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

ticdc/kvclient: make multiple cdc kv clients share one RegionCache #3464

Merged
merged 10 commits into from
Nov 26, 2021

Conversation

zhaoxinyu
Copy link
Contributor

@zhaoxinyu zhaoxinyu commented Nov 15, 2021

What problem does this PR solve?

issue 3208

Considering the following test:

  • create a TiCDC cluster with one TiCDC server.
  • create a changefeed using MySQL as TiCDC's sink target.
  • create 10 tables and write some data to TiDB using sysbench prepare command.

Optimization Result:
Before optimization: In go pprof goroutine result, we can see 10 goroutines associated with *RegionCache).asyncCheckAndResolveLoop.
After optimization: In go pprof goroutine result, we can see 1 goroutines associated with *RegionCache).asyncCheckAndResolveLoop.

Note: Several goroutines created by tikv/client-go may be visible to us in go pprof goroutine result as well.

What is changed and how it works?

Use a server-level RegionCache instead of calling tikv.NewRegionCache every time a CDCClient is created. By this way, we can use exactly one goroutine for (*RegionCache).asyncCheckAndResolveLoop.

Check List

Tests

  • Unit test
  • Integration test

Release note

None

@ti-chi-bot
Copy link
Member

ti-chi-bot commented Nov 15, 2021

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • amyangfei
  • overvenus

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 first-time-contributor Indicates that the PR was contributed by an external member and is a first-time contributor. release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Nov 15, 2021
@overvenus overvenus added component/kv-client TiKV kv log client component. needs-cherry-pick-release-4.0 Should cherry pick this PR to release-4.0 branch. needs-cherry-pick-release-5.0 Should cherry pick this PR to release-5.0 branch. needs-cherry-pick-release-5.1 Should cherry pick this PR to release-5.1 branch. needs-cherry-pick-release-5.2 Should cherry pick this PR to release-5.2 branch. needs-cherry-pick-release-5.3 Should cherry pick this PR to release-5.3 branch. subject/performance Denotes an issue or pull request is related to replication performance. labels Nov 15, 2021
overvenus
overvenus previously approved these changes Nov 15, 2021
Copy link
Member

@overvenus overvenus 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 Nov 15, 2021
Comment on lines 29 to 31
regionCacheOnce.Do(func() {
regionCacheInstance = tikv.NewRegionCache(pd)
})
Copy link
Contributor

Choose a reason for hiding this comment

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

kv client would close region cache after it exits, which is not expected after using a singleton

@amyangfei
Copy link
Contributor

Besides please check whether any side effect was introduced to existing unit tests

@ti-chi-bot ti-chi-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 17, 2021
Copy link
Member

@overvenus overvenus left a comment

Choose a reason for hiding this comment

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

Rest LGTM

cdc/kv/client.go Outdated Show resolved Hide resolved
@overvenus overvenus dismissed their stale review November 17, 2021 11:36

See above

@ti-chi-bot ti-chi-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 19, 2021
@amyangfei
Copy link
Contributor

/run-all-tests

@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 Nov 24, 2021
@amyangfei
Copy link
Contributor

/merge

@ti-chi-bot
Copy link
Member

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

Commit hash: 197d005

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Nov 24, 2021
@ti-chi-bot ti-chi-bot merged commit e46ded9 into pingcap:master Nov 26, 2021
ti-chi-bot pushed a commit to ti-chi-bot/tiflow that referenced this pull request Nov 26, 2021
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created: #3633.

ti-chi-bot pushed a commit to ti-chi-bot/tiflow that referenced this pull request Nov 26, 2021
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created: #3634.

ti-chi-bot pushed a commit to ti-chi-bot/tiflow that referenced this pull request Nov 26, 2021
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created: #3635.

ti-chi-bot pushed a commit to ti-chi-bot/tiflow that referenced this pull request Nov 26, 2021
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created: #3636.

@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created: #3637.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/kv-client TiKV kv log client component. first-time-contributor Indicates that the PR was contributed by an external member and is a first-time contributor. needs-cherry-pick-release-4.0 Should cherry pick this PR to release-4.0 branch. needs-cherry-pick-release-5.0 Should cherry pick this PR to release-5.0 branch. needs-cherry-pick-release-5.1 Should cherry pick this PR to release-5.1 branch. needs-cherry-pick-release-5.2 Should cherry pick this PR to release-5.2 branch. needs-cherry-pick-release-5.3 Should cherry pick this PR to release-5.3 branch. release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 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. subject/performance Denotes an issue or pull request is related to replication performance.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants