Skip to content

Conversation

@wdsjk
Copy link

@wdsjk wdsjk commented Sep 27, 2025

Fixes: #8596

Added cancellation by context in benchmark/client instead of custom channel approach. Not sure about returning ctx.Err() (as mentioned in the original issue under point 4), so please review

RELEASE NOTES: None

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Sep 27, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

@codecov
Copy link

codecov bot commented Sep 27, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.19%. Comparing base (ab1ca08) to head (e09a7f5).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8614      +/-   ##
==========================================
+ Coverage   82.05%   82.19%   +0.13%     
==========================================
  Files         417      417              
  Lines       40793    40793              
==========================================
+ Hits        33473    33530      +57     
+ Misses       5963     5919      -44     
+ Partials     1357     1344      -13     

see 30 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@wdsjk wdsjk marked this pull request as draft September 27, 2025 17:22
@wdsjk wdsjk marked this pull request as ready for review September 27, 2025 17:30
@wdsjk
Copy link
Author

wdsjk commented Sep 27, 2025

Could you please add "Type: Internal Cleanup" label? Thanks

@Pranjali-2501 Pranjali-2501 added the Type: Internal Cleanup Refactors, etc label Sep 30, 2025
@Pranjali-2501 Pranjali-2501 self-requested a review September 30, 2025 06:53
@Pranjali-2501 Pranjali-2501 self-assigned this Sep 30, 2025
@Pranjali-2501 Pranjali-2501 added this to the 1.77 Release milestone Sep 30, 2025
@arjan-bal arjan-bal assigned arjan-bal and unassigned wdsjk Oct 7, 2025
Copy link
Contributor

@arjan-bal arjan-bal left a comment

Choose a reason for hiding this comment

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

Apologies for the delayed review and thanks for the contribution!

A few main points:

  1. We should pass the context though function params.
  2. We should try to derive contexts from other contexts as much as possible instead of using context.Background.
  3. We can avoid a lot of the ctx.Err() checks by letting RPCs fail and handling the case when the error had a status of CANCELLED.

@arjan-bal arjan-bal assigned wdsjk and unassigned arjan-bal Oct 10, 2025
@wdsjk
Copy link
Author

wdsjk commented Oct 10, 2025

Thank you very much for the review, it is very helpful!

@arjan-bal arjan-bal removed their assignment Oct 16, 2025
@wdsjk
Copy link
Author

wdsjk commented Oct 16, 2025

Everything is ready, review please @arjan-bal

@arjan-bal arjan-bal assigned arjan-bal and unassigned wdsjk Oct 16, 2025
arjan-bal
arjan-bal previously approved these changes Oct 17, 2025
Copy link
Contributor

@arjan-bal arjan-bal left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for the contribution! Adding a second reviewer. I'll also run the benchmarks once to verify there aren't any regressions.

Copy link
Contributor

@arjan-bal arjan-bal left a comment

Choose a reason for hiding this comment

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

There's a significant drop in unary performance from 625k qps to 351k qps compared to the master branch. I'm investigating further.

@arjan-bal arjan-bal self-requested a review October 17, 2025 09:50
@arjan-bal arjan-bal dismissed their stale review October 17, 2025 09:50

Investigating performance regression in unary benchmark performance.

@arjan-bal
Copy link
Contributor

There's a significant drop in unary performance from 625k qps to 351k qps compared to the master branch. I'm investigating further.

Using the cancellable context to make RPCs seems to be the reason for the performance drop. After reverting to using context.Background() for making RPCs (see 1d2714b), the performance was back to initial levels.

Copy link
Contributor

@arjan-bal arjan-bal left a comment

Choose a reason for hiding this comment

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

Left some comments to avoid the performance cost of using a cancellable context for RPCs. The main changes are:

  • We should continue to propagate the context until the point of making a stream or unary call.
  • We should check for context expiry before making the unary call or stream request. In most cases this means replacing the following
select {
	case <-bc.stop:
		return
	default:
}

with

if ctx.Err() != nil {
        return
}
  • Continue to use context.Background() for requests as before.

@arjan-bal arjan-bal assigned wdsjk and unassigned easwars and arjan-bal Oct 17, 2025
@wdsjk
Copy link
Author

wdsjk commented Oct 17, 2025

Review please @arjan-bal

@wdsjk wdsjk closed this Oct 17, 2025
@wdsjk wdsjk reopened this Oct 17, 2025
@wdsjk
Copy link
Author

wdsjk commented Oct 17, 2025

Sorry, misclicked

@wdsjk wdsjk requested a review from arjan-bal October 17, 2025 12:27
@wdsjk wdsjk removed their assignment Oct 17, 2025
@arjan-bal arjan-bal self-assigned this Oct 21, 2025
Copy link
Contributor

@arjan-bal arjan-bal left a comment

Choose a reason for hiding this comment

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

LGTM, adding a second reviewer.

@arjan-bal arjan-bal assigned easwars and unassigned arjan-bal Oct 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

benchmark/client: Use context for cancellation

4 participants