Last active
October 23, 2022 11:01
-
-
Save pervognsen/4779c867e02f3de50bbd1cb01f82fb66 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is another take on the mark-compact collector from https://gist.github.com/pervognsen/7fe51bef8977cb249ac4c6f830f818a5 | |
// To avoid having to do global compaction, our object indices will have two parts: a block index and a block offset. | |
// Within a block we have the same linear older-to-newer ordering by offset. But now blocks are allowed to have different ages. | |
// The block ages are defined by their position in a linked list: There's oldest_block and newest_block indices and then | |
// previous_block[block_index] for each block. This enables newest-to-oldest block iteration and the linked-list structure | |
// means that we can free an empty block by unlinking it. When a block is reused, it becomes the newest_block. Now, instead | |
// of only compacting within a block we will actually be coalescing across an age range of blocks. By doing so, we will usually | |
// be able to empty out entire blocks from the newer part of that age range, so they can be reused. This should have very similar | |
// performance characteristics to a generational collector. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment