I have a F# .NET process running an algorithm that performs many calculations. Due to combinatorics, the number of calculations can be several billions.
To reduce execution times, calculations are performed in parallel by using Async.Parallel(max parallelism = nbr of cores) |> Async.RunSynchronously
The process terminates correctly and the results are ok, however in the log I get multiple warnings like
As of "07/26/2023 22:36:09 +00:00", the heartbeat has been running for "00:04:34.0765437" which is longer than "00:00:01". This could be caused by thread pool starvation. # {"EventId": {"Id": 22, "Name": "HeartbeatSlow"}, "SourceContext": "Microsoft.AspNetCore.Server.Kestrel"}
When this happens, the process hangs up for a variable time (from few seconds up to 10 minutes), and then it resumes and continunes.
Does anyone know the cause for this and how to fix it?