pthread_create() slowdown with concurrent sched_yield()

Corinna Vinschen corinna-cygwin@cygwin.com
Wed Mar 8 16:48:00 GMT 2017


On Mar  7 16:19, Dan Bonachea wrote:
> I suspect I may have discovered a corner-case performance bug in
> Cygwin's pthread_create() implementation. The problem arises when a
> call to pthread_create() is made concurrently with multiple pthreads
> in the same process spinning on calls to sched_yield(). I've searched
> the Cygwin mailing list archives, user guide, FAQ, and Google and not
> found any mention of this particular misbehavior.
> 
> A minimal demo program is copied below and also available here:
>    https://upc-bugs.lbl.gov/bugzilla/attachment.cgi?id=549
> The demo program is a narrowed-down version of test code used in the
> GASNet communication system (http://gasnet.lbl.gov).
> 
> The test code calls pthread_create to spawn a user-controlled number
> of threads, which then execute 1000 "spin barriers" - implemented by
> spinning on in-memory flags and stalling with sched_yield(). The test
> can also optionally insert a pthread_barrier_wait() across all threads
> before the first spin barrier.

Thanks for the thorough analysis and especially the testcase!

I applied a fix for this problem and uploaded new developer snapshots
to https://cygwin.com/snapshots/

Please give them a try.


Thanks,
Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20170308/c96d7ad8/attachment.sig>


More information about the Cygwin mailing list