-
Notifications
You must be signed in to change notification settings - Fork 244
kvdb-rocksdb: Force compact the DB on startup and on heavy writes #949
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
Conversation
This changes kvdb-rocksdb to force compact the DB on startup and when we are writing a lot of data. This significantly improves the read performance after doing a warp sync for example.
| // | ||
| // Otherwise, rocksdb read performance is going down, after e.g. a warp sync. | ||
| if stats_total_bytes > self.config.compaction.initial_file_size as usize && | ||
| self.last_compaction.lock().elapsed() > Duration::from_secs(60) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any ideas how long compaction lasts? 60s sounds too often - but it is a pure guess from my side.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its only when we do large write and 60s have passed. If not much happens, we will not compact every 60 seconds. But also means that if changes to rocksdb trickle in, this branch will never be triggered. But maybe thats okay and rocksdb can handle that case by itself. At least we saw this problem mostly with large writes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not measure it, but it took less than 60s. Also we are not really writing that much. Even if it takes longer, rocksdb internally hopefully prevents this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hopefully
[x] doubts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For whoever lands here in the future, sorry :)
|
Leaving this link here for the future readers: tikv/rfcs#110 Maybe worth adding to the PR description? |
Not only this. It is also mentioned in their own docs of rocksdb that you sometimes need to do manual compaction. |
This changes kvdb-rocksdb to force compact the DB on startup and when we are writing a lot of data. This significantly improves the read performance after doing a warp sync for example.