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

Add option for smaller bitcask keys #643

Merged
merged 3 commits into from
Sep 20, 2013
Merged

Conversation

evanmcc
Copy link
Contributor

@evanmcc evanmcc commented Aug 27, 2013

The kv bucket/key to bitcask key conversion uses term_to_binary. This results in 13 bytes of overhead per key.

This patch introduces a new key format:

|--|---bucket---|---key--|
 ^---- bucket_len

The first two bytes specify the length of the bucket, allowing kv to translate the compact binary back to the bucket/key pair that it needs. In order to read old-format values off of disk, this code allows the insertion of a translation function, so that keys in the keydir are in a consistent format. This saves 11 bytes per entry in the keydir.

When a large percentage of your keys on disk are in the old format, there is a small but noticable slowdown in startup time and fold time. This should go down over time as keys are replaced. If the slowdown is intolerable, adding {small_keys, false} to the bitcask section of your app.config will revert to the old format. This feature is currently on by default; whether this should be the case is up for debate.

This PR depends on a change in bitcask adding support for key transformation functions:
basho/bitcask#103

evanmcc and others added 2 commits August 27, 2013 10:36
The new keydir format has 2 forms, as follows

<<Version:7, 0:1, BucketSize:16/integer, Bucket/binary, Key/binary>>
<<Version:7, 1:1, TypeSize:16/integer, Type/binary, BucketSize:16/integer, Bucket/binary, Key/binary>>

The 8th bit of the binary is the bit that indicates if a bucket type is
present, and tells the decoder which form to expect.
@Vagabond
Copy link
Contributor

This mostly looks ok, although it needs my refactor to support bucket types over in #663.

Modify the version 1 format to support bucket types
@evanmcc
Copy link
Contributor Author

evanmcc commented Sep 19, 2013

Merged, your PR, is this ready to merge once the bitcask comments have been addressed?

@Vagabond
Copy link
Contributor

Yes.

evanmcc added a commit that referenced this pull request Sep 20, 2013
@evanmcc evanmcc merged commit e4f561e into develop Sep 20, 2013
@seancribbs seancribbs deleted the pevm-keydir-overhead-support branch April 1, 2015 23:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants