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 size properties collector #2097

Merged
merged 12 commits into from
Aug 7, 2017
Merged

Add size properties collector #2097

merged 12 commits into from
Aug 7, 2017

Conversation

huachaohuang
Copy link
Contributor

@huachaohuang huachaohuang commented Jul 28, 2017

Collect size properties from CF_DEFAULT and CF_WRITE.

Don't merge until #2096 has been merged.

@huachaohuang huachaohuang force-pushed the huachao/mvcc-properties branch from 556542c to 0e9c6bc Compare July 31, 2017 06:27
@huachaohuang huachaohuang force-pushed the huachao/size-properties branch from 876e609 to 3f492ac Compare July 31, 2017 14:04
@huachaohuang huachaohuang changed the base branch from huachao/mvcc-properties to master July 31, 2017 14:19
@huachaohuang huachaohuang changed the title [DNM] Add size properties collector Add size properties collector Jul 31, 2017
@huachaohuang
Copy link
Contributor Author

PTAL @zhangjinpeng1987 @BusyJay

@@ -30,6 +32,9 @@ const PROP_NUM_PUTS: &'static str = "tikv.num_puts";
const PROP_NUM_VERSIONS: &'static str = "tikv.num_versions";
const PROP_MAX_ROW_VERSIONS: &'static str = "tikv.max_row_versions";
const PROP_NUM_ERRORS: &'static str = "tikv.num_errors";
const PROP_TOTAL_SIZE: &'static str = "tikv.total_size";
const PROP_SIZE_INDEX: &'static str = "tikv.size_index";
const PROP_SIZE_INDEX_DISTANCE: u64 = 4 * 1024 * 1024;
Copy link
Contributor

Choose a reason for hiding this comment

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

how about if the SST target file size is smaller than 4 MB?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Then we collect only the start key and the end key.

@@ -183,6 +283,18 @@ impl UserProperties {
buf.encode_u64(value).unwrap();
self.encode(name, buf);
}

// Format: | klen | k | v.size | v.offset |
pub fn encode_handles(&mut self, name: &str, handles: &BTreeMap<Vec<u8>, IndexHandle>) {
Copy link
Member

@zhangjinpeng87 zhangjinpeng87 Aug 1, 2017

Choose a reason for hiding this comment

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

This function is not belongs to here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why not?

Copy link
Member

Choose a reason for hiding this comment

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

Because IndexHandle is a concept of SizeProperties.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not really, it can be a common struct in the future. For example, we may add handles for rows count later.

@@ -167,6 +172,101 @@ impl TablePropertiesCollectorFactory for MvccPropertiesCollectorFactory {
}
}

#[derive(Clone, Debug, Default)]
pub struct IndexHandle {
Copy link
Member

Choose a reason for hiding this comment

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

As you mentioned, how to add rows informations in this struct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For example, we may have a RowsProperties like:

struct RowsProperties {
    total_rows: u64,
    index_handles: BTreeMap<Vec<u8>, IndexHandle>,
}

It needs to encode the index_handles too, so I put the encode_handles() in a common place.
Besides, I prefer to put those encode/decode in one place.

@huachaohuang
Copy link
Contributor Author

PTAL @zhangjinpeng1987 @BusyJay

while !buf.is_empty() {
let klen = try!(buf.decode_u64());
let mut k = vec![0; klen as usize];
try!(buf.read_exact(k.as_mut_slice()));
Copy link
Contributor

Choose a reason for hiding this comment

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

can we use &mut k

let mut range = self.index_handles.range::<[u8], _>((Included(start), Unbounded));
let start_offset = match range.next() {
Some((_, v)) => v.offset,
None => return 0,
Copy link
Contributor

Choose a reason for hiding this comment

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

any test to cover None here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, see test cases here.

@huachaohuang huachaohuang force-pushed the huachao/size-properties branch 2 times, most recently from e5ea9a8 to d997313 Compare August 4, 2017 02:38
@huachaohuang
Copy link
Contributor Author

PTAL @zhangjinpeng1987 @BusyJay

@siddontang
Copy link
Contributor

LGTM

@huachaohuang
Copy link
Contributor Author

PTAL @zhangjinpeng1987

@zhangjinpeng87
Copy link
Member

LGTM

@huachaohuang huachaohuang force-pushed the huachao/size-properties branch from d997313 to 43ba847 Compare August 7, 2017 07:22
Copy link
Member

@zhangjinpeng87 zhangjinpeng87 left a comment

Choose a reason for hiding this comment

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

LGTM

@huachaohuang huachaohuang merged commit 5cd94f0 into master Aug 7, 2017
@huachaohuang huachaohuang deleted the huachao/size-properties branch August 7, 2017 08:11
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.

3 participants