Repository navigation
[Data] Revisiting make_async_gen to address issues with concurrency control for sequences of varying lengths - #51661
Merged
Merged
Conversation
Signed-off-by: Alexey Kudinkin <[email protected]>
Signed-off-by: Alexey Kudinkin <[email protected]>
Signed-off-by: Alexey Kudinkin <[email protected]>
Signed-off-by: Alexey Kudinkin <[email protected]>
Signed-off-by: Alexey Kudinkin <[email protected]>
alexeykudinkin
commented
Mar 25, 2025
| fn: Callable[[Iterator[T]], Iterator[U]], | ||
| num_workers: int = 1, | ||
| queue_buffer_size: int = 2, | ||
| queue_buffer_size: Optional[int] = None, |
Contributor
Author
There was a problem hiding this comment.
@raulchen i'd recommend reviewing in isolation as this was written from scratch
Signed-off-by: Alexey Kudinkin <[email protected]>
Signed-off-by: Alexey Kudinkin <[email protected]>
Signed-off-by: Alexey Kudinkin <[email protected]>
make_async_gen to address issues with concurrency control for sequences of varying lengthsmake_async_gen to address issues with concurrency control for sequences of varying lengths
raulchen
approved these changes
Mar 25, 2025
Signed-off-by: Alexey Kudinkin <[email protected]>
Signed-off-by: Alexey Kudinkin <[email protected]>
Signed-off-by: Alexey Kudinkin <[email protected]>
Signed-off-by: Alexey Kudinkin <[email protected]>
Fixed fixture Signed-off-by: Alexey Kudinkin <[email protected]>
Signed-off-by: Alexey Kudinkin <[email protected]>
Signed-off-by: Alexey Kudinkin <[email protected]>
Signed-off-by: Alexey Kudinkin <[email protected]>
Signed-off-by: Alexey Kudinkin <[email protected]>
Signed-off-by: Alexey Kudinkin <[email protected]>
alexeykudinkin
commented
Mar 26, 2025
Signed-off-by: Alexey Kudinkin <[email protected]>
raulchen
approved these changes
Mar 26, 2025
| iter(range(3)), | ||
| _transform_b, | ||
| ): | ||
| pass |
Contributor
There was a problem hiding this comment.
nit, maybe use multiple workers and test that transform fn is entered at most once per worker.
and for simplicity in the multi-threading case, we can just use a counter instead of capturing the logs.
Contributor
|
Can you update the PR description as the fix has changed? |
Signed-off-by: Alexey Kudinkin <[email protected]>
Signed-off-by: Alexey Kudinkin <[email protected]>
Signed-off-by: Alexey Kudinkin <[email protected]>
… on whether ordering has to be preserved; Updated docs Signed-off-by: Alexey Kudinkin <[email protected]>
Signed-off-by: Alexey Kudinkin <[email protected]>
Signed-off-by: Alexey Kudinkin <[email protected]>
… queue instead of N Signed-off-by: Alexey Kudinkin <[email protected]>
Signed-off-by: Alexey Kudinkin <[email protected]>
Signed-off-by: Alexey Kudinkin <[email protected]>
Tidying up Signed-off-by: Alexey Kudinkin <[email protected]>
Signed-off-by: Alexey Kudinkin <[email protected]>
Signed-off-by: Alexey Kudinkin <[email protected]>
Signed-off-by: Alexey Kudinkin <[email protected]>
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.
Why are these changes needed?
This change addresses potential deadlocks inside
make_async_genwhen used in with functions producing sequences of wildly varying in lengths.Fundamentally
make_async_genwas trying to solve 2 problems respective solutions for which never actually overlapped:Implement parallel processing based on transforming an input iterator into an output one, while preserving back-pressure semantic, where input iterator should not be outpacing output iterator being consumed.
Implement parallel processing allowing ordering of the input iterator being preserved.
These requirements coupled with the fact the transformation is expected to received and produce iterators are what led to erroneous deduction that it could be implemented:
To resolve that problem fundamentally we decoupling this 2 use-cases into
Preserving order: has N input and output queues, with the input queues being uncapped (while output queues still being capped at
queue_buffer_size), meaning that incoming iterator will be unrolled eagerly by the producer (till exhaustion)Not preserving order: has 1 input queue and N output queues, with both input and output queues being capped in size based
queue_buffer_sizeconfiguration. This allows to implement back-pressure semantic where consumption speed will limit production speed (and amount of buffered data)Changes
preserve_orderingparamRelated issue number
Checks
git commit -s) in this PR.scripts/format.shto lint the changes in this PR.method in Tune, I've added it in
doc/source/tune/api/under thecorresponding
.rstfile.