-
Notifications
You must be signed in to change notification settings - Fork 759
pd: report hot read cpu in heartbeat #10178
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
Merged
Merged
Changes from 24 commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
77f90dd
use hot read cpu
lhy1024 5790ab6
fix version
lhy1024 531ed27
adjust sample windows
lhy1024 5b42858
fix statistics
lhy1024 a61cfc8
add comments and tests
lhy1024 7e04125
Merge branch 'master' of github.com:tikv/pd into hot-read-cpu
lhy1024 35223a2
fix lint
lhy1024 d9310e1
fix tests
lhy1024 550ffd8
update kvproto
lhy1024 cbcda2a
address comments
lhy1024 3ab78da
address comments
lhy1024 7cc9995
address comments
lhy1024 6d78ea2
address comments
lhy1024 b1c86f8
remove cpu specail windows
lhy1024 1f3e1db
fix lint
lhy1024 4b2e3c8
Merge branch 'master' of github.com:tikv/pd into hot-read-cpu
lhy1024 a99ac37
Merge branch 'master' of github.com:tikv/pd into hot-read-cpu
lhy1024 5e3e458
add panel
lhy1024 1d18285
remove grpc
lhy1024 3b56493
Merge remote-tracking branch 'pingcap/master' into hot-read-cpu
lhy1024 0d55388
adjust version
lhy1024 f9ed627
add some test and comments
lhy1024 9fb6ae3
fallback in bucket
lhy1024 c384dbf
reserve write cpu
lhy1024 7376b5e
fix client
lhy1024 c843e19
*: bump kvproto to 678ff92b1edd
lhy1024 b477bcf
statistics: align read cpu with query hot signals
lhy1024 27f2cf7
tests: align hot scheduler cpu rate expectations
lhy1024 71e1e30
hot-read-cpu: backport compatibility and review fixes
lhy1024 76d0eaa
add pending weight config
lhy1024 bd2eed8
fix lint
lhy1024 0289764
tests: pin split bucket priorities and cover cpu fallback
lhy1024 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -65,15 +65,18 @@ func errRegionIsStale(region *metapb.Region, origin *metapb.Region) error { | |
| // the properties are Read-Only once created except buckets. | ||
| // the `buckets` could be modified by the request `report buckets` with greater version. | ||
| type RegionInfo struct { | ||
| meta *metapb.Region | ||
| learners []*metapb.Peer | ||
| witnesses []*metapb.Peer | ||
| voters []*metapb.Peer | ||
| leader *metapb.Peer | ||
| downPeers []*pdpb.PeerStats | ||
| pendingPeers []*metapb.Peer | ||
| term uint64 | ||
| meta *metapb.Region | ||
| learners []*metapb.Peer | ||
| witnesses []*metapb.Peer | ||
| voters []*metapb.Peer | ||
| leader *metapb.Peer | ||
| downPeers []*pdpb.PeerStats | ||
| pendingPeers []*metapb.Peer | ||
| term uint64 | ||
| // cpuUsage is deprecated and will be removed in the future. | ||
| // We should use `cpuStats` instead. | ||
| cpuUsage uint64 | ||
| cpuStats *pdpb.CPUStats | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need to mark cpuUsage as deprecated?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
| writtenBytes uint64 | ||
| writtenKeys uint64 | ||
| readBytes uint64 | ||
|
|
@@ -257,8 +260,9 @@ func RegionFromHeartbeat(heartbeat RegionHeartbeatRequest, flowRoundDivisor uint | |
| region.approximateKvSize = int64(h.GetApproximateKvSize() / units.MiB) | ||
| region.approximateColumnarKvSize = int64(h.GetApproximateColumnarKvSize() / units.MiB) | ||
| region.replicationStatus = h.GetReplicationStatus() | ||
| if cpuStats := h.GetCpuStats(); cpuStats != nil { | ||
| region.cpuUsage = cpuStats.GetUnifiedRead() | ||
| region.cpuStats = h.GetCpuStats() | ||
| if region.cpuStats != nil { | ||
| region.cpuUsage = region.cpuStats.GetUnifiedRead() | ||
| } else { | ||
| region.cpuUsage = h.CpuUsage | ||
| } | ||
|
|
@@ -329,6 +333,7 @@ func (r *RegionInfo) Clone(opts ...RegionCreateOption) *RegionInfo { | |
| downPeers: downPeers, | ||
| pendingPeers: pendingPeers, | ||
| cpuUsage: r.cpuUsage, | ||
| cpuStats: typeutil.DeepClone(r.cpuStats, CPUStatsFactory), | ||
| writtenBytes: r.writtenBytes, | ||
| writtenKeys: r.writtenKeys, | ||
| readBytes: r.readBytes, | ||
|
|
@@ -2019,6 +2024,8 @@ func (r *RegionInfo) GetLoads() []float64 { | |
| float64(r.GetBytesWritten()), | ||
| float64(r.GetKeysWritten()), | ||
| float64(r.GetWriteQueryNum()), | ||
| float64(r.GetCPUUsage()), | ||
| 0, // RegionWriteCPU: reserved, not yet reported by TiKV | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -2031,6 +2038,8 @@ func (r *RegionInfo) GetWriteLoads() []float64 { | |
| float64(r.GetBytesWritten()), | ||
| float64(r.GetKeysWritten()), | ||
| float64(r.GetWriteQueryNum()), | ||
| 0, | ||
| 0, // RegionWriteCPU: reserved, not yet reported by TiKV | ||
| } | ||
| } | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Scope the hidden expected-load queries to the selected stores.
These two targets ignore
$store, so the panel still fetchesexp-cpu-rate-read-*for every store even when target A is narrowed to a subset. That makes the hidden debug overlay inconsistent with the visible series and adds unnecessary query load.Suggested fix
📝 Committable suggestion
🤖 Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right that these hidden pd_scheduler_hot_peers_summary queries are not scoped by $store. However, this is not specific to the new CPU panel. The existing read bytes / read keys / read query panels already use the same pattern for their hidden expected-load queries.
If we only changed the CPU panel here, it would make this panel inconsistent with the existing dashboard behavior. If we want to optimize this, I think it is better handled as a separate dashboard cleanup that updates all similar panels together.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR description image shows a Grafana time-series panel titled “Store read cpu.” The legend lists multiple stores (e.g., 192.168.8.88:20162-store-1), Y-axis ~0–15, and there’s a spike near 16:40 where store-1 peaks around 13 and store-2 around 9; other stores are near zero. A dropdown on the right shows sorting by max/current.
@lhy1024Thanks for the context—agreed on keeping this PR consistent.I double-checked the dashboard JSON and confirmed the pattern you mentioned:
Let’s keep panel 608 as-is here. If you’d like, I can open a follow-up issue to update all similar panels together. Proposed scope:
pd_scheduler_hot_peers_summary{type="exp-…-read-…"}
to:
pd_scheduler_hot_peers_summary{store=~"$store", type="exp-…-read-…"}
Want me to file that tracking issue and assign it to you, or prefer I prep a small cleanup PR after this merges?
✏️ Learnings added