[GHC] #15403: Compact Regions with Lazy Evaluation

GHC ghc-devs at haskell.org
Tue Jul 17 02:40:23 UTC 2018


#15403: Compact Regions with Lazy Evaluation
-------------------------------------+-------------------------------------
           Reporter:  andrewthad     |             Owner:  (none)
               Type:  feature        |            Status:  new
  request                            |
           Priority:  normal         |         Milestone:  8.6.1
          Component:  Compiler       |           Version:  8.4.3
           Keywords:                 |  Operating System:  Unknown/Multiple
       Architecture:                 |   Type of failure:  None/Unknown
  Unknown/Multiple                   |
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 Currently, adding a value to a compact region evaluates it to normal form.
 I'm wondering if it's possible to have another compacting primitive that
 can add unevaluated thunks to a compact region. These thunks would be
 evaluated as they were demanded, and the resulting values would be added
 to the compact region. I actually have a use case for this in mind
 involving very large map-like data structures whose size exceeds system
 memory when in normal form but that are largely unevaluated, giving them a
 memory footprint that is a fraction of what it would be.

 One problem would be that a compaction failure (from someone trying to
 stick a function or a `MutableArray#` into a compact region) would happen
 after the call to `compactLazy`, so you end up with all the usual lazy IO
 problems. Another problem would be that the thunks wouldn't get GCed,
 since they would live in a compact region (and also because you could not
 update the references to the thunk, since compact regions are not scanned
 during GC). Neither of these are absolute deal-breakers though.

 Are there other problems that make this fundamentally impossible to do? Or
 is this something that could conceivably be added?

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15403>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list