Conversation
Benchmark for 0855531Click to view benchmark
|
Benchmark for 1c8dfdaClick to view benchmark
|
jorajeev
approved these changes
Nov 17, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
BatchSemaphore::close_no_scheduling_point.The reason for adding this is that primitives which utilize multiple semaphores (in my case:
mpsc) need to be able to close more than one semaphore without having more than one scheduling point. This is both for efficiency, and for not leaving a system which is partially closed.The latter could have been solved with an atomic field as the source of truth on whether the system is closed or not, but I prefer exposing this method as this approach is more efficient than having needless scheduling points.
There is however one con of this, which is that after #212 gets merged, a
switchbecomes both a scheduling point and an "indicator of interest". If this PR gets merged, then any users ofBatchSemaphore::close_no_scheduling_pointwill not indicate any interest on thoseBatchSemaphores. There's a couple potential solutions to this that come to mind:Eventwhich takes multipleEvents. The code would then never useclose, and instead do a singleswitchbefore callingclose_no_scheduling_pointon whicheverBatchSemaphores it wants to close.There might be a case to expose multiple
_no_scheduling_pointfunctions. My stance is that we'll add those once we need them. If it becomes the case that we want multiple_no_scheduling_pointfunctions, then I will probably suggest to refactor the code such thatswitch(Event)returns aSwitched(Event)which would be passed by ownership to the_no_scheduling_pointfunctions in order to make sure that a scheduling point has occurred and that a correspondingEventhas been created. Again, that bridge is to be burned if that river is ever to be crossed.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.