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 to use row cache of RocksDB #407

Merged
merged 3 commits into from
Dec 7, 2021
Merged

Conversation

ShooterIT
Copy link
Member

@ShooterIT ShooterIT commented Nov 30, 2021

For kvrocks point lookups, row cache is more useful than block cache, so we can enlarge row cache size and lessen meta/subkey block cache size.

If there are some hot keys that have the same prefix, they may be in the same block cache, so competition will be more serious, but if we use row cache, these keys may distribute into different cache shard since in row cache, distribute them by its hash value.

"4G block cache" VS "2G row cache and 2G block cache"

Test by benchmark (-t get -d 1024 -r 10000000 -n 10000000 --threads 8 -c 128)

Use row cache First test Second test Third test
No 291358 275755 242318
Yes 266084 263067 270182

in random mode, there is no obvious difference.

@ShooterIT ShooterIT linked an issue Nov 30, 2021 that may be closed by this pull request
@caipengbo
Copy link
Contributor

Meta data is mostly a point-query scenario, subkey is often a range query. Can we use only row cache in meta and only block cache in subkey?

@ShooterIT
Copy link
Member Author

I don't find a solution now, row cache is a global cache.

caipengbo
caipengbo previously approved these changes Nov 30, 2021
Copy link
Contributor

@caipengbo caipengbo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just a minor problem about config comments.

git-hulk
git-hulk previously approved these changes Dec 3, 2021
@ShooterIT ShooterIT added major decision Requires project management committee consensus release notes labels Dec 5, 2021
@ShooterIT ShooterIT marked this pull request as draft December 6, 2021 04:40
@ShooterIT
Copy link
Member Author

Currently, from my some tests, i don't find row cache has obvious profit. Now i convert it to draft, maybe i have wrong understanding, if anyone have new ideas, happy to listen your thoughts

@ShooterIT ShooterIT marked this pull request as ready for review December 7, 2021 00:29
Copy link
Member

@git-hulk git-hulk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ShooterIT
Copy link
Member Author

If there are some hot keys that have the same prefix, they may be in the same block cache, so competition will be more serious, but if we use row cache, these keys may distribute into different cache shard since in row cache, distribute them by its hash value.

And in theory, row_cache is more useful for hots keys scenario since we don't need search on index and data block.

But this mechanism is not always useful and also use more memory, so we disable it by default, you can enable it if you want to test or use it.

@ShooterIT ShooterIT changed the title Use row cache of RocksDB to implement kv cache Support to use row cache of RocksDB Dec 7, 2021
@ShooterIT ShooterIT merged commit 98f7d03 into apache:unstable Dec 7, 2021
@ShooterIT ShooterIT deleted the row_cache branch December 7, 2021 01:14
ShooterIT added a commit to ShooterIT/kvrocks that referenced this pull request Dec 7, 2021
RocksDB row cache may be useful for hots keys scenario, but it is not always
useful and cost much more memory, so it is disabled by default, you can test
and then decide to enable it or not in your scenario.
@ShooterIT ShooterIT mentioned this pull request Dec 7, 2021
ShooterIT added a commit that referenced this pull request Dec 7, 2021
RocksDB row cache may be useful for hots keys scenario, but it is not always
useful and cost much more memory, so it is disabled by default, you can test
and then decide to enable it or not in your scenario.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
major decision Requires project management committee consensus release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[NEW] Use row cache of RocksDB to implement KV cache
3 participants