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: print the process of init stats #53560

Merged
merged 4 commits into from
May 30, 2024

Conversation

hawkingrei
Copy link
Member

@hawkingrei hawkingrei commented May 27, 2024

What problem does this PR solve?

Issue Number: close #53564

Problem Summary:

What changed and how does it work?

it sometimes takes too much time for tidb to init stats. we should print the process info to tell the users.

Check List

Tests

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

if we have several tables, it will print

[2024/05/27 18:21:39.093 +08:00] [INFO] [bootstrap.go:734] ["complete to load the histogram"] [category=stats]
[2024/05/27 18:21:39.094 +08:00] [INFO] [bootstrap.go:743] ["complete to load the topn"] [category=stats]
[2024/05/27 18:21:39.097 +08:00] [INFO] [bootstrap.go:755] ["complete to load the bucket"] [category=stats]
[2024/05/27 18:21:39.098 +08:00] [INFO] [domain.go:2318] ["init stats info time"] [lite=false] ["take time"=13.208834ms]

But if TiDB has enough tables, it will print.

...
[2024/05/27 19:54:10.516 +08:00] [INFO] [load_stats_page.go:83] ["load bucket [1080/2391]"] [category=stats]
[2024/05/27 19:55:10.516 +08:00] [INFO] [load_stats_page.go:83] ["load bucket [1781/2391]"] [category=stats]
...
  • 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.

init stats 时显示进度
statistics: print the process of init stats

@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/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels May 27, 2024
Copy link

codecov bot commented May 27, 2024

Codecov Report

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

Project coverage is 74.7782%. Comparing base (df64c34) to head (7d7125c).
Report is 33 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #53560        +/-   ##
================================================
+ Coverage   72.4222%   74.7782%   +2.3560%     
================================================
  Files          1505       1507         +2     
  Lines        430553     439922      +9369     
================================================
+ Hits         311816     328966     +17150     
+ Misses        99427      90766      -8661     
- Partials      19310      20190       +880     
Flag Coverage Δ
integration 49.4542% <0.0000%> (?)
unit 71.4592% <81.5789%> (+0.0577%) ⬆️

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

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

@ti-chi-bot ti-chi-bot bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed do-not-merge/needs-tests-checked do-not-merge/needs-linked-issue size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels May 27, 2024
@ti-chi-bot ti-chi-bot bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-none Denotes a PR that doesn't merit a release note. labels May 27, 2024
@hawkingrei
Copy link
Member Author

/retest

1 similar comment
@hawkingrei
Copy link
Member Author

/retest

@hawkingrei
Copy link
Member Author

/retest

Copy link
Contributor

@AilinKid AilinKid left a comment

Choose a reason for hiding this comment

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

Rest LGTM

@@ -57,6 +101,10 @@ func (ls *RangeWorker) loadStats() {
if err := ls.dealFunc(task); err != nil {
logutil.BgLogger().Error("load stats failed", zap.Error(err))
}
if ls.logger != nil {
completeTaskCnt := ls.completeTaskCnt.Add(1)
ls.logger.Info(fmt.Sprintf("load %s [%d/%d]", ls.taskName, completeTaskCnt, ls.taskCnt))
Copy link
Contributor

@AilinKid AilinKid May 28, 2024

Choose a reason for hiding this comment

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

seems it's sampling output
1% 50% 90% 100%
if 100% is missed, will the log msg look wired as unfinished/hang?

Copy link
Member Author

Choose a reason for hiding this comment

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

If it is complete, It must print complete.

Copy link
Member Author

Choose a reason for hiding this comment

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

load xxxx [completed task count / total task count]

@ti-chi-bot ti-chi-bot bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels May 28, 2024
@hawkingrei
Copy link
Member Author

@winoros @hi-rustin PTAL

*
Signed-off-by: Weizhen Wang <[email protected]>
err = h.initStatsHistogramsLite(is, cache)
if err != nil {
return errors.Trace(err)
}
statslogutil.StatsLogger().Info("complete to load the histogram")
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
statslogutil.StatsLogger().Info("complete to load the histogram")
statslogutil.StatsLogger().Info("complete to load the lite histogram")

Copy link
Member Author

Choose a reason for hiding this comment

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

updated.

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

ti-chi-bot bot commented May 29, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-05-28 05:45:52.28889873 +0000 UTC m=+2755306.046034295: ☑️ agreed by AilinKid.
  • 2024-05-29 10:19:14.104927128 +0000 UTC m=+2858107.862062699: ☑️ agreed by winoros.

@hawkingrei
Copy link
Member Author

/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 May 29, 2024
@hawkingrei hawkingrei requested a review from elsa0520 May 30, 2024 02:34
@hawkingrei
Copy link
Member Author

@elsa0520 Please confirm one last time.

Copy link
Contributor

@elsa0520 elsa0520 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link

ti-chi-bot bot commented May 30, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: AilinKid, elsa0520, winoros

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

@hawkingrei
Copy link
Member Author

/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 May 30, 2024
@hawkingrei
Copy link
Member Author

/retest

@ti-chi-bot ti-chi-bot bot merged commit 5e5326b into pingcap:master May 30, 2024
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/planner SIG: Planner size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Showing the progress of loading initial stats
4 participants