Async.Parallel stack overflow on cancellation of ~2000 uncompleted computations #13165
Labels
Area-Library
Issues for FSharp.Core not covered elsewhere
Bug
Impact-Medium
(Internal MS Team use only) Describes an issue with moderate impact on existing code.
When
Async.Parallel
is handling cancellation (via the token or a computation throwing) with e.g. 2000 items outstanding, the current implementation as of FSharp.Core 6.0.4 is such that the non-tail-recursive impl can blow the stack.Repro steps
Known workarounds
batch the work with
Seq.ChunkBySize 1500
, add an outerAsync.Parallel
call (distributing thedegreeOfParallelism
over the constituent calls, or using the same value but internally constraining it withAsync.Throttle
),Array.concat
the results.Related information
(1800 is the approx threshold with SDK 6.0.202 on MacOS x86 with Rider test runner)
Problem appears to be at
fsharp/src/FSharp.Core/async.fs
Line 1473 in 0006b73
The text was updated successfully, but these errors were encountered: