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

*: remove limiting process id for auto analyze #54902

Merged

Conversation

hawkingrei
Copy link
Member

@hawkingrei hawkingrei commented Jul 25, 2024

What problem does this PR solve?

Issue Number: ref #53460

Problem Summary:

What changed and how does it work?

  • Add GlobalAutoAnalyzeProcessList to collect all auto analyze process IDs.
  • Remove the restriction of having only one process ID for auto analyze and release the used process ID.

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/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. 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 Jul 25, 2024
Copy link

codecov bot commented Jul 25, 2024

Codecov Report

Attention: Patch coverage is 89.39394% with 7 lines in your changes missing coverage. Please review.

Project coverage is 73.3113%. Comparing base (7e73ddc) to head (2358073).
Report is 27 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #54902        +/-   ##
================================================
+ Coverage   72.7907%   73.3113%   +0.5206%     
================================================
  Files          1558       1568        +10     
  Lines        438406     446381      +7975     
================================================
+ Hits         319119     327248      +8129     
+ Misses        99643      98700       -943     
- Partials      19644      20433       +789     
Flag Coverage Δ
integration 20.6010% <13.8461%> (?)

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

Components Coverage Δ
dumpling 52.9567% <ø> (ø)
parser ∅ <ø> (∅)
br 52.1135% <ø> (+6.2092%) ⬆️

@hawkingrei
Copy link
Member Author

/retest

@@ -854,7 +855,9 @@ func readDataAndSendTask(ctx sessionctx.Context, handler *tableResultHandler, me
for {
failpoint.Inject("mockKillRunningV2AnalyzeJob", func() {
Copy link
Member Author

Choose a reason for hiding this comment

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

Here are the tests.

@hawkingrei hawkingrei changed the title *: remove limiting process id for analyze *: remove limiting process id for auto analyze Jul 25, 2024
Signed-off-by: Weizhen Wang <[email protected]>
Signed-off-by: Weizhen Wang <[email protected]>
Signed-off-by: Weizhen Wang <[email protected]>
Signed-off-by: Weizhen Wang <[email protected]>
Signed-off-by: Weizhen Wang <[email protected]>
Signed-off-by: Weizhen Wang <[email protected]>
Signed-off-by: Weizhen Wang <[email protected]>
@hawkingrei hawkingrei force-pushed the remove_limit_for_autoanalyze_in_procs_id branch from 8855661 to 2a68900 Compare July 26, 2024 03:19
Signed-off-by: Weizhen Wang <[email protected]>
Signed-off-by: Weizhen Wang <[email protected]>
@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Jul 26, 2024
@hawkingrei hawkingrei requested a review from winoros July 26, 2024 06:44
Copy link
Contributor

@pingyu pingyu left a comment

Choose a reason for hiding this comment

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

reservedConnAnalyze can be removed. Rest LGTM~

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

ti-chi-bot bot commented Jul 27, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-07-26 04:32:28.888426399 +0000 UTC m=+1192370.879367870: ☑️ agreed by xhebox.
  • 2024-07-27 02:21:18.180276505 +0000 UTC m=+58762.307336681: ☑️ agreed by pingyu.

Signed-off-by: Weizhen Wang <[email protected]>
@hawkingrei
Copy link
Member Author

reservedConnAnalyze can be removed. Rest LGTM~

I have removed it. Thanks.

var GlobalAutoAnalyzeProcessList = newGlobalAutoAnalyzeProcessList()

type globalAutoAnalyzeProcessList struct {
processes map[uint64]struct{}
Copy link
Member Author

@hawkingrei hawkingrei Jul 29, 2024

Choose a reason for hiding this comment

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

We use global thread-safe map to record the running auto analyze task.

Copy link
Contributor

Choose a reason for hiding this comment

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

why not use a sync.map

Copy link
Member Author

Choose a reason for hiding this comment

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

The Map type is optimized for two common use cases: (1) when the entry for a given key is only ever written once but read many times, as in caches that only grow, or (2) when multiple goroutines read, write, and overwrite entries for disjoint sets of keys. In these two cases, use of a Map may significantly reduce lock contention compared to a Go map paired with a separate Mutex or RWMutex.

so two common use cases are not the same as us.

@hawkingrei
Copy link
Member Author

@winoros PTAL

Signed-off-by: Weizhen Wang <[email protected]>
Copy link

ti-chi-bot bot commented Jul 29, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: lance6716, pingyu, qw4990, xhebox

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:

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 added the approved label Jul 29, 2024
Signed-off-by: Weizhen Wang <[email protected]>
@ti-chi-bot ti-chi-bot bot merged commit 273ca66 into pingcap:master Jul 29, 2024
23 checks passed
@hawkingrei hawkingrei deleted the remove_limit_for_autoanalyze_in_procs_id branch July 29, 2024 16:06
hawkingrei added a commit to hawkingrei/tidb that referenced this pull request Aug 1, 2024
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.

7 participants