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

Reduce UniPS snapshot stat overhead #7706

Merged
merged 5 commits into from
Jun 28, 2023

Conversation

JaySon-Huang
Copy link
Contributor

@JaySon-Huang JaySon-Huang commented Jun 27, 2023

What problem does this PR solve?

Issue Number: close #7713

Problem Summary:

When there are many DeltaMergeStore in one tiflash instance, each DeltaMergeStore::getStoreStats will try to get the snapshot stats from PSV3/UniPS. But the PSV3/UniPS is a global instance that brings much CPU waste and locks contention. So it causes slow queries.

What is changed and how it works?

  • Only get snapshot stats under PageStorageRunMode::ONLY_V2, because PSV2 have different PS instances for different table
  • Reduce the lock scope of read_write_mutex in DeltaMergeStore::getStoreStats
  • Add metrics about disagg RPC requests
  • Refine some loggings

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

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

None

@ti-chi-bot ti-chi-bot bot added do-not-merge/needs-linked-issue release-note-none Denotes a PR that doesn't merit a release note. labels Jun 27, 2023
@JaySon-Huang JaySon-Huang requested a review from hongyunyan June 27, 2023 11:40
@ti-chi-bot ti-chi-bot bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jun 27, 2023
@JaySon-Huang JaySon-Huang requested a review from lidezhu June 27, 2023 11:40
Comment on lines -57 to -65
if (request->timeout_s() < 0)
{
throw TiFlashException(Errors::Coprocessor::BadRequest, "invalid timeout={}", request->timeout_s());
}
else if (request->timeout_s() > 0)
{
context->setSetting("disagg_task_snapshot_timeout", request->timeout_s());
} // use default timeout if it is 0

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Delete these rows so that we can define disagg_task_snapshot_timeout by wn config file instead of rn

@@ -50,7 +50,6 @@ bool TiDBSchemaSyncer<mock_getter, mock_mapper>::syncSchemas(Context & context)
{
if (version <= cur_version)
{
LOG_INFO(log, " version {} is the same as cur_version {}, so do nothing", version, cur_version);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this cause useless loggings under multi keyspaces

const auto & stable = segment->getStable();

total_placed_rows += delta->getPlacedDeltaRows();
std::shared_lock lock(read_write_mutex);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reduce the lock scope by {...} block statements

@JaySon-Huang
Copy link
Contributor Author

/run-all-tests

@JaySon-Huang JaySon-Huang changed the title Reduce UniPS snapshot stat overhead [WIP] Reduce UniPS snapshot stat overhead Jun 27, 2023
@ti-chi-bot ti-chi-bot bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 27, 2023
@JaySon-Huang JaySon-Huang force-pushed the reduce_snapshot_overhead branch from 89cc700 to e63d6c7 Compare June 27, 2023 15:53
@JaySon-Huang
Copy link
Contributor Author

/run-all-tests

@JaySon-Huang JaySon-Huang changed the title [WIP] Reduce UniPS snapshot stat overhead Reduce UniPS snapshot stat overhead Jun 28, 2023
Copy link
Contributor

@lidezhu lidezhu left a comment

Choose a reason for hiding this comment

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

LGTM

@ti-chi-bot ti-chi-bot bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Jun 28, 2023
@ti-chi-bot ti-chi-bot bot added the lgtm label Jun 28, 2023
@ti-chi-bot ti-chi-bot bot removed the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Jun 28, 2023
@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Jun 28, 2023

[LGTM Timeline notifier]

Timeline:

  • 2023-06-28 03:47:37.079186774 +0000 UTC m=+765822.480437222: ☑️ agreed by lidezhu.
  • 2023-06-28 05:16:30.06600106 +0000 UTC m=+771155.467251510: ☑️ agreed by hongyunyan.

@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Jun 28, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: hongyunyan, lidezhu, Lloyd-Pottiger

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

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [Lloyd-Pottiger,hongyunyan,lidezhu]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot merged commit 787ab97 into pingcap:master Jun 28, 2023
@JaySon-Huang JaySon-Huang deleted the reduce_snapshot_overhead branch June 28, 2023 06:24
@JaySon-Huang
Copy link
Contributor Author

/cherry-pick release-7.1

@JaySon-Huang
Copy link
Contributor Author

/cherry-pick release-6.5

@ti-chi-bot
Copy link
Member

@JaySon-Huang: new pull request created to branch release-7.1: #7715.

In response to this:

/cherry-pick release-7.1

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.

ti-chi-bot pushed a commit to ti-chi-bot/tiflash that referenced this pull request Jun 28, 2023
@ti-chi-bot
Copy link
Member

@JaySon-Huang: new pull request created to branch release-6.5: #7716.

In response to this:

/cherry-pick release-6.5

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Slow get segment snapshot causes read timeout when there are multiple tables
5 participants