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

In-memory engine: collector iteration related metrics #16735

Merged
merged 12 commits into from Apr 11, 2024

Conversation

SpadeA-Tang
Copy link
Member

@SpadeA-Tang SpadeA-Tang commented Apr 2, 2024

What is changed and how it works?

Issue Number: Ref #16141

What's Changed:

collector iteration related metrics

Collector iteration related metrics just like what does in rocksdb.

Related changes

  • PR to update pingcap/docs/pingcap/docs-cn:
  • Need to cherry-pick to the release branch

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Release note

None

Signed-off-by: SpadeA-Tang <u6748471@anu.edu.au>
Signed-off-by: SpadeA-Tang <u6748471@anu.edu.au>
Copy link
Contributor

ti-chi-bot bot commented Apr 2, 2024

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • LykxSassinator
  • tonyxuqqi

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

The full list of commands accepted by this bot can be found here.

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

Signed-off-by: SpadeA-Tang <u6748471@anu.edu.au>
@SpadeA-Tang SpadeA-Tang changed the title In-memory engine: collector tombstone count when iterating In-memory engine: collector iteration related metrics Apr 2, 2024
Signed-off-by: SpadeA-Tang <u6748471@anu.edu.au>
@ti-chi-bot ti-chi-bot bot removed the needs-rebase label Apr 7, 2024
SpadeA-Tang and others added 2 commits April 8, 2024 17:19
Signed-off-by: SpadeA-Tang <u6748471@anu.edu.au>
EK: KvEngine,
EC: RangeCacheEngine,
{
collector: Either<
Copy link
Contributor

@tonyxuqqi tonyxuqqi Apr 8, 2024

Choose a reason for hiding this comment

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

Why do we need to have HybridEngineIterMetricsCollector again?
It seems to me as long as the caller of HybridEngineIterMetricsCollector has the MetricsExt instance, it can call the relevant APIs directly.

Copy link
Member Author

Choose a reason for hiding this comment

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

Disk engine collector and range cache engine collector are different and have their own implementation (RocksIterMetricsCollector and RangeCacheIterMetricsCollector).

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, understood. But for one HybridEngineIterMetricsCollector instance, it's either the RocksDB or RangeCache, which have the same interface. So why don't we use this same interface directly instead of a wrapper.

@@ -117,8 +117,19 @@ pub trait RefIterable {
fn iter(&self, opts: IterOptions) -> Result<Self::Iterator<'_>>;
}

pub trait IterMetricsCollector {
fn internal_delete_skipped_count(&self) -> usize;
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we include total scanned count as well? Otherwise we don't know the percentage of delete skipped or internal skipped.

Copy link
Member Author

Choose a reason for hiding this comment

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

I will leave a todo and we should add these metrics when we need. This PR is to make the in-memory engine returns iteration related metrics like what did in RocksEngine which only include delete skipped count.

Copy link
Contributor

@tonyxuqqi tonyxuqqi left a comment

Choose a reason for hiding this comment

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

Some comments, overall LGTM.

@SpadeA-Tang
Copy link
Member Author

/run-test retry=7

Signed-off-by: SpadeA-Tang <u6748471@anu.edu.au>
{
type Collector = HybridEngineIterMetricsCollector<EK, EC>;

fn metrics_collector(&self) -> Self::Collector {
Copy link
Contributor

@tonyxuqqi tonyxuqqi Apr 10, 2024

Choose a reason for hiding this comment

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

IMO, here we don't need to wrap a collector object HybridEngineIterMetricsCollector at all.
Instead we can do this:
fn metrics_collector(&self) -> impl IterMetricsCollector

The current code is kind of manual implementation of Polymorphism.
What do you think @afeinberg

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think we can use -> impl IterMetricsCollector here. impl trait is static dispatch, which determines the return type at compile time. However, what we need is dynamic dispatch here and determines the return type according to the type of self.iter. We can use Box<dyn IterMetricsCollector> here but the performance should be poorer.

Copy link
Contributor

Choose a reason for hiding this comment

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

No. impl IterMetricsCollector is dynamic dispatch
@SpadeA-Tang

@ti-chi-bot ti-chi-bot bot added the status/LGT1 Status: PR - There is already 1 approval label Apr 11, 2024
@ti-chi-bot ti-chi-bot bot added status/LGT2 Status: PR - There are already 2 approvals and removed status/LGT1 Status: PR - There is already 1 approval labels Apr 11, 2024
@SpadeA-Tang
Copy link
Member Author

/merge

Copy link
Contributor

ti-chi-bot bot commented Apr 11, 2024

@SpadeA-Tang: It seems you want to merge this PR, I will help you trigger all the tests:

/run-all-tests

You only need to trigger /merge once, and if the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes.

If you have any questions about the PR merge process, please refer to pr process.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository.

Copy link
Contributor

ti-chi-bot bot commented Apr 11, 2024

This pull request has been accepted and is ready to merge.

Commit hash: 789faf6

@ti-chi-bot ti-chi-bot bot added the status/can-merge Status: Can merge to base branch label Apr 11, 2024
@ti-chi-bot ti-chi-bot bot merged commit f1c16b8 into tikv:master Apr 11, 2024
6 of 7 checks passed
@ti-chi-bot ti-chi-bot bot added this to the Pool milestone Apr 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note-none size/XL status/can-merge Status: Can merge to base branch status/LGT2 Status: PR - There are already 2 approvals
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants