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

kv-client: use worker pool in region worker #1481

Merged

Conversation

amyangfei
Copy link
Contributor

What problem does this PR solve?

Part of #1393

To increase the throughput of kv client, we should use multiple goroutines in region worker

What is changed and how it works?

  • Reuse github.com/pingcap/ticdc/pkg/workerpool

Check List

Tests

  • Unit test
  • Integration test

Release note

  • No release note

@amyangfei amyangfei added status/WIP component/kv-client TiKV kv log client component. needs-cherry-pick-release-4.0 Should cherry pick this PR to release-4.0 branch. labels Mar 3, 2021
@amyangfei amyangfei added this to the v5.0.0 milestone Mar 3, 2021
@amyangfei amyangfei force-pushed the kv-client-optimization-region-worker-pool branch from 34ed9e2 to f46e923 Compare March 5, 2021 08:31
@ti-chi-bot ti-chi-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 24, 2021
@amyangfei amyangfei modified the milestones: v5.0.0, v5.0.1 Apr 9, 2021
@amyangfei amyangfei force-pushed the kv-client-optimization-region-worker-pool branch from 9d0912b to 531d440 Compare April 15, 2021 03:03
@ti-chi-bot ti-chi-bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Apr 15, 2021
@amyangfei amyangfei added the needs-cherry-pick-release-5.0 Should cherry pick this PR to release-5.0 branch. label Apr 15, 2021
@amyangfei amyangfei force-pushed the kv-client-optimization-region-worker-pool branch 2 times, most recently from d6da339 to 168a20b Compare April 16, 2021 10:27
@amyangfei
Copy link
Contributor Author

/run-all-tests

1 similar comment
@amyangfei
Copy link
Contributor Author

/run-all-tests

@ti-chi-bot ti-chi-bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Apr 20, 2021
@amyangfei amyangfei force-pushed the kv-client-optimization-region-worker-pool branch from 3c6d569 to 4dc2f83 Compare April 20, 2021 07:49
@amyangfei
Copy link
Contributor Author

/run-all-tests

1 similar comment
@amyangfei
Copy link
Contributor Author

/run-all-tests

@amyangfei amyangfei added status/ptal Could you please take a look? and removed status/wip labels Apr 20, 2021
@amyangfei amyangfei modified the milestones: v5.0.1, v5.0.2 Apr 22, 2021
@amyangfei
Copy link
Contributor Author

PTAL @liuzix @leoppro @overvenus

func Test(t *testing.T) { check.TestingT(t) }
func Test(t *testing.T) {
conf := config.GetDefaultServerConfig()
config.StoreGlobalServerConfig(conf)
Copy link
Contributor

Choose a reason for hiding this comment

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

should we set a default config in init function?

@@ -263,6 +264,10 @@ func (s *Server) run(ctx context.Context) (err error) {
return sorter.RunWorkerPool(cctx)
})

wg.Go(func() error {
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe we can run worker pool in init function?

Copy link
Contributor Author

@amyangfei amyangfei Apr 28, 2021

Choose a reason for hiding this comment

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

Yep either run it in init function or explicit invocation works, but IMHO the init function is a little dangerous in some scenarios, which may make initialization step unclear (such as init sequence, unexpected init when we import a package but don't want it to init, etc)
such as the discussion in this article: https://medium.com/higher-order-functions/golang-how-to-sensibly-use-init-function-8077a4ec15e5

@overvenus
Copy link
Member

/lgtm

@ti-chi-bot
Copy link
Member

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • leoppro
  • 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 writing /lgtm in a comment.
Reviewer can cancel approval by writing /lgtm cancel in a comment.

@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 May 18, 2021
@3AceShowHand
Copy link
Contributor

/run-unit-tests

regionWorkerPool workerpool.WorkerPool
workerPoolOnce sync.Once
// TODO: unified channel buffer mechanism
regionWorkerInputChanSize = 128000
Copy link
Contributor

Choose a reason for hiding this comment

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

can you add a comment about this magic 128000?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added some comments

@amyangfei
Copy link
Contributor Author

/merge

@ti-chi-bot
Copy link
Member

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

Commit hash: 862f695

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label May 19, 2021
@purelind
Copy link
Collaborator

/run-all-tests

@amyangfei
Copy link
Contributor Author

/run-kafka-tests

@ti-chi-bot ti-chi-bot merged commit 075a31d into pingcap:master May 19, 2021
ti-chi-bot pushed a commit to ti-chi-bot/tiflow that referenced this pull request May 19, 2021
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: #1802.

ti-chi-bot pushed a commit to ti-chi-bot/tiflow that referenced this pull request May 19, 2021
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: #1803.

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. 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. 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. status/ptal Could you please take a look?
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants