This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Cygwin multithreading performance


Corinna Vinschen wrote:
On Nov 23 16:54, Mark Geisert wrote:
John Hein wrote:
Mark Geisert wrote at 23:45 -0800 on Nov 22, 2015:
  > Corinna Vinschen wrote:
  > > On Nov 21 01:21, Mark Geisert wrote:
  > [...] so I wonder if there's
  > >> some unintentional serialization going on somewhere, but I don't know yet
  > >> how I could verify that theory.
  > >
  > > If I'm allowed to make an educated guess, the big serializer in Cygwin
  > > are probably the calls to malloc, calloc, realloc, free.  We desperately
  > > need a new malloc implementation better suited to multi-threading.
[...]

Someone recently mentioned on this list they were working on porting
jemalloc.  That would be a good choice.

Indeed; thanks for the reminder.  Somehow I hadn't followed that thread.

Indeed^2.  Did you look into the locking any further to see if there's
more than one culprit?  I guess we've a rather long way to a "lock-less
kernel"...

It took me a while to figure out what I wanted to see in the strace logs. I ended up adding a small patch to pthread_mutex::lock() to record a timestamp on entry, and also log that in the pthread_printf() near the end of the method. With that I'm able to see how long a thread has to wait for a lock before actually acquiring it. That will allow me to unravel the sequence of locking and unlocking and give stats for all threads and/or locks. That could be generally useful to evaluate different memory allocators or different locking strategies using the same allocator.

But that is just groundwork to identifying which locks are suffering the most contention. To identify them at source level I think I'll also need to record the caller's RIP when they are being locked.

In the raw strace data I'm looking at for the OP's testcase, I can see a lot of cases where a thread wants a lock but is delayed for milliseconds before getting ahold of it. I can't say ATM whether it's just one or a few locks suffering this way, or more. Work continues :).

..mark

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]