-
Notifications
You must be signed in to change notification settings - Fork 719
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
client: Make tsoStream receives asynchronously #8483
Conversation
Skipping CI for Draft Pull Request. |
Signed-off-by: MyonKeminta <[email protected]>
881f542
to
140a7c2
Compare
Signed-off-by: MyonKeminta <[email protected]>
Signed-off-by: MyonKeminta <[email protected]>
Signed-off-by: MyonKeminta <[email protected]>
Signed-off-by: MyonKeminta <[email protected]>
Signed-off-by: MyonKeminta <[email protected]>
Signed-off-by: MyonKeminta <[email protected]>
Signed-off-by: MyonKeminta <[email protected]>
Signed-off-by: MyonKeminta <[email protected]>
Signed-off-by: MyonKeminta <[email protected]>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #8483 +/- ##
==========================================
- Coverage 77.66% 77.61% -0.05%
==========================================
Files 474 474
Lines 61898 62033 +135
==========================================
+ Hits 48072 48148 +76
- Misses 10283 10340 +57
- Partials 3543 3545 +2
Flags with carried forward coverage won't be shown. Click here to find out more. |
Signed-off-by: MyonKeminta <[email protected]>
@@ -0,0 +1,333 @@ | |||
// Copyright 2024 TiKV Project Authors. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to add bench for it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean mocking the internal implementation of the stream and benching the overhead of the tsoStream
layer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to add a bench to compare the performance change before and after introducing this pr.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll have a try on this
client/tso_stream.go
Outdated
|
||
const invalidStreamID = "<invalid>" | ||
|
||
// TODO: Pass a context? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will we pass it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I forgot this. I'll have a try.
}) | ||
|
||
// A large-enough capacity to hold maximum concurrent RPC requests. In our design, the concurrency is at most 16. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will it be changed in the future?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have such plan. As the more concurrent RPC there is, the less we can benefit from each additional concurrent RPC, it's not a good idea to allow too many concurrent RPCs for each stream. In our current plan, 16 is the maximum.
…make-tso-stream-async
Signed-off-by: MyonKeminta <[email protected]>
Signed-off-by: MyonKeminta <[email protected]>
…make-tso-stream-async
Signed-off-by: MyonKeminta <[email protected]>
Signed-off-by: MyonKeminta <[email protected]>
…make-tso-stream-async
Signed-off-by: MyonKeminta <[email protected]>
@lhy1024 I've done some benchmarks with the stream implemented by channels internally to show the overhead of Before this PR: (code in #8618 , which is branched from the merge-base of this PR and master)
This PR (bff9eae):
There are several microseconds of additional overhead in this PR. Please see if this is acceptable. If you feel good with it, let's consider merging #8618 before this PR. |
Signed-off-by: MyonKeminta <[email protected]>
…make-tso-stream-async
…Request from the pool Signed-off-by: MyonKeminta <[email protected]>
Signed-off-by: MyonKeminta <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the rest LGTM
for !s.state.CompareAndSwap(streamStateIdle, streamStateClosing) { | ||
switch state := s.state.Load(); state { | ||
case streamStateIdle, streamStateSending: | ||
// streamStateSending should switch to streamStateIdle very quickly. Spin until successfully setting to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spin?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Considering that there won't be any blocking operation in streamStateSending
state and the state won't last long, I think spinning here is better than writing another syncing operation here.
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: JmPotato, lhy1024 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 |
What problem does this PR solve?
Issue Number: Ref #8432
What is changed and how does it work?
Check List
Tests
Code changes
Side effects
Related changes
pingcap/docs
/pingcap/docs-cn
:pingcap/tiup
:Release note