rocksdb icon indicating copy to clipboard operation
rocksdb copied to clipboard

iterator.seek() so slow

Open meilihao opened this issue 3 years ago • 4 comments

I use rocksdb to store cdp(Continuous Data Protection) data. key is 'p'+nanosecond timestamp(uint64), value is sector + bio data.

my env: 2022-08-09_19-16-48

my code: 2022-08-09_19-15-11 2022-08-09_19-15-46 2022-08-09_19-08-47

Expected behavior

iterator.seek() returns soon.

Actual behavior

2022-08-09_19-09-18

2022-08-09_19-24-15

seek() need 1~2h or more on my other db(206g).

meilihao avatar Aug 09 '22 11:08 meilihao

I found SeekToFirst() is slow too.

meilihao avatar Aug 09 '22 11:08 meilihao

Do you have a lot of Deletes in your app? From the perf_context, it seems that a lot of data block (block_read_bytes) is read due to skipping deleted entries (internal_delete_skipped_count). Doing a full manual compaction might help remove all the tombstones. A similar issue before: #10300

cbi42 avatar Aug 09 '22 16:08 cbi42

@cbi42, thank your answer. I tried db.CompactRange(Range{nil, nil}), and iterator.seek() returns soon. But CompactRange(42g) need 11 minutes, it's too long.

There is a lot of writing rocksdb in my application. Do you have any optimization suggestions?

meilihao avatar Aug 10 '22 03:08 meilihao

Hi @meilihao, I'm not an expert on compaction, so my suggestion on that is limited and others are welcomed to add more. I think tuning options that allow more compactions in the background should be helpful. You can checkout some wikis here: https://github.com/facebook/rocksdb/wiki/Compaction, https://github.com/facebook/rocksdb/wiki/Setup-Options-and-Basic-Tuning, https://github.com/facebook/rocksdb/wiki/Prefix-Seek.

cbi42 avatar Aug 11 '22 04:08 cbi42