stats: optimize build topn and histogram (#63285)
This is an automated cherry-pick of #63285
What problem does this PR solve?
Issue Number: close #63286
Problem Summary:
What changed and how does it work?
- Use heap to maintain the topN to reduce memory shuffle
- Track topN index range while iterating samples
- When building histogram, skip entries that falls into the topN range so don't need to remove topN values from samples.
Check List
Tests
- [x] 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
@Tristan1900 This PR has conflicts, I have hold it.
Please resolve them or ask others to resolve them, then comment /unhold to remove the hold label.
@ti-chi-bot: ## If you want to know how to resolve it, please read the guide in TiDB Dev Guide.
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.
Codecov Report
:x: Patch coverage is 87.26115% with 20 lines in your changes missing coverage. Please review.
:warning: Please upload report for BASE (release-8.5@69b1dbe). Learn more about missing BASE report.
Additional details and impacted files
@@ Coverage Diff @@
## release-8.5 #64577 +/- ##
================================================
Coverage ? 48.3771%
================================================
Files ? 1598
Lines ? 467713
Branches ? 0
================================================
Hits ? 226266
Misses ? 221281
Partials ? 20166
| Flag | Coverage Δ | |
|---|---|---|
| integration | 48.3771% <87.2611%> (?) |
Flags with carried forward coverage won't be shown. Click here to find out more.
| Components | Coverage Δ | |
|---|---|---|
| dumpling | ∅ <0.0000%> (?) |
|
| parser | ∅ <0.0000%> (?) |
|
| br | 28.2073% <0.0000%> (?) |
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
- :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
/unhold
[APPROVALNOTIFIER] This PR is APPROVED
This pull-request has been approved by: 0xPoe, fixdb
The full list of commands accepted by this bot can be found here.
The pull request process is described here
- ~~OWNERS~~ [0xPoe,fixdb]
- ~~pkg/planner/OWNERS~~ [0xPoe,fixdb]
- ~~pkg/statistics/OWNERS~~ [0xPoe,fixdb]
Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment
[LGTM Timeline notifier]
Timeline:
/retest
/retest
/test all
@0xPoe: No presubmit jobs available for pingcap/[email protected]
In response to this:
/test all
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 kubernetes-sigs/prow repository.
/retest
/retest
/retest
/retest
/retest
/retest
/unhold /retest
/retest
/retest
@ti-chi-bot: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:
| Test name | Commit | Details | Required | Rerun command |
|---|---|---|---|---|
| idc-jenkins-ci-tidb/mysql-test | c07eb859fcecd54feacc522e88a14acdd654b37f | link | true | /test mysql-test |
| idc-jenkins-ci-tidb/check_dev_2 | c07eb859fcecd54feacc522e88a14acdd654b37f | link | true | /test check-dev2 |
| idc-jenkins-ci-tidb/unit-test | c07eb859fcecd54feacc522e88a14acdd654b37f | link | true | /test unit-test |
Full PR test history. Your PR dashboard.
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 kubernetes-sigs/prow repository. I understand the commands that are listed here.
/close
Tests are broken. This PR has some prior PRs, so let's close it for now. It may introduce extra risks to release 8.5.
This cherry pick PR is for a release branch and has not yet been approved by triage owners.
Adding the do-not-merge/cherry-pick-not-approved label.
To merge this cherry pick:
- It must be approved by the approvers firstly.
- AFTER it has been approved by approvers, please wait for the cherry-pick merging approval from triage owners.
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 kubernetes-sigs/prow repository.