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

Support online garbage collection #10

Closed
chenhao-ye opened this issue Oct 17, 2021 · 0 comments
Closed

Support online garbage collection #10

chenhao-ye opened this issue Oct 17, 2021 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@chenhao-ye
Copy link
Collaborator

A few thoughts on how to implement GC when there are still other processes running:

  • As discussed previously, we could move blocks at the end of the file to fill holes in the middle. Let' call it relocation. For the blocks that are organized as linked lists (e.g. LogEntryBlock), we could use an RCU to atomically relocate the block: copy it to the hole and CAS to update the pointer pointing to it.
  • To relocate DataBlock, we must scan through the log (and clean up dead log entries too), since the log will contain pointer points to DataBlock.
  • In MetaBlock, we maintain a gc_clock, which is a logical clock (or version number, if this is a better term); every time a GC completes, increase gc_clock by one. In the current block allocation, every process will always try to allocate from the recent bitmap it has successfully allocated; if fails, then try to allocate from the next bitmap, so bitmaps are searched in increasing order. When a process fails to allocate blocks from the last bitmap, it then tries to extend the bitmap. Now that we gc_clock, the process could compare it to the last gc_clock it has seen. If it is mismatched, it means a new GC happened so instead of extending the file, it tries to rescan all the bitmap from the head.
@chenhao-ye chenhao-ye added the enhancement New feature or request label Oct 17, 2021
@chenhao-ye chenhao-ye self-assigned this Nov 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants