Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Concurrent garbage collector #85

Open
KCreate opened this issue Mar 31, 2022 · 0 comments
Open

Concurrent garbage collector #85

KCreate opened this issue Mar 31, 2022 · 0 comments

Comments

@KCreate
Copy link
Owner

KCreate commented Mar 31, 2022

  • Load / Write Barriers

    • Some kind of load barrier when loading from other heap objects
    • When does the runtime have to check the forward pointers of a cell?
    • How does this mechanism work?
    • How is it implemented?
  • Phases

    • Idle | Application is running normally, GC is not running
    • Idle -> Marking | Mark roots and start background marking
    • Marking | Heap tracing, write barriers append to queue drained at next pause
    • Marking -> Evacuation | Drain SATB buffers and initialize evacuation phase
    • Evacuation | Heap objects get relocated, write barriers access forward pointer
    • Evacuation -> UpdateRef | Initialize update ref phase
    • UpdateRef | Heap references to old objects get updated, write barriers update references
    • UpdateRef -> Idle | Finalize garbage collection, prepare for idle phase
  • Concurrent Marking

    • Init phase
      • Workers mark root set
      • New allocations marked grey
      • Mark all VM reachable objects
      • Arm SATB buffers
    • Concurrent phase
      • Traverse application and mark reachable objects
      • Collect statistics and information about heap regions
    • Application threads
      • Write barriers
      • Read barriers
  • Evacuation

    • Init phase
      • Disable and mark values from SATB buffers
      • Finish marking
      • Build From-To evacuation mappings
      • Evacuate worker root set
    • Concurrent phase
      • Traverse From Regions and evacuate cells to To-regions
    • Application threads
      • Evacuate in barriers
    • How do evacuated cells know where they end up?
      • Build mapping of From-spaces to To-spaces
        • During the Init-Evacuate pause, allocate each alive cell in From-regions a slot in the corresponding
          To-regions
        • Evacuation can atomically check if the final copy has already been created / initialized
      • Each from-space knows in what to-space it will end up
        • Need some easy way of knowing which offset each cell ultimately ends up at
    • How are the copies that are created during a contended evacuation recycled?
      • Mechanism to un-allocate a cell, works only if no other cell was allocated since
        • Since another copy will be allocated in another region, we can just unwind the last allocation and reuse it for the next one
  • UpdateRef

    • Init phase
      • Update root set
    • Concurrent phase
      • Update references to objects in from-spaces
    • Application threads
      • Update references during load barriers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant