Skip to content
This repository was archived by the owner on Apr 25, 2025. It is now read-only.
This repository was archived by the owner on Apr 25, 2025. It is now read-only.

Local Discardable Heaps #149

@RossTate

Description

@RossTate

In #121 (specifically here), there is discussion of how Erlang relies on keeping process heaps isolated for quick clean up. It seems this might be very important to good performance for at least Erlang, possibly for other systems as well, so I thought it might be useful to provide high-level notes on how to make this possible.

First, we need an instruction like new_heap $h instr* end. This creates a new heap that can be referenced within instr* via $h. Supposing each Erlang process is run in its own stack, this instruction could be one of the first things in the root of each stack. Second, we need a reference type (constructor) that can be parameterized by a heap, say heapref $h (which also takes some additional parameter specifying the layout of the referenced data). Within the body of new_heap, one would then be able to construct and track references within specifically the new heap. Third, we will need to make it possible for functions to have heaps as parameters. This makes it possible to call such functions from within new_heap.

If you design your (sub)typing system right, you can ensure no references in this new heap are still live once end is reached (or the relevant stack frame is cleaned up). Consequently, you can clean up the entire new heap all at once. It's also possible to have a variant of the new_heap instruction that makes it so that the new heap is an extension of an existing heap, which (with appropriate subtyping rules) would enable data in the new heap to (easily) point into the existing heap but not the other way around.

Of course, this all relies on having the write (sub)typing rules. In particular, if heapref $h <: anyref holds, then all references in the new heap can leak as anyref values. So this feature seems incompatible with having a (global) top type for references.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions