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 in-memory compaction in rocksdb and use it for lock CF #8140

Open
yiwu-arbug opened this issue Jun 25, 2020 · 6 comments
Open

Support in-memory compaction in rocksdb and use it for lock CF #8140

yiwu-arbug opened this issue Jun 25, 2020 · 6 comments
Assignees
Labels
component/rocksdb Component: RocksDB engine difficulty/hard Difficulty: Hard. sig/engine SIG: Engine
Projects

Comments

@yiwu-arbug
Copy link
Contributor

yiwu-arbug commented Jun 25, 2020

Feature Request

Is your feature request related to a problem? Please describe:

For rocksdb (or any LSM tree implementation) in use cases when data get deleted soon after they being inserted, when memtable flush to disk, the end result could be significant smaller than the memtable size. This will result in inefficient compaction since L0 file sizes become too small. One way to work it around is compacting memtables: instead of flushing memtable when they are full, we can run compaction on them to reduce their size in memory. The technique reduces IO and also keep hot data in memory as much as possible.

One challenge to implement in-memory compaction is handling WAL. Normally when memtable get flushed, corresponding WAL file can be deleted since data is persisted to SSTs. However, after in-memory compaction such WAL files cannot be deleted. They will grow indefinitely. A workaround is to force memtable flush when WAL size reach certain threshold. RocksDB already provide such functionality. The WAL wouldn't be a problem if we remove the use of WAL from KvDB.

We can use in-memory compaction on lock CF to reduce its IO cost and keep its content in memory for query.

This is a common optimization for LSM implementations. We can probably sync with rocksdb team to know their views and plan.

@yiwu-arbug yiwu-arbug added help wanted Help wanted. Contributions are very welcome! component/rocksdb Component: RocksDB engine difficulty/hard Difficulty: Hard. sig/engine SIG: Engine labels Jun 25, 2020
@github-actions github-actions bot added this to To Do in Engine SIG Jun 25, 2020
@jyizheng
Copy link
Contributor

jyizheng commented Jul 6, 2020

Is this task to change RocksDB code? Is the in-memory compaction can be controlled by ti TiKV code? It would be helpful if anybody gives me a pointer to the relevant code.

@yiwu-arbug
Copy link
Contributor Author

@jyizheng Yes, this task require changing rocksdb code, and for a warning this task is a hard task which could easily take > 1 month work. If you are still interested you can join #sig-engine channel at tikv-wg.slack.com and ping us. Thanks.

@jyizheng
Copy link
Contributor

jyizheng commented Jul 7, 2020

@yiwu-arbug Yes, I still want to work on this issue. I want to learn more about RocksDB. Can this issue be assigned to me?

@yiwu-arbug
Copy link
Contributor Author

Discussed with @jyizheng offline and he will be working on the task.

@yiwu-arbug yiwu-arbug removed the help wanted Help wanted. Contributions are very welcome! label Jul 7, 2020
@yiwu-arbug yiwu-arbug moved this from To Do to In Progress(Developing) in Engine SIG Jul 7, 2020
@Connor1996 Connor1996 self-assigned this Jun 16, 2021
@Connor1996
Copy link
Member

From my test, l0 flow of lock CF is high.
image

With in-memory compaction, I think it would save some unnecessary write IO.

@dwangxxx
Copy link
Contributor

dwangxxx commented Jan 5, 2022

From my test, l0 flow of lock CF is high. image

With in-memory compaction, I think it would save some unnecessary write IO.

Hi, how should I get the compaction flow like this image? I'm not familiar with RocksDB, could you give me some guidance? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/rocksdb Component: RocksDB engine difficulty/hard Difficulty: Hard. sig/engine SIG: Engine
Projects
Engine SIG
  
In Progress(Developing)
Development

No branches or pull requests

4 participants