tidb icon indicating copy to clipboard operation
tidb copied to clipboard

pkg[utils]: Added logic to display the Major usage of tracker

Open PsychoPunkSage opened this issue 1 year ago • 11 comments

What problem does this PR solve?

Issue Number: close #52478 Problem Summary: Its an Enhancement. In memory usage, we have no idea which components contribute the most to it. So this PR logs Tracer Fields more idiomatically.

What changed and how does it work?

Added a simple logic to catch all the tracers that consume more than 10% memory and Print all the required Info. Here is the difference

+ [expensivequery.go:151] ["memory exceeds quota"] [cost_time=0.003367882s] [prewrite_time=0.000088001s] [commit_time=0.000171603s] [get_commit_ts_time=0.000015086s] [Slowest_prewrite_rpc_detail="total:0.000s, region_id: 2, store: store1, }"] [Commit_primary_rpc_detail="{total:0.000s, region_id: 2, store: store1, }"] [write_keys=3] [write_size=87] [prewrite_region=1] [conn=1126723269891976749] [user=root] [database=test] [txn_start_ts=0] [mem_max="8408 Bytes (8.21 KB)"] [mem_top_contributors="-28: 8192 Bytes (97.43%)"] [sql="insert into t (a) values (1), (2), (3)"] [session_alias=] ["affected rows"=3]

- [expensivequery.go:151] ["memory exceeds quota"] [cost_time=0.002873876s] [prewrite_time=0.000119431s] [commit_time=0.000117685s] [get_commit_ts_time=0.00001334s] [Slowest_prewrite_rpc_detail="total:0.000s, region_id: 2, store: store1, }"] [Commit_primary_rpc_detail="{total:0.000s, region_id: 2, store: store1, }"] [write_keys=3] [write_size=87] [prewrite_region=1] [conn=7641997234132563176] [user=root] [database=test] [txn_start_ts=0] [mem_max="8408 Bytes (8.21 KB)"] [sql="insert into t (a) values (1), (2), (3)"] [session_alias=] ["affected rows"=3]

To see this output

cd pkg/executor/test/seqtest/prepared_test.go
# Run TestPreparedIssue17419
# search for `expensivequery.go`

Check List

Tests

  • [X] Unit test
  • [X] Integration test
  • [X] Manual test (add detailed scripts or steps below)
  • [X] No need to test
    • [X] I checked and no code files have been changed.

Side effects

  • [X] Performance regression: Consumes more CPU
  • [X] Performance regression: Consumes more Memory
  • [X] Breaking backward compatibility

Documentation

  • [X] Affects user behaviors
  • [X] Contains syntax changes
  • [X] Contains variable changes
  • [X] Contains experimental features
  • [X] Changes MySQL compatibility
None

PsychoPunkSage avatar Aug 20 '24 06:08 PsychoPunkSage

CLA assistant check
All committers have signed the CLA.

sre-bot avatar Aug 20 '24 06:08 sre-bot

Welcome @PsychoPunkSage!

It looks like this is your first PR to pingcap/tidb 🎉.

I'm the bot to help you request reviewers, add labels and more, See available commands.

We want to make sure your contribution gets all the attention it needs!



Thank you, and welcome to pingcap/tidb. :smiley:

ti-chi-bot[bot] avatar Aug 20 '24 06:08 ti-chi-bot[bot]

Hi @PsychoPunkSage. Thanks for your PR.

I'm waiting for a pingcap 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.

ti-chi-bot[bot] avatar Aug 20 '24 06:08 ti-chi-bot[bot]

Hi @PsychoPunkSage. Thanks for your PR.

PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test all.

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-sigs/prow repository.

tiprow[bot] avatar Aug 20 '24 06:08 tiprow[bot]

/ok-to-test

lance6716 avatar Aug 21 '24 07:08 lance6716

/auto-cc

lance6716 avatar Aug 21 '24 07:08 lance6716

/cc @XuHuaiyu

lance6716 avatar Aug 21 '24 07:08 lance6716

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 74.7987%. Comparing base (559f634) to head (ce15901). Report is 1678 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #55521        +/-   ##
================================================
+ Coverage   72.9866%   74.7987%   +1.8121%     
================================================
  Files          1576       1578         +2     
  Lines        440815     447672      +6857     
================================================
+ Hits         321736     334853     +13117     
+ Misses        99389      92409      -6980     
- Partials      19690      20410       +720     
Flag Coverage Δ
integration 49.3336% <81.2500%> (?)
unit 72.5234% <100.0000%> (-0.1977%) :arrow_down:

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

Components Coverage Δ
dumpling ∅ <ø> (∅)
parser ∅ <ø> (∅)
br 52.4790% <ø> (+5.7666%) :arrow_up:
: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 Aug 21 '24 08:08 codecov[bot]

Hi Are there any updates I have to make in the code?

PsychoPunkSage avatar Aug 28 '24 18:08 PsychoPunkSage

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: xhebox

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 Aug 29 '24 02:08 ti-chi-bot[bot]

[LGTM Timeline notifier]

Timeline:

  • 2024-08-29 02:03:12.86842101 +0000 UTC m=+1008588.002871126: :ballot_box_with_check: agreed by xhebox.

ti-chi-bot[bot] avatar Aug 29 '24 02:08 ti-chi-bot[bot]