Skip to content

Resource limits for Haskell

commit 1f5eb79cc278fd64ee3f1f4249ea3b7404f62ba1
Author: Edward Z. Yang <ezyang@mit.edu>
Date:   Thu Mar 7 13:53:31 2013 -0800

    Primops and runtime support for space resource limits.
    
    This patch adds support for resource limits in Haskell, especially
    for monitoring and triggering events when portions of Haskell code
    exceed memory usage and/or allocation.  The system is described in
    more detail at.
    
        http://hackage.haskell.org/trac/ghc/wiki/Commentary/ResourceLimits
    
    This patch adds the following types:
    
        CostCentre# - non-GCd pointer to CostCentre struct
        CostCentreStack# - non-GCd pointer to CostCentreStack struct
        Listener# - GC'd object for listening to pointer events
    
    and the following primops:
    
        ccToAddr
        addrToCC
        ccsToAddr
        addrToCCS
    
        newCC#
        setCCSOf#
        withCCS#
        pushCC#
        queryCCS#
        listenCCS#
        unlistenCCS#
    
    These previously existing primops have had their types changed,
    mainly for better type safety (replacing Addr# with CostCentreStack#)
    
        getCCSOf#
        getCurrentCCS#
    
    We add the following new RTS options:
    
        -hl     equivalent to -hc but also keeps census information in-memory
                for access and does not write out a *.hp file
    
        -xf     modified cost-centre stack semantics, where function entries
                never modify the stack (so only CAFs and explicit set CCCS
                affect cost-centres).
    
    To utilize these new features, compile with -prof and run with +RTS -hl -xf

See also http://hackage.haskell.org/trac/ghc/wiki/Commentary/ResourceLimits

Probably the most dodgy parts of the patch is the primop code for withCCS#, and some of the refactoring of the heap profiler.

Edited by Edward Z. Yang
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information