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

Storages: refine SegmentReadTaskScheduler #8557

Merged
merged 7 commits into from
Jan 3, 2024

Conversation

JinheLin
Copy link
Contributor

@JinheLin JinheLin commented Dec 20, 2023

What problem does this PR solve?

Issue Number: ref #6834

Problem Summary:

What is changed and how it works?

  • The main updates of this PR is removing the code of CircularScanList and refining SegmentReadTaskScheduler. Removing CircularScanList is because it's not very necessary.

  • The design of CircularScanList is to make each iteration of read_pools start from the previous end position. Meanwhile, for the convenience of accessing by pool_id, also added an unordered_map to index all pools.

  • CircularScanList also will release pools that are never used, causing inconvenience in some monitoring statistics.

  • This PR deletes the code of CircularScanList, and just uses an unordered_map to store read_pools.

  • When scheduling, try scheduling each pool in the read_pools before releasing lock.

  • The biggest difference is that the new code will try to schedule all pools in read_pools before the scheduler releasing its lock.

  • Also add some unit-tests of SegmentReadTaskScheduler.

  • Add CPU usage of threads:
    image
    image

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
    • Run chbenchmark workload with concurrent queries.
  • 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

Copy link
Contributor

ti-chi-bot bot commented Dec 20, 2023

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@ti-chi-bot ti-chi-bot bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note-none Denotes a PR that doesn't merit a release note. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Dec 20, 2023
@JinheLin
Copy link
Contributor Author

/run-all-tests

1 similar comment
@JinheLin
Copy link
Contributor Author

/run-all-tests

@JinheLin
Copy link
Contributor Author

/run-unit-tests

@JinheLin JinheLin marked this pull request as ready for review December 21, 2023 07:36
@JinheLin JinheLin changed the title [WIP]Storages: refine SegmentReadTaskScheduler Storages: refine SegmentReadTaskScheduler Dec 21, 2023
@ti-chi-bot ti-chi-bot bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Dec 21, 2023
@JinheLin
Copy link
Contributor Author

/run-all-tests

@JinheLin
Copy link
Contributor Author

/run-integration-test

1 similar comment
@JinheLin
Copy link
Contributor Author

/run-integration-test

Copy link
Contributor

@Lloyd-Pottiger Lloyd-Pottiger 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 Dec 28, 2023
@@ -127,7 +127,11 @@ class MergedTask
}
}

#ifndef DBMS_PUBLIC_GTEST
Copy link
Member

Choose a reason for hiding this comment

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

Why? I found these 3 methods not accessed in gtest_segment_read_tasks.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Use the member variables in gtest_segment_read_tasks. For example,

ASSERT_EQ(merged_task->units.size(), 1);

Stopwatch sw_do_add;
read_pools.add(pool);
read_pools.emplace(pool->pool_id, pool);
Copy link
Member

Choose a reason for hiding this comment

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

The SegmentReadTaskScheduler::add is public, it could be called by someone else. Wo we should assert pool to be not nullptr.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added.

Copy link
Contributor

@JaySon-Huang JaySon-Huang 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 the lgtm label Jan 2, 2024
Copy link
Contributor

ti-chi-bot bot commented Jan 2, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: JaySon-Huang, 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 [JaySon-Huang,Lloyd-Pottiger]

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 removed the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Jan 2, 2024
Copy link
Contributor

ti-chi-bot bot commented Jan 2, 2024

[LGTM Timeline notifier]

Timeline:

  • 2023-12-28 08:51:40.903548162 +0000 UTC m=+1728591.940775089: ☑️ agreed by Lloyd-Pottiger.
  • 2024-01-02 13:47:53.886218722 +0000 UTC m=+2178364.923445649: ☑️ agreed by JaySon-Huang.

@JaySon-Huang
Copy link
Contributor

/hold

@ti-chi-bot ti-chi-bot bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 2, 2024
@JaySon-Huang
Copy link
Contributor

/run-all-tests

@JaySon-Huang
Copy link
Contributor

/unhold

@ti-chi-bot ti-chi-bot bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 3, 2024
@ti-chi-bot ti-chi-bot bot merged commit 64c1ae5 into pingcap:master Jan 3, 2024
6 checks passed
JinheLin added a commit to JinheLin/tiflash-1 that referenced this pull request May 7, 2024
@JinheLin
Copy link
Contributor Author

JinheLin commented May 7, 2024

/cherry-pick to release-7.5

@ti-chi-bot
Copy link
Member

@JinheLin: cannot checkout to release-7.5: error checking out to release-7.5: exit status 1. output: error: pathspec 'to release-7.5' did not match any file(s) known to git

In response to this:

/cherry-pick to release-7.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/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants