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: reduce unnecessary copy when collect hot metrics #5709

Merged
merged 6 commits into from
Nov 21, 2022

Conversation

lhy1024
Copy link
Contributor

@lhy1024 lhy1024 commented Nov 15, 2022

Signed-off-by: lhy1024 [email protected]

What problem does this PR solve?

Issue Number: Ref #5692
Before:
image
After:
image

What is changed and how does it work?

Check List

Tests

  • Unit test

Release note

None.

@ti-chi-bot
Copy link
Member

ti-chi-bot commented Nov 15, 2022

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • CabinfeverB
  • rleungx

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

The full list of commands accepted by this bot can be found here.

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot added the do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. label Nov 15, 2022
@lhy1024 lhy1024 added the release-note-none Denotes a PR that doesn't merit a release note. label Nov 15, 2022
@ti-chi-bot ti-chi-bot removed the do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. label Nov 15, 2022
Signed-off-by: lhy1024 <[email protected]>
Signed-off-by: lhy1024 <[email protected]>
@codecov
Copy link

codecov bot commented Nov 16, 2022

Codecov Report

Base: 75.65% // Head: 75.70% // Increases project coverage by +0.05% 🎉

Coverage data is based on head (5acb0d0) compared to base (7a040fd).
Patch coverage: 100.00% of modified lines in pull request are covered.

❗ Current head 5acb0d0 differs from pull request most recent head a55376c. Consider uploading reports for the commit a55376c to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5709      +/-   ##
==========================================
+ Coverage   75.65%   75.70%   +0.05%     
==========================================
  Files         329      329              
  Lines       32689    32707      +18     
==========================================
+ Hits        24730    24761      +31     
+ Misses       5817     5814       -3     
+ Partials     2142     2132      -10     
Flag Coverage Δ
unittests 75.70% <100.00%> (+0.05%) ⬆️

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

Impacted Files Coverage Δ
server/statistics/hot_peer_cache.go 97.70% <ø> (ø)
server/cluster/coordinator.go 72.95% <100.00%> (+1.14%) ⬆️
server/statistics/hot_peer.go 100.00% <100.00%> (+2.94%) ⬆️
server/statistics/store_hot_peers_infos.go 100.00% <100.00%> (ø)
server/statistics/store_load.go 98.01% <100.00%> (ø)
server/id/id.go 83.05% <0.00%> (-10.17%) ⬇️
server/schedulers/shuffle_hot_region.go 56.00% <0.00%> (-10.00%) ⬇️
server/region_syncer/server.go 82.96% <0.00%> (-4.40%) ⬇️
server/member/member.go 64.21% <0.00%> (-1.58%) ⬇️
server/schedulers/hot_region_v2.go 88.30% <0.00%> (-1.17%) ⬇️
... and 18 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@rleungx
Copy link
Member

rleungx commented Nov 17, 2022

Is there any benchmark to show the improvement?

@lhy1024
Copy link
Contributor Author

lhy1024 commented Nov 17, 2022

Is there any benchmark to show the improvement?

As shown in the picture in the description of pr, the memory of clone will be saved when collecting monitoring information, and in the new version of the test, the relevant flame graph will not be seen.

peerLoadSum[j] += peer.GetLoad(j)
}
}
ret[id] = &HotPeersStat{
Copy link
Member

Choose a reason for hiding this comment

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

Will it miss some info compared with before?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It doesn't contain store info and hot peers detail, but metrics only use the total data of hot peers.

Signed-off-by: lhy1024 <[email protected]>
@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Nov 18, 2022
@nolouch
Copy link
Contributor

nolouch commented Nov 21, 2022

PTAL @HunDunDM

Copy link
Member

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

peers := filterHotPeers(kind, hotPeers)
for _, peer := range peers {
for j := range peerLoadSum {
peerLoadSum[j] += peer.GetLoad(j)
Copy link
Member

Choose a reason for hiding this comment

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

In summaryStoresLoadByEngine, it seems use peer.Loads[i] but not peer.GetLoad(j)

Copy link
Contributor Author

@lhy1024 lhy1024 Nov 21, 2022

Choose a reason for hiding this comment

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

peer.Loads[i] return instant data. peer.GetLoad(i) return denoising data, which is better.

Signed-off-by: lhy1024 <[email protected]>
@ti-chi-bot ti-chi-bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Nov 21, 2022
@lhy1024
Copy link
Contributor Author

lhy1024 commented Nov 21, 2022

/merge

@ti-chi-bot
Copy link
Member

@lhy1024: It seems you want to merge this PR, I will help you trigger all the tests:

/run-all-tests

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
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: 5acb0d0

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Nov 21, 2022
@ti-chi-bot
Copy link
Member

@lhy1024: Your PR was out of date, I have automatically updated it for you.

At the same time I will also trigger all tests for you:

/run-all-tests

If the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes.

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 ti-chi-bot merged commit c703be3 into tikv:master Nov 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note-none Denotes a PR that doesn't merit a release note. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants