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

Copy link

linux-foundation-easycla bot commented Sep 27, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

Copy link

codecov bot commented Sep 27, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.25%. Comparing base (ae62635) to head (08c45bc).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8614      +/-   ##
==========================================
+ Coverage   81.21%   81.25%   +0.04%     
==========================================
  Files         416      416              
  Lines       41002    41002              
==========================================
+ Hits        33298    33317      +19     
+ Misses       6226     6205      -21     
- Partials     1478     1480       +2     

see 22 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!

Comment on lines 312 to 319
bc.lockingHistograms[idx].histogram = stats.NewHistogram(bc.histogramOptions)
if poissonLambda == nil { // Closed loop.
if stream.Context().Err() != nil {
return
}
// Start goroutine on the created mutex and histogram.
go func(idx int) {
// TODO: do warm up if necessary.
Copy link
Author

Choose a reason for hiding this comment

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

You said

We usually do the check just before performing an asynchronous operation

so I decided to do it like that. If it is not the appropriate way, please tell me

Copy link
Contributor

Choose a reason for hiding this comment

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

Since gRPC handles context cancellation and returns a CANCELLED status, this check seems redundant. Considering the context could be cancelled just after we check Context().Err(), checking it here explicitly doesn't buy us much.

@easwars
Copy link
Contributor

easwars commented Oct 10, 2025

@wdsjk Please let us know when this is ready for another review pass.

@wdsjk
Copy link
Author

wdsjk commented Oct 11, 2025

This is ready, review please @easwars @arjan-bal

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.

Mostly looks good, left some minor comments.

Comment on lines 312 to 319
bc.lockingHistograms[idx].histogram = stats.NewHistogram(bc.histogramOptions)
if poissonLambda == nil { // Closed loop.
if stream.Context().Err() != nil {
return
}
// Start goroutine on the created mutex and histogram.
go func(idx int) {
// TODO: do warm up if necessary.
Copy link
Contributor

Choose a reason for hiding this comment

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

Since gRPC handles context cancellation and returns a CANCELLED status, this check seems redundant. Considering the context could be cancelled just after we check Context().Err(), checking it here explicitly doesn't buy us much.

@arjan-bal arjan-bal assigned wdsjk and unassigned arjan-bal 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
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