Ticket #7300 (new feature request)

Opened 8 months ago

Last modified 7 months ago

Allow CAFs kept reachable by FFI to be forcibly made unreachable for GC

Reported by: absence Owned by:
Priority: high Milestone: 7.8.1
Component: Compiler (FFI) Version: 7.4.1
Keywords: unsafe caf gc Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Runtime performance bug Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

CAFs used by a foreign exported function are kept reachable the entire session because GHC can't know when the function will be called from C. If such a CAF is an evolving expression, like an FRP network, a space leak occurs because (I'm guessing) the thunks that build up during iteration go all the way back to the initial CAF, and the GC can't start collecting because it considers the CAF reachable. According to JaffaCake? on the #haskell IRC channel, the runtime is capable of sovling this problem, it just needs a function that tells it to consider the specific CAF unreachable. It is then the responsibility of the user to not call the foreign exported function after the CAF is forced unreachable.

Change History

  Changed 8 months ago by simonmar

  • priority changed from normal to high
  • difficulty set to Unknown
  • milestone set to 7.8.1

Thanks for making a ticket.

What I had in mind (to remind myself) is that we expose a C API from the RTS that would revert all the live CAFs. This would have to be done at the same time as a major GC, because that is the only time that we can visit all the live CAFs.

follow-up: ↓ 3   Changed 8 months ago by ezyang

Of course, revertCAFs only works when the linker sets up CAFs with newDynCAF...

in reply to: ↑ 2   Changed 7 months ago by simonmar

Replying to ezyang:

Of course, revertCAFs only works when the linker sets up CAFs with newDynCAF...

Spot on.

Note: See TracTickets for help on using tickets.