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

executor: add memory tracker for memtableRetriever #51455

Merged
merged 1 commit into from
Mar 5, 2024

Conversation

wshwsh12
Copy link
Contributor

@wshwsh12 wshwsh12 commented Mar 1, 2024

What problem does this PR solve?

Issue Number: close #51456
related #51260

Problem Summary:

What changed and how does it work?

Add memory tracker for memtableRetriever

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)

Test Case: 50k tables, each table contains 10 columns.

Test1: Testing 'explain analyze' to accurately display memory usage.

tidb> desc analyze select * from INFORMATION_SCHEMA.tables;
+----------------+----------+---------+------+---------------+-------------------------------------+---------------+---------+------+
| id             | estRows  | actRows | task | access object | execution info                      | operator info | memory  | disk |
+----------------+----------+---------+------+---------------+-------------------------------------+---------------+---------+------+
| MemTableScan_4 | 10000.00 | 50816   | root | table:TABLES  | time:115.1ms, loops:51, RU:0.000000 |               | 91.3 MB | N/A  |
+----------------+----------+---------+------+---------------+-------------------------------------+---------------+---------+------+
1 row in set (0.116 sec)

Test2: Testing mem-quota to successfully cancel SQL queries exceeding the threshold.

tidb> set tidb_mem_quota_query = 80 << 20;
Query OK, 0 rows affected (0.001 sec)

tidb> desc analyze select * from INFORMATION_SCHEMA.tables;
ERROR 8175 (HY000): Your query has been cancelled due to exceeding the allowed memory limit for a single SQL query. Please try narrowing your query scope or increase the tidb_mem_quota_query limit and try again.[conn=463470598]
  • 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 do-not-merge/needs-tests-checked release-note-none Denotes a PR that doesn't merit a release note. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Mar 1, 2024
Copy link

tiprow bot commented Mar 1, 2024

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

Copy link

codecov bot commented Mar 1, 2024

Codecov Report

Merging #51455 (da0ceed) into master (60aa838) will increase coverage by 2.7114%.
Report is 29 commits behind head on master.
The diff coverage is 100.0000%.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #51455        +/-   ##
================================================
+ Coverage   70.6985%   73.4099%   +2.7114%     
================================================
  Files          1462       1463         +1     
  Lines        435210     440890      +5680     
================================================
+ Hits         307687     323657     +15970     
+ Misses       108225      97086     -11139     
- Partials      19298      20147       +849     
Flag Coverage Δ
integration 49.7203% <100.0000%> (?)
unit 71.0142% <100.0000%> (+0.5164%) ⬆️

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

Components Coverage Δ
dumpling 53.9957% <ø> (ø)
parser ∅ <ø> (∅)
br 51.7237% <ø> (+5.8787%) ⬆️

@ywqzzy
Copy link
Contributor

ywqzzy commented Mar 1, 2024

/lgtm

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

@YangKeao YangKeao left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -210,6 +211,9 @@ func (e *memtableRetriever) retrieve(ctx context.Context, sctx sessionctx.Contex
return nil, err
}
e.initialized = true
if e.memTracker != nil {
e.memTracker.Consume(calculateDatumsSize(e.rows))
Copy link
Member

Choose a reason for hiding this comment

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

At this time, the memory has already been allocated 🤔. Do we have a plan to Consume progressively in each implementation above?

Copy link

ti-chi-bot bot commented Mar 4, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: YangKeao, ywqzzy

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 Mar 4, 2024
Copy link

ti-chi-bot bot commented Mar 4, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-03-01 09:57:41.65262228 +0000 UTC m=+1215150.400245406: ☑️ agreed by ywqzzy.
  • 2024-03-04 08:49:43.912291959 +0000 UTC m=+70610.934538347: ☑️ agreed by YangKeao.

@wshwsh12
Copy link
Contributor Author

wshwsh12 commented Mar 5, 2024

/retest

Copy link

tiprow bot commented Mar 5, 2024

@wshwsh12: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/retest

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.

@wshwsh12
Copy link
Contributor Author

wshwsh12 commented Mar 5, 2024

/retest

Copy link

tiprow bot commented Mar 5, 2024

@wshwsh12: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/retest

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.

@wshwsh12
Copy link
Contributor Author

wshwsh12 commented Mar 5, 2024

/ok-to-test

@ti-chi-bot ti-chi-bot bot added the ok-to-test Indicates a PR is ready to be tested. label Mar 5, 2024
Copy link

tiprow bot commented Mar 5, 2024

@wshwsh12: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
fast_test_tiprow da0ceed link true /test fast_test_tiprow

Full PR test history. Your PR dashboard.

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. I understand the commands that are listed here.

@ti-chi-bot ti-chi-bot bot merged commit 4f4f911 into pingcap:master Mar 5, 2024
22 of 23 checks passed
@ti-chi-bot ti-chi-bot added the needs-cherry-pick-release-7.1 Should cherry pick this PR to release-7.1 branch. label Apr 23, 2024
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-7.1: #52823.

ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Apr 23, 2024
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot ti-chi-bot added the needs-cherry-pick-release-7.5 Should cherry pick this PR to release-7.5 branch. label May 7, 2024
ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request May 7, 2024
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-7.5: #53068.

@ti-chi-bot ti-chi-bot added the needs-cherry-pick-release-6.5 Should cherry pick this PR to release-6.5 branch. label May 31, 2024
ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request May 31, 2024
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-6.5: #53706.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm needs-cherry-pick-release-6.5 Should cherry pick this PR to release-6.5 branch. needs-cherry-pick-release-7.1 Should cherry pick this PR to release-7.1 branch. needs-cherry-pick-release-7.5 Should cherry pick this PR to release-7.5 branch. ok-to-test Indicates a PR is ready to be tested. release-note-none Denotes a PR that doesn't merit a release note. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add memory tracker for memtableRetriever
4 participants