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

use per-level perfcontext for DB::Get calls #4617

Closed

Conversation

miasantreble
Copy link
Contributor

this PR adds two more per-level perf context counters to track

  • number of keys returned in Get call, break down by levels
  • total processing time at each level during Get call

@@ -1218,6 +1218,7 @@ void Version::Get(const ReadOptions& read_options, const LookupKey& k,
sample_file_read_inc(f->file_metadata);
}

StopWatchNano timer(env_, true);
Copy link
Contributor

Choose a reason for hiding this comment

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

We should only do timing when perf context level allows timing and by level counter is enabled.

@@ -52,11 +52,17 @@ Status DBImplReadOnly::Get(const ReadOptions& read_options,
&max_covering_tombstone_seq, read_options)) {
pinnable_val->PinSelf();
RecordTick(stats_, MEMTABLE_HIT);
PERF_COUNTER_BY_LEVEL_ADD(user_key_return_count, 1, 0);
Copy link
Contributor

Choose a reason for hiding this comment

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

Memtable is not level0. Now we can't distinguish the two.

super_version->current->Get(read_options, lkey, pinnable_val, &s,
&merge_context, &max_covering_tombstone_seq);
&merge_context, &level_found,
Copy link
Contributor

Choose a reason for hiding this comment

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

Version::Get() to return level found makes the function less clean. Do we really need to return it, or can be update the counter inside Version::Get()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, we can update the counter inside Version::Get(), doesn't have to happen in DBImpl::GetImpl

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@miasantreble has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@@ -1218,6 +1218,9 @@ void Version::Get(const ReadOptions& read_options, const LookupKey& k,
sample_file_read_inc(f->file_metadata);
}

bool timer_enabled = get_perf_context()->per_level_perf_context_enabled &&
GetPerfLevel() >= PerfLevel::kEnableTimeExceptForMutex;
Copy link
Contributor

Choose a reason for hiding this comment

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

Reverting the two conditions feels slightly more performant in normal path to me.

@@ -1250,6 +1257,7 @@ void Version::Get(const ReadOptions& read_options, const LookupKey& k,
} else if (fp.GetHitFileLevel() >= 2) {
RecordTick(db_statistics_, GET_HIT_L2_AND_UP);
}
PERF_COUNTER_BY_LEVEL_ADD(user_key_return_count, 1, fp.GetHitFileLevel());
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we need to find it in kMerge too.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we don't deal with all kMerge case now. It's OK for now if you add a TODO here, and comment in the perf counter what the expectation is.

@@ -26,6 +28,10 @@ struct PerfContextByLevel {
// exist.
uint64_t bloom_filter_full_true_positive = 0;

uint64_t user_key_return_count; // total number of user key returned
Copy link
Contributor

Choose a reason for hiding this comment

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

Need to have better comment. For example, explaining how it counts in deletion and merge cases.

@@ -26,6 +28,10 @@ struct PerfContextByLevel {
// exist.
uint64_t bloom_filter_full_true_positive = 0;

uint64_t user_key_return_count; // total number of user key returned

uint64_t get_processing_time; // total nanos spent on Get query
Copy link
Contributor

Choose a reason for hiding this comment

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

We used to do ..._time, but later realized that it was not good. Now the convention is ..._nanos. This can be something like get_from_table_nanos.

@facebook-github-bot
Copy link
Contributor

@miasantreble has updated the pull request. Re-import the pull request

@miasantreble
Copy link
Contributor Author

all comments have been addressed, thanks @siying

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@miasantreble has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@@ -26,6 +28,12 @@ struct PerfContextByLevel {
// exist.
uint64_t bloom_filter_full_true_positive = 0;

// total number of user key returned (only include keys that are found, does
// not include keys that are deleted or merged
Copy link
Contributor

Choose a reason for hiding this comment

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

This can be more accurate. If the key is found as "merge-merge-put", we still report one. But if there is no final put, we don't report. It's a good idea to clarify.

// not include keys that are deleted or merged
uint64_t user_key_return_count;

uint64_t get_from_table_nanos; // total nanos spent on Get query
Copy link
Contributor

Choose a reason for hiding this comment

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

Not "get" query, but getting from SST files. Memtable and other operations are not included here.

@siying
Copy link
Contributor

siying commented Nov 13, 2018

Also HISTORY.md.

@facebook-github-bot
Copy link
Contributor

@miasantreble has updated the pull request. Re-import the pull request

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@miasantreble is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@miasantreble miasantreble deleted the more-per-level-perfcontext branch November 24, 2018 18:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants