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

resource_group_client: statistic sql cpu cost #6003

Merged
merged 24 commits into from Mar 2, 2023

Conversation

HuSharp
Copy link
Member

@HuSharp HuSharp commented Feb 16, 2023

What problem does this PR solve?

Issue Number: Ref #5851

What is changed and how does it work?

statistic tidb cpu cost

Check List

Release note

None

@ti-chi-bot
Copy link
Member

ti-chi-bot commented Feb 16, 2023

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • JmPotato
  • nolouch

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 do-not-merge/needs-linked-issue release-note-none do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. needs-ok-to-test labels Feb 16, 2023
@ti-chi-bot
Copy link
Member

Hi @HuSharp. Thanks for your PR.

I'm waiting for a tikv member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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/test-infra repository.

Signed-off-by: husharp <jinhao.hu@pingcap.com>
@codecov
Copy link

codecov bot commented Feb 16, 2023

Codecov Report

Patch coverage: 82.75% and project coverage change: -0.04 ⚠️

Comparison is base (2383cf4) 74.02% compared to head (d56342f) 73.99%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6003      +/-   ##
==========================================
- Coverage   74.02%   73.99%   -0.04%     
==========================================
  Files         381      381              
  Lines       37793    37802       +9     
==========================================
- Hits        27978    27971       -7     
- Misses       7351     7364      +13     
- Partials     2464     2467       +3     
Flag Coverage Δ
unittests 73.99% <82.75%> (-0.04%) ⬇️

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

Impacted Files Coverage Δ
client/resource_group/controller/model.go 64.00% <66.66%> (+0.50%) ⬆️
pkg/mcs/resource_manager/server/manager.go 81.76% <66.66%> (+0.99%) ⬆️
client/resource_group/controller/config.go 100.00% <100.00%> (ø)
client/resource_group/controller/controller.go 61.91% <100.00%> (+0.53%) ⬆️
pkg/mcs/resource_manager/server/metrics.go 100.00% <100.00%> (ø)
pkg/errs/errs.go 75.00% <0.00%> (-25.00%) ⬇️
server/region_syncer/server.go 82.96% <0.00%> (-4.40%) ⬇️
server/schedule/labeler/rules.go 87.50% <0.00%> (-2.28%) ⬇️
pkg/tso/tso.go 69.10% <0.00%> (-1.69%) ⬇️
pkg/tso/allocator_manager.go 62.56% <0.00%> (-1.63%) ⬇️
... and 20 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.

@HuSharp HuSharp marked this pull request as ready for review February 17, 2023 00:27
@ti-chi-bot ti-chi-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Feb 17, 2023
@JmPotato JmPotato requested review from JmPotato, CabinfeverB and nolouch and removed request for disksing and rleungx February 17, 2023 03:50
Copy link
Contributor

@nolouch nolouch left a comment

Choose a reason for hiding this comment

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

I think we need add a metrics for it.

Signed-off-by: husharp <jinhao.hu@pingcap.com>
@HuSharp
Copy link
Member Author

HuSharp commented Feb 17, 2023

I think we need add a metrics for it.

sqlCPUMetrics have been in backgroundMetricsFlush

Copy link
Contributor

@nolouch nolouch left a comment

Choose a reason for hiding this comment

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

Could you show the metrics panel as an example?

func (dsc *SQLCalculator) Trickle(ctx context.Context, consumption *rmpb.Consumption) {
delta := getSQLProcessCPUTime() - consumption.SqlLayerCpuTimeMs
consumption.SqlLayerCpuTimeMs = delta
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's an accumulative value, not a delta value. we can calculate the delta within collectRequestAndConsumption? ptal @JmPotato

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, this will eventually be calculated in collectRequestAndConsumption.
The reason why delta is calculated here is because it will be added here.
https://github.com/tikv/pd/pull/6003/files#diff-ac1c6525251add035bc46a2bce40ac9d39ee05a8f1b9c062657e869d10506497R499

Signed-off-by: husharp <jinhao.hu@pingcap.com>
@HuSharp
Copy link
Member Author

HuSharp commented Feb 21, 2023

Could you show the metrics panel as an example?

@nolouch
after modify pd client in tidb and client-go
when run sysbench:
image

@nolouch nolouch removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 1, 2023
Signed-off-by: husharp <jinhao.hu@pingcap.com>
@@ -468,7 +483,7 @@ func newGroupCostController(
gc.handleRespFunc = gc.handleRawResourceTokenResponse
}

gc.mu.consumption = &rmpb.Consumption{}
gc.mu.consumption = &rmpb.Consumption{SqlLayerCpuTimeMs: getSQLProcessCPUTime(mainCfg.isSingleGroupByKeyspace)}
Copy link
Contributor

@nolouch nolouch Mar 1, 2023

Choose a reason for hiding this comment

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

I think should make the lastRequestConsumption init with it. then collectRequestAndConsumption will calculate the delta part.

Copy link
Member Author

Choose a reason for hiding this comment

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

You are right, the run.consumption represents the total, not the delta

Signed-off-by: husharp <jinhao.hu@pingcap.com>
@ti-chi-bot ti-chi-bot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Mar 1, 2023
@HuSharp
Copy link
Member Author

HuSharp commented Mar 2, 2023

metrics
RU
image
SQL CPU Time
image

Signed-off-by: husharp <jinhao.hu@pingcap.com>
@@ -46,6 +46,14 @@ var (
Help: "Bucketed histogram of the write request unit cost for all resource groups.",
Buckets: prometheus.ExponentialBuckets(3, 10, 5), // 3 ~ 300000
}, []string{resourceGroupNameLabel})
sqlLayerRequestUnitCost = prometheus.NewHistogramVec(
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe we do no need histogram.

Copy link
Member Author

@HuSharp HuSharp Mar 2, 2023

Choose a reason for hiding this comment

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

have changed to vec

Signed-off-by: husharp <jinhao.hu@pingcap.com>
Signed-off-by: husharp <jinhao.hu@pingcap.com>
@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Mar 2, 2023
@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 Mar 2, 2023
@JmPotato
Copy link
Member

JmPotato commented Mar 2, 2023

/merge

@ti-chi-bot
Copy link
Member

@JmPotato: 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: d56342f

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Mar 2, 2023
@JmPotato
Copy link
Member

JmPotato commented Mar 2, 2023

/ok-to-test

@ti-chi-bot ti-chi-bot merged commit 2ae62af into tikv:master Mar 2, 2023
@HuSharp HuSharp deleted the sqllayer_cpu_cost branch March 2, 2023 08:17
rleungx pushed a commit to rleungx/pd that referenced this pull request Apr 19, 2023
ref tikv#5851

statistic tidb cpu cost

Signed-off-by: husharp <jinhao.hu@pingcap.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ok-to-test release-note-none 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.

None yet

5 participants