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 support of using hyper clock cache as the block cache #2031

Merged
merged 15 commits into from
Jan 24, 2024

Conversation

JxLi0921
Copy link
Contributor

This is related to this issue #2022 . I will soon post my simple benchmark result for this PR below.

@JxLi0921
Copy link
Contributor Author

The script for pressing data into kvrocks:

memtier_benchmark -t 4 -c 20 -h 127.0.0.1 -p 6666 --distinct-client-seed --key-minimum=1000000000 --key-maximum=10000000000 --random-data --key-prefix="" --data-size=50 -n 2000000 --pipeline=100 --command "mset key data key data key data key data key data key data key data key data key data key data"

The script for benchmarking: where the READ_RATIO is 0, 50, 90 or 100, respectively.

memtier_benchmark -t 4 -c 20 -s 127.0.0.1 -p 6666 --distinct-client-seed --key-minimum=1000000000 --key-maximum=10000000000 --key-prefix="" -n 10000 --command "get key" --command-ratio=READ_RATIO --command "set key value" --command-ratio=100-READ_RATIO

Here is the P99, P999 and P9999 latency with difference read ratios for the SET and GET command in the benchmark above.

SET:
latency_SET

GET:
latency_GET

@wanghenshui
Copy link
Contributor

--data-size=50 -n 2 000 000

50 * 2,000,000 * 20(c) = 2,000,000,000

how much rocksdb sst data your make, 2G? please make at least 10G data

@mapleFU
Copy link
Member

mapleFU commented Jan 20, 2024

I think the clock might has better concurrency and perhaps a bit worse cache hit rate. We can also report the cache hit rate etc for analyzing the performance here

Copy link
Member

@mapleFU mapleFU left a comment

Choose a reason for hiding this comment

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

+1 for this pr.
And maybe we can dive into benchmark result and find some reason of performance🤔

src/storage/storage.cc Outdated Show resolved Hide resolved
@JxLi0921
Copy link
Contributor Author

--data-size=50 -n 2 000 000
50 * 2,000,000 * 20(c) = 2,000,000,000
how much rocksdb sst data your make, 2G? please make at least 10G data

@wanghenshui Thanks for your review! The command I used to press the data into kvrocks is mset key data * 10, so maybe it's 20G instead of 2G? I am not convinced with my understanding, please correct me if I am wrong.

@JxLi0921
Copy link
Contributor Author

I think the clock might has better concurrency and perhaps a bit worse cache hit rate. We can also report the cache hit rate etc for analyzing the performance here

Thanks for your review! I would add these statistics later today.

@mapleFU
Copy link
Member

mapleFU commented Jan 20, 2024

As for the statistics, you can refer Server::GetRocksDBInfo for help

kvrocks.conf Outdated
Comment on lines 572 to 575
# Specify the type of cache used in the block cache.
# Accept value: "lru", "hcc"
# default lru
rocksdb.block_cache_type lru
Copy link
Member

Choose a reason for hiding this comment

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

Could you explain the meaning of lru and hcc for users in the comment>

options.row_cache = rocksdb::NewLRUCache(config_->rocks_db.row_cache_size * MiB);
// Parameters for the rocksdb::LRUCacheOptions here are set in line with the default parameters for the
// rocksdb::NewLRUCache function, which is now deprecated
rocksdb::LRUCacheOptions lru_cache_options(config_->rocks_db.row_cache_size * MiB, -1, false, 0.5);
Copy link
Member

Choose a reason for hiding this comment

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

Could we add some named constants for these default arguments (e.g. -1, false, 0.5)?

Copy link
Contributor Author

@JxLi0921 JxLi0921 Jan 20, 2024

Choose a reason for hiding this comment

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

I have did this, but I am not sure whether the names of my constants are proper.

rocksdb::LRUCacheOptions lru_cache_options(block_cache_size, -1, false, 0.75);
shared_block_cache = lru_cache_options.MakeSharedCache();
} else {
rocksdb::HyperClockCacheOptions hcc_cache_options(block_cache_size, 0);
Copy link
Member

Choose a reason for hiding this comment

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

ditto for 0 here.

@git-hulk
Copy link
Member

git-hulk commented Jan 20, 2024

@JxLi0921 Great, thanks for your PR. I'm not sure if the QPS throughput is close between Hyper Clock Cache and LRU since I didn't see this in previous report.

@JxLi0921
Copy link
Contributor Author

JxLi0921 commented Jan 24, 2024

Sorry for late update. I found that the way I use memtier_benchmark is totally wrong before.

Here is my current script for putting data and running benchmark:

Putting data into kvrocks:

memtier_benchmark -t 8 -c 20 -h 127.0.0.1 -p 6666 --distinct-client-seed --key-minimum=1000000000 --key-maximum=10000000000 --random-data --key-prefix="" --data-size
=50 -n 2000000 --pipeline=100 --command "mset __key__ __data__ __key__ __data__ __key__ __data__  __key__ __data__ __key__ __data__ __key__ __data__ __key__ __data__ __key__ 
__data__ __key__ __data__ __key__ __data__"

I failed to run the script above to complete because I am almost run out of disk space. After running the script above for about 20% of progress, the keyspace statistics of kvrocks is as follows.

#  Keyspace
# Last DBSIZE SCAN time: Wed Jan 24 12:04:59 2024
db0:keys=341377306,expires=0,avg_ttl=0,expired=0
sequence:615748420
used_db_size:18388474802
max_db_size:0
used_percent: 0%

Running benchmark:

memtier_benchmark -t 4 -c 20 -s 127.0.0.1 -p 6666 --distinct-client-seed --key-minimum=1000000000  --key-maximum=10000000000 --key-prefix="" -n 50000 --ratio={100-read_ratio}:{read_ratio}

where the read_ratio above is one of 0, 50, 90 and 100.

Result:

GET Latency:

latency_GET

SET Latency:

latency_SET

GET Ops/sec

ops_GET

SET Ops/sec

ops_SET

Overall(Get+Set) Ops/sec

ops_Overall

According to the results listed above, it seems that HCC does outperform LRU for latency and throughput in this simple benchmark.

Block Cache Hit Ratio:

cacheHit_SET

I'm not sure whether it's normal to have the block cache hit ratios to be almost 100. Should I use a smaller block cache size? I used 4096MB block cache size in this benchmark, which is kvrocks' default configuration.

Copy link
Member

@mapleFU mapleFU left a comment

Choose a reason for hiding this comment

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

Thanks for the investigate. I may go for this this weekend. At lease we can first checkin this patch?

Also @JxLi0921 would you mind tell the CPU and disk you're using?

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.

Cool, LGTM

@JxLi0921
Copy link
Contributor Author

JxLi0921 commented Jan 24, 2024

would you mind tell the CPU and disk you're using?

@mapleFU

CPU: AMD Ryzen 6800H
Disk: SAMSUNG MZVL2512HCJQ-00B00

@mapleFU mapleFU merged commit 02a6240 into apache:unstable Jan 24, 2024
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants