Repository navigation
fix: concurrentPool buffered-delivery stall and unbounded prefetch - #399
Merged
Merged
Conversation
…ulls Three failing regressions: - buffered items are not delivered once the pull chain drains - next() hangs on a buffered result while the following upstream fetch hangs - every consumer next() launches `length` new fetches regardless of buffered results, so a slow consumer grows the buffer unboundedly (produced == consumed x pool size) - the source is pulled again after it has thrown (the known TODO) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…currentPool - next() now serves already-buffered results immediately instead of depending on a future fetch settling, fixing a hang where buffered items were never delivered once the pull chain drained while the next upstream fetch was pending - prefetch is capped at the pool size when no consumer is waiting, so a slow consumer no longer grows the buffer unboundedly (was consumed x pool-size upstream pulls); under active demand the pool stays saturated, preserving p-map-equivalent throughput (verified 455ms == 455ms on the uneven-duration benchmark) - the source is no longer pulled after it has thrown (resolves the long-standing TODO), and post-error consumers receive done once nothing is in flight and the buffer is drained Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Summary
Fixes three empirically reproduced defects in
concurrentPool(regression tests committed first, all failing on the previous implementation):next()only relied on a future fetch settling to trigger delivery, so once the pull chain drained, already-buffered results were never handed out while the following upstream fetch hung.next()now serves the buffer directly.next()launchedlengthnew fetches regardless of buffered results (upstream pulls == consumed × pool size). Prefetch is now capped at the pool size when no consumer is waiting; under active demand the pool stays saturated, which is what order-preserving pools (p-map included) must do past a slow head item.done.Throughput parity re-verified after the fix: p-map 455ms vs concurrentPool 455ms on the uneven-duration benchmark (concurrency 2) — the migration guide's claims still hold.
Test plan
Promise.racetimeout, produced ≤ consumed + pool, zero post-throw pulls), all red before / green aftercompile:check0🤖 Generated with Claude Code