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

lightning: improve the performance of duplicate detection #30203

Merged
merged 31 commits into from
Dec 30, 2021

Conversation

sleepymole
Copy link
Contributor

@sleepymole sleepymole commented Nov 29, 2021

What problem does this PR solve?

Issue Number: close #29588

Problem Summary:

What is changed and how it works?

Improve the performance of duplicate detection by implementing concurrency logic to collecting duplicates and resolving duplicates. I tested about 900 million rows duplicates. The cost time is reduced from serval hours to 5m30s(detection 3m30s, resolution 1m35s) on my Ryzen 7 4800H laptop.

This PR is too large 🤣. It has been split into multiple small PRs:

Check List

Tests

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

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

None

@ti-chi-bot
Copy link
Member

ti-chi-bot commented Nov 29, 2021

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • Little-Wallace
  • kennytm

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 release-note-none Denotes a PR that doesn't merit a release note. label Nov 29, 2021
@sleepymole sleepymole marked this pull request as draft November 29, 2021 02:20
@ti-chi-bot ti-chi-bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Nov 29, 2021
@sleepymole
Copy link
Contributor Author

/component lightning

@ti-chi-bot ti-chi-bot added the component/lightning This issue is related to Lightning of TiDB. label Nov 29, 2021
@sleepymole
Copy link
Contributor Author

/run-integration-br-test

Co-authored-by: glorv <glorvs@163.com>
@sleepymole
Copy link
Contributor Author

/run-integration-br-test

@kennytm
Copy link
Contributor

kennytm commented Dec 29, 2021

/run-unit-test

@sre-bot
Copy link
Contributor

sre-bot commented Dec 29, 2021

finishSchedulers()
cancelFunc(switchBack)
finishFuncCalled = true
finishSchedulers()
Copy link
Contributor

Choose a reason for hiding this comment

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

Please move defer close(stopPeriodicActions) before this defer to ensure output progress log in post-process phase. BTW, I'm not sure if do normal logic like postProcess in a defer function is a good idea. @kennytm what do you think

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure if do normal logic like postProcess in a defer function is a good idea.

Maybe it is not a good idea. 🤣 restoreTables method need to do some refactor.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

move defer close(stopPeriodicActions) before this defer to ensure output progress log in post-process phase

If so, we can't switch TiKV to normal mode during duplicate detection.

Copy link
Contributor

Choose a reason for hiding this comment

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

So, maybe we need to split stopPeriodicActions into two function, one is called at this point, and one is called after restoreTables finished. 😂

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 seems cancelFuncs did such thing.

Copy link
Contributor

@Little-Wallace Little-Wallace left a comment

Choose a reason for hiding this comment

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

LGTM

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Dec 30, 2021
Copy link
Contributor

@glorv glorv left a comment

Choose a reason for hiding this comment

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

LGTM

@kennytm PTAL again

@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 Dec 30, 2021
@sleepymole
Copy link
Contributor Author

/run-integration-br-test

@glorv
Copy link
Contributor

glorv commented Dec 30, 2021

/merge

@ti-chi-bot
Copy link
Member

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

Commit hash: eefd997

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Dec 30, 2021
@sleepymole
Copy link
Contributor Author

/run-unit-test

@sleepymole
Copy link
Contributor Author

/run-check_dev_2

@ti-chi-bot
Copy link
Member

@gozssky: 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.

@sleepymole
Copy link
Contributor Author

/run-mysql-test
/run-unit-test

@ti-chi-bot ti-chi-bot merged commit 56a2767 into pingcap:master Dec 30, 2021
@sleepymole sleepymole deleted the issue-29588 branch March 16, 2022 07:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/lightning This issue is related to Lightning of TiDB. release-note-none Denotes a PR that doesn't merit a release note. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. 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.

The duration of lightning duplicate detection is too long
6 participants