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

statistics: support global singleflight for sync load #52796

Merged

Conversation

hawkingrei
Copy link
Member

@hawkingrei hawkingrei commented Apr 22, 2024

What problem does this PR solve?

Issue Number: close #52797

Problem Summary:

What changed and how does it work?

before

whiteboard_exported_image

All items the query needs will be put into the global task channel( the default capacity is 1000). And workers will merge the same task with the singleflight. So performance depends on the number of tasks that can be concurrently executed.
Under poor performance conditions, he will not be able to handle a sufficient number of tasks, resulting in slow processing. But there are still many same tasks in the channel. So they still need to check whether to sync load. And They will fill up this channel. Query can not insert the sync load task into it and load necessary stats.

after

whiteboard_exported_image (1)

So we need to refactor this code. We need first to let the query pass through singleflight to merge identical tasks. Then insert the task into the channel to make the worker syncload it.

So why is it that during the startup of Wetech, the queries are very unstable and there are severe timeouts with sync load? The problem lies right here.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No need to test
    • I checked and no code files have been changed.

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

Please refer to Release Notes Language Style Guide to write a quality release note.

None

@ti-chi-bot ti-chi-bot bot added do-not-merge/invalid-title do-not-merge/needs-linked-issue do-not-merge/needs-tests-checked release-note-none Denotes a PR that doesn't merit a release note. sig/planner SIG: Planner size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed do-not-merge/needs-linked-issue labels Apr 22, 2024
@hawkingrei hawkingrei changed the title Global singleflight for sync load v2 statistics: support global singleflight for sync load Apr 22, 2024
@hawkingrei hawkingrei force-pushed the global_singleflight_for_sync_load_v2 branch from 6cad5a3 to ba4654c Compare April 22, 2024 04:05
Copy link

codecov bot commented Apr 22, 2024

Codecov Report

Merging #52796 (eaaf8c9) into master (cf5c68e) will increase coverage by 1.8664%.
Report is 8 commits behind head on master.
The diff coverage is 84.0909%.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #52796        +/-   ##
================================================
+ Coverage   72.4170%   74.2834%   +1.8664%     
================================================
  Files          1477       1480         +3     
  Lines        427989     430723      +2734     
================================================
+ Hits         309937     319956     +10019     
+ Misses        98854      90824      -8030     
- Partials      19198      19943       +745     
Flag Coverage Δ
integration 48.2083% <68.1818%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
dumpling 53.9957% <ø> (ø)
parser ∅ <ø> (∅)
br 49.6616% <ø> (+8.4490%) ⬆️

@hawkingrei
Copy link
Member Author

/retest

@hawkingrei hawkingrei force-pushed the global_singleflight_for_sync_load_v2 branch 2 times, most recently from a5ca967 to 36637fc Compare April 22, 2024 07:18
@ti-chi-bot ti-chi-bot bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Apr 22, 2024
@hawkingrei hawkingrei force-pushed the global_singleflight_for_sync_load_v2 branch from fe5cf09 to 145a589 Compare April 22, 2024 09:08
@ti-chi-bot ti-chi-bot bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 23, 2024
@@ -211,17 +211,18 @@ func TestConcurrentLoadHistWithPanicAndFail(t *testing.T) {
task3, err3 := h.HandleOneTask(testKit.Session().(sessionctx.Context), task1, exitCh)
require.NoError(t, err3)
require.Nil(t, task3)

task, err3 := h.HandleOneTask(testKit.Session().(sessionctx.Context), nil, exitCh)
Copy link
Member Author

Choose a reason for hiding this comment

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

Now, we merge the same request on the top. it has nothing in the task channel. so it will block.

@hawkingrei hawkingrei force-pushed the global_singleflight_for_sync_load_v2 branch from 85816a1 to ea67022 Compare April 23, 2024 01:00
@ti-chi-bot ti-chi-bot bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 23, 2024
@hawkingrei hawkingrei force-pushed the global_singleflight_for_sync_load_v2 branch 2 times, most recently from c2ebf60 to 2d1376c Compare April 23, 2024 04:05
@hawkingrei
Copy link
Member Author

hawkingrei commented Apr 23, 2024

the old singleflight still exists, but it is to support timeout for tasks in the worker.

@hawkingrei hawkingrei force-pushed the global_singleflight_for_sync_load_v2 branch 2 times, most recently from 76077b1 to 9b609ab Compare April 23, 2024 09:37
@@ -312,11 +323,11 @@ func TestRetry(t *testing.T) {
result, err1 := h.HandleOneTask(testKit.Session().(sessionctx.Context), task1, exitCh)
require.NoError(t, err1)
require.Nil(t, result)
select {
Copy link
Member Author

@hawkingrei hawkingrei Apr 23, 2024

Choose a reason for hiding this comment

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

We cannot use the old way to check. the item in the channel will be fetched by globalSingleFlight.

@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Apr 24, 2024
Copy link

ti-chi-bot bot commented Apr 24, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-04-24 03:19:11.613324218 +0000 UTC m=+143908.353227130: ☑️ agreed by winoros.
  • 2024-04-24 08:56:13.260308272 +0000 UTC m=+164130.000211183: ☑️ agreed by hi-rustin.

Signed-off-by: Weizhen Wang <wangweizhen@pingcap.com>
@ti-chi-bot ti-chi-bot bot merged commit cd90f81 into pingcap:master Apr 24, 2024
23 checks passed
@hawkingrei
Copy link
Member Author

/cherrypick release-8.1

@ti-chi-bot
Copy link
Member

@hawkingrei: new pull request created to branch release-8.1: #52870.

In response to this:

/cherrypick release-8.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.

@hawkingrei
Copy link
Member Author

/cherrypick release-7.5

@hawkingrei hawkingrei deleted the global_singleflight_for_sync_load_v2 branch May 16, 2024 15:19
@ti-chi-bot
Copy link
Member

@hawkingrei: new pull request created to branch release-7.5: #53340.

In response to this:

/cherrypick 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.

ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request May 16, 2024
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@hawkingrei
Copy link
Member Author

/cherrypick release-7.1
/cherrypick release-6.5

ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Jun 5, 2024
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot
Copy link
Member

@hawkingrei: new pull request created to branch release-6.5: #53838.

In response to this:

/cherrypick release-7.1
/cherrypick 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.

ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Jun 5, 2024
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot
Copy link
Member

@hawkingrei: new pull request created to branch release-7.1: #53839.

In response to this:

/cherrypick release-7.1
/cherrypick 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.

hawkingrei added a commit to ti-chi-bot/tidb that referenced this pull request Aug 28, 2024
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
hawkingrei added a commit to ti-chi-bot/tidb that referenced this pull request Aug 28, 2024
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
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. sig/planner SIG: Planner 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.

global sync load to avoid too much item in the channel
4 participants