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
About Deletion marker #655
Comments
Mark/sweep as you'd see in a garbage collector is way more complicated than what happens in leveldb. A simplified version of how leveldb works (ignoring some of the implementation details for the youngest generation and optimizations like bloom filters and key sharding) is that there's a stack of files representing (more or less) snapshots of the database. When you go to look up a key, you first look in the top file in the stack. If you find a key, or a deletion marker, you stop there. Otherwise you keep going down the stack until you either find the key or reach the bottom of the stack. So for example imagine this stack of tables:
then what you would see iterating through the database would be Compaction is basically removing the redundant data in lower levels of the stack. So if we were to compact
Because the lower levels of the stack are logically immutable, compaction can happen in the background and then the stack of tables can be atomically replaced by the new, single, compacted table. Some of the configured options control when stuff happens. Basically once a level gets above a certain size, it gets compacted with the level under it. Compaction can also be manually triggered for a key range, for example if you know that you're not going to be writing to that range for a while but are going to be reading from it a lot (since compaction can avoid the need to search multiple levels for your key). As the documentation states, however, you're probably better off leaving compaction up to the built-in logic. |
Thx for the response @adam-azarchs. I think this is answered, but please reopen if not. |
I am korean student and Can I ask few question? if you are not busy.
I know that leveldb's delete operation is implemented by deletion marker.
if the user delete data multiple times, many space will be waste so leveldb has compaction algorithm.
Thank you.
The text was updated successfully, but these errors were encountered: