tidb icon indicating copy to clipboard operation
tidb copied to clipboard

stats: optimize build topn and histogram (#63285)

Open ti-chi-bot opened this issue 1 month ago • 12 comments

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?

  1. Use heap to maintain the topN to reduce memory shuffle
  2. Track topN index range while iterating samples
  3. 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

ti-chi-bot avatar Nov 19 '25 16:11 ti-chi-bot

@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 avatar Nov 19 '25 16:11 ti-chi-bot

@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.

ti-chi-bot[bot] avatar Nov 19 '25 16:11 ti-chi-bot[bot]

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.

codecov[bot] avatar Nov 19 '25 22:11 codecov[bot]

/unhold

0xPoe avatar Dec 08 '25 12:12 0xPoe

[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

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[bot] avatar Dec 08 '25 12:12 ti-chi-bot[bot]

[LGTM Timeline notifier]

Timeline:

  • 2025-12-08 08:10:55.602148681 +0000 UTC m=+855800.415926243: :ballot_box_with_check: agreed by fixdb.
  • 2025-12-08 12:50:21.008868674 +0000 UTC m=+872565.822646236: :ballot_box_with_check: agreed by 0xPoe.

ti-chi-bot[bot] avatar Dec 08 '25 12:12 ti-chi-bot[bot]

/retest

0xPoe avatar Dec 08 '25 12:12 0xPoe

/retest

fixdb avatar Dec 09 '25 06:12 fixdb

/test all

0xPoe avatar Dec 10 '25 09:12 0xPoe

@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.

tiprow[bot] avatar Dec 10 '25 09:12 tiprow[bot]

/retest

0xPoe avatar Dec 10 '25 10:12 0xPoe

/retest

EmmaDuDu avatar Dec 12 '25 13:12 EmmaDuDu

/retest

EmmaDuDu avatar Dec 12 '25 13:12 EmmaDuDu

/retest

fixdb avatar Dec 12 '25 22:12 fixdb

/retest

EmmaDuDu avatar Dec 13 '25 01:12 EmmaDuDu

/retest

EmmaDuDu avatar Dec 13 '25 13:12 EmmaDuDu

/unhold /retest

qw4990 avatar Dec 15 '25 01:12 qw4990

/retest

EmmaDuDu avatar Dec 15 '25 07:12 EmmaDuDu

/retest

fixdb avatar Dec 15 '25 07:12 fixdb

@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.

ti-chi-bot[bot] avatar Dec 15 '25 08:12 ti-chi-bot[bot]

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

0xPoe avatar Dec 15 '25 08:12 0xPoe

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:

  1. It must be approved by the approvers firstly.
  2. 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.

ti-chi-bot[bot] avatar Dec 15 '25 09:12 ti-chi-bot[bot]