Skip to content

mvcc: gc write CF with compaction filter#5333

Closed
hicqu wants to merge 24 commits intotikv:masterfrom
hicqu:gc-use-compaction-filter
Closed

mvcc: gc write CF with compaction filter#5333
hicqu wants to merge 24 commits intotikv:masterfrom
hicqu:gc-use-compaction-filter

Conversation

@hicqu
Copy link
Copy Markdown
Contributor

@hicqu hicqu commented Aug 26, 2019

What have you changed?

GC write CF with compaction filter.

What is the type of the changes?

Improvement.

How is the PR tested?

Unit tests

Benchmark result if necessary (optional)

With the patch:
图片
Without the patch:
图片

Dependencies

@hicqu hicqu force-pushed the gc-use-compaction-filter branch 5 times, most recently from e73e42f to a63afc6 Compare August 29, 2019 07:12
@hicqu hicqu removed the S: WIP label Aug 29, 2019
@hicqu hicqu force-pushed the gc-use-compaction-filter branch 4 times, most recently from a20612f to d8bc119 Compare August 29, 2019 07:45
@hicqu
Copy link
Copy Markdown
Contributor Author

hicqu commented Aug 29, 2019

It can be reviewd now. PTAL @MyonKeminta @Little-Wallace thanks!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't think it's a good idea to leak txn concepts to raft layer. How about inspecting the deleted keys and sending MvccGcTask in raftstore::coprocessor?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think it's not raft layer, it's just a proposal that needs to do some special things for it. We also have ComputeHash like this.

@hicqu hicqu force-pushed the gc-use-compaction-filter branch 2 times, most recently from cd9cae6 to d176c7c Compare August 30, 2019 08:41
@hicqu
Copy link
Copy Markdown
Contributor Author

hicqu commented Aug 30, 2019

PTAL @MyonKeminta thanks!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Create thread for every task? why not threadpool?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Emm, we have removed many thread pools. I'm afraid to add one more. what do you think @zhangjinpeng1987 ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we could make Rocksdb support CompactRange in async way, which just put it into background threadpool of Rocksdb. @yiwu-arbug

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good idea. So let's keep the current implementation, and switch to the async API when it's ready.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

keep the current way and leave a TODO comment here?

hicqu added 10 commits September 5, 2019 12:25
Signed-off-by: qupeng <qupeng@pingcap.com>
Signed-off-by: qupeng <qupeng@pingcap.com>
Signed-off-by: qupeng <qupeng@pingcap.com>
Signed-off-by: qupeng <qupeng@pingcap.com>
Signed-off-by: qupeng <qupeng@pingcap.com>
Signed-off-by: qupeng <qupeng@pingcap.com>
Signed-off-by: qupeng <qupeng@pingcap.com>
Signed-off-by: qupeng <qupeng@pingcap.com>
Signed-off-by: qupeng <qupeng@pingcap.com>
Signed-off-by: qupeng <qupeng@pingcap.com>
hicqu added 11 commits September 5, 2019 12:25
Signed-off-by: qupeng <qupeng@pingcap.com>
Signed-off-by: qupeng <qupeng@pingcap.com>
Signed-off-by: qupeng <qupeng@pingcap.com>
Signed-off-by: qupeng <qupeng@pingcap.com>
Signed-off-by: qupeng <qupeng@pingcap.com>
Signed-off-by: qupeng <qupeng@pingcap.com>
Signed-off-by: qupeng <qupeng@pingcap.com>
Signed-off-by: qupeng <qupeng@pingcap.com>
Signed-off-by: qupeng <qupeng@pingcap.com>
Signed-off-by: qupeng <qupeng@pingcap.com>
Signed-off-by: qupeng <qupeng@pingcap.com>
@hicqu hicqu force-pushed the gc-use-compaction-filter branch from 14c91d2 to ea2a791 Compare September 5, 2019 04:26

use crate::raftstore::store::keys::{data_end_key, data_key};
use crate::storage::mvcc::{
extract_mvcc_props, get_gc_ratio, init_mvcc_gc_db, init_safe_point, need_gc,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think you'd better reconsider the overall architecture to avoid coupling between raftstore and storage.

let dek = data_end_key(&task.end_key);
if *sk < dek && dsk < *ek {
// overlap with a range in compaction.
info!("gc task overlap, skip");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why not use a BTreeMap instead of a HashMap, so you don't need to iterate all ranges and check all of them?

}

pub fn need_gc(props: MvccProperties, safe_point: u64, ratio_threshold: f64) -> bool {
if ratio_threshold <= 1.0 {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This seems to be duplicated with Reader::need_gc. I think you can invoke this function in Reader::need_gc.

@hicqu hicqu added component/storage Component: Storage, Scheduler, etc. type/enhancement The issue or PR belongs to an enhancement. labels Sep 9, 2019
@nolouch nolouch added the S: DNM label Oct 28, 2019
@hicqu hicqu closed this Nov 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component/storage Component: Storage, Scheduler, etc. type/enhancement The issue or PR belongs to an enhancement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants