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

LockCtx: add memTracker for InitCheckExistence in LockCtx #52739

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

RemHero
Copy link

@RemHero RemHero commented Apr 18, 2024

What problem does this PR solve?

Issue Number: close #51217

Problem Summary:
The memory consumed in InitCheckExistence is not tracked by the memory tracker.

What changed and how does it work?

This PR and PR implement the memTracker to track memory usage in InitCheckExistence. Specifically, the OnMemChange method is declared in InitCheckExistence to obtain the memory usage in InitCheckExistence, and the exact memory usage is obtained by referring to the memory calculation method in mem_aware_map.go.

[NOTICE]
This PR needs to be merged after this PR is merged because new member variables are declared in InitCheckExistence. And it needs to be tested after PR merging.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • 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

@sre-bot
Copy link
Contributor

sre-bot commented Apr 18, 2024

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link

ti-chi-bot bot commented Apr 18, 2024

Welcome @RemHero!

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. 😃

Copy link

ti-chi-bot bot commented Apr 18, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign fzhedu for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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 needs-ok-to-test Indicates a PR created by contributors and need ORG member send '/ok-to-test' to start testing. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Apr 18, 2024
Copy link

ti-chi-bot bot commented Apr 18, 2024

Hi @RemHero. 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.

Copy link

tiprow bot commented Apr 18, 2024

Hi @RemHero. 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.

@RemHero RemHero changed the title Add memTracker for InitCheckExistence in LockCtx LockCtx: add memTracker for InitCheckExistence in LockCtx Apr 18, 2024
@hawkingrei
Copy link
Member

/ok-to-test

@ti-chi-bot ti-chi-bot bot added ok-to-test Indicates a PR is ready to be tested. and removed needs-ok-to-test Indicates a PR created by contributors and need ORG member send '/ok-to-test' to start testing. labels Apr 19, 2024
@@ -1246,8 +1250,16 @@ func newLockCtx(sctx sessionctx.Context, lockWaitTime int64, numKeys int) (*tikv
rec := deadlockhistory.ErrDeadlockToDeadlockRecord(deadlock)
deadlockhistory.GlobalDeadlockHistory.Push(rec)
}
lockCtx.OnMemChange = func(capacity int) uint64 {
Copy link
Member

Choose a reason for hiding this comment

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

Please add some test cases for it.

Copy link

ti-chi-bot bot commented Apr 19, 2024

[FORMAT CHECKER NOTIFICATION]

Notice: To remove the do-not-merge/needs-tests-checked label, please finished the tests then check the finished items in description.

For example:

Tests

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

📖 For more info, you can check the "Contribute Code" section in the development guide.

@ti-chi-bot ti-chi-bot bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Apr 19, 2024
Copy link

tiprow bot commented Apr 19, 2024

@RemHero: 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 f725e45 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.

Copy link
Contributor

@ekexium ekexium left a comment

Choose a reason for hiding this comment

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

In terms of how to update client-go dependency, here's the common way:

  1. Prepare PRs for both TiDB and cilent-go.
  2. Replace the dependency of client-go in your TiDB PR, so that CI can run with your client-go patch (see https://github.com/tikv/client-go#test-with-tidb). Note that the bazel cache in CI could stop you. Seek @hawkingrei for help.
  3. Once TiDB PR passes CI and both PRs are approved, merge the client-go PR.
  4. Modify your TiDB PR, remove the replace part, update client-go dependency to the correct version.
  5. Get your TiDB PR merged.

if lockCtx.ForUpdateTS > 0 && seVars.AssertionLevel != variable.AssertionLevelOff {
lockCtx.InitCheckExistence(numKeys)
if lockCtx.OnMemChange != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

OnMemChange is defined in this function and only used here. So it seems to me that it is redundant to have a OnMemChange field in LockCtx.

So you are only recording the initial usage of the struct. That leads to a question: should we dynamically track the structure, or is the initial usage is enough? Anyway it's a good start and better than tracking nothing.

@ti-chi-bot ti-chi-bot bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 5, 2024
Copy link

ti-chi-bot bot commented Jul 5, 2024

PR needs rebase.

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

ti-chi-bot bot commented Nov 18, 2024

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

Test name Commit Details Required Rerun command
idc-jenkins-ci-tidb/build f725e45 link true /test build
idc-jenkins-ci-tidb/check_dev_2 f725e45 link true /test check-dev2
idc-jenkins-ci-tidb/check_dev f725e45 link true /test check-dev
pull-mysql-client-test f725e45 link true /test pull-mysql-client-test
pull-integration-ddl-test f725e45 link true /test pull-integration-ddl-test
idc-jenkins-ci-tidb/unit-test f725e45 link true /test unit-test
idc-jenkins-ci-tidb/mysql-test f725e45 link true /test mysql-test
pull-integration-e2e-test f725e45 link true /test pull-integration-e2e-test

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do-not-merge/needs-tests-checked needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. 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/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Track memory usage in pessimistic locking phase
4 participants