[cfe-dev] Thread pool for llvm::CrashRecoveryContext::RunSafelyOnThread?

Dmitri Gribenko gribozavr at gmail.com
Tue Apr 29 03:59:01 PDT 2014


On Tue, Apr 29, 2014 at 11:38 AM, Milian Wolff <mail at milianw.de> wrote:
> On Monday 28 April 2014 20:43:35 Dmitri Gribenko wrote:
>> On Mon, Apr 28, 2014 at 7:04 PM, Milian Wolff <mail at milianw.de> wrote:
>> > Would it not be better, performance-wise, to recycle the threads in a
>> > thread pool?
>>
>> This certainly could give us some speedup.  How much does
>> pthread_create() cost on your system?
>
> Based on the simple attached example, the benefit is pretty small. I.e., on my
> machine the reusable thread runs the test in ~1.9s, while the iterative
> approach takes ~5.2s.
>
> That is a cost saving of only ~3s over a run of 100000 iterations. Considering
> that the workload in clang is much higher, I doubt the time savings will be
> noticeable. The only thing that will be noticeable, is one from the tooling
> perspective: You don't see threads being created and deleted all the time
> (esp. in GDB).

This amounts to 30 us for a single run.  I guess, every little bit
helps.  We would accept the patch to implement a portable thread pool
in libSupport and use it in libclang, but I don't think this is
high-priority for someone to work on.

Dmitri

-- 
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/



More information about the cfe-dev mailing list