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: add a thread-safe heap #55064

Merged
merged 1 commit into from
Jul 31, 2024

Conversation

Rustin170506
Copy link
Member

@Rustin170506 Rustin170506 commented Jul 30, 2024

What problem does this PR solve?

Issue Number: ref #55063

Problem Summary:

What changed and how does it work?

This PR added a thread-safe heap for the priority queue.
Because it doesn't involve any business logic to the priority queue, it is a pure data structure, so I think we can add it in advance.

Maybe you will ask why we don't use Fibonacci heap here. The constants for Fibonacci heaps are actually quite large, and their complexity is amortized. Therefore, it is very likely that their performance will be similar to that of regular binary heaps in this scenario.

The original implementation:
https://github.com/kubernetes/client-go/blob/master/tools/cache/heap.go

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 release-note-none Denotes a PR that doesn't merit a release note. sig/planner SIG: Planner size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed do-not-merge/needs-linked-issue labels Jul 30, 2024
@Rustin170506 Rustin170506 changed the title statistics: add a thread-safe heap WIP: statistics: add a thread-safe heap Jul 30, 2024
@ti-chi-bot ti-chi-bot bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 30, 2024
Copy link

codecov bot commented Jul 30, 2024

Codecov Report

Attention: Patch coverage is 79.77528% with 36 lines in your changes missing coverage. Please review.

Project coverage is 75.2952%. Comparing base (5d5de41) to head (385d483).
Report is 14 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #55064        +/-   ##
================================================
+ Coverage   72.7121%   75.2952%   +2.5831%     
================================================
  Files          1561       1563         +2     
  Lines        438708     445591      +6883     
================================================
+ Hits         318994     335509     +16515     
+ Misses       100007      89896     -10111     
- Partials      19707      20186       +479     
Flag Coverage Δ
integration 50.2412% <ø> (?)
unit 72.3072% <79.7752%> (+0.5994%) ⬆️

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

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

@Rustin170506 Rustin170506 changed the title WIP: statistics: add a thread-safe heap statistics: add a thread-safe heap Jul 31, 2024
@ti-chi-bot ti-chi-bot bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 31, 2024
@@ -0,0 +1,306 @@
// Copyright 2017 The Kubernetes Authors.
// Copyright 2024 PingCAP, Inc.
Copy link
Contributor

Choose a reason for hiding this comment

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

Better to add some comments to explain why we copy this implementation instead of using other third-party libs.

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

ti-chi-bot bot commented Jul 31, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: AilinKid, qw4990

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 lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Jul 31, 2024
Copy link

ti-chi-bot bot commented Jul 31, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-07-31 14:46:23.92142138 +0000 UTC m=+367100.201469448: ☑️ agreed by qw4990.
  • 2024-07-31 16:24:03.513007536 +0000 UTC m=+372959.793055605: ☑️ agreed by AilinKid.

@ti-chi-bot ti-chi-bot bot merged commit b59f5ec into pingcap:master Jul 31, 2024
23 checks passed
hawkingrei pushed 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/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants