[llvm] [Support] Join threads when stopping the ThreadPoolExecutor (PR #166054)
Maurice Heumann via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 4 04:51:16 PST 2025
momo5502 wrote:
> Just want to note that IIRC, the reason for only joining the threads in the destructor was to speed up "fast" no cleanup exit, i.e. would skip joining any threads. This used to be quite an overhead for systems with very high thread counts. Something to bear in mind.
So the fix works now, but as it joins the threads, shutdown will take longer.
I don't really see an easy way of having both the speed and safety. Except something like triggering the stop at the beginning of llvm_shutdown and joining the threads at the end, when everything inbetween is done. Not sure if that helps much and it's probably too big of a change.
If the speed is desired, I propose to expose some kind of function that, when called, tells the pool to join the threads when being stopped. Otherwise joining will be done in the destructor. That way, if one needs the safety, the function can be called.
That would be fine for me.
https://github.com/llvm/llvm-project/pull/166054
More information about the llvm-commits
mailing list