Hi Vadim!

On Thu, Sep 12, 2013 at 11:16 AM, Vadim <> wrote:
> On Thu, Sep 12, 2013 at 9:32 AM, K. Frank <> wrote:
>>
>> Hello Kai and Vadim!
>> ...
>> > 2013/9/12 Vadim <>:
>> >> Hi,
>> >> I am investigating performance problems in binary compiled with
>> >> mingw-w64,
>> >> and libwinpthreads mutex comes at the top of my profile.
>> >> ...
>> Just some background comments -- not directly relevant to
>> mingw-w64:
>> ...
>> I experimented with using both windows mutexes and windows
>> critical sections for implementing std::thread with mingw-w64;
>> not surprisingly, the critical-section version was significantly
>> faster, at least when it came to creating a lot of std::mutex
>> objects.
>
> Precisely.  In the absence of contention, critical sections can be up to
> sever hundred times faster than kernel mutexes.
>> ...
>> Two down-sides I found with windows critical sections:  They are
>> relatively recent -- I think Vista and later.  (I didn't really care
>> about this.)
>
> They've been around since win95.   In Vista they were modified such that
> InitializeCriticalSection will not fail under low-memory conditions.

Thanks, I didn't know that.

>  ...
>> Happy Pthreads Hacking!
>
> Before we embark on that, I'd like to clarify a couple more things:
>
> 1. Have you guys considered adopting/forking phtreads-win32?  I believe this
> is what the regular mingw uses.  That library looks more mature, at least as
> far as mutexes go.

Let me speak beyond my competence here ...  (Kai, please correct
me if I have anything wrong.)

There are possibly two issues:

I think that pthreads-win32 has a less flexible license.  I think one
reason for winpthreads is to offer users a more flexible license.
(Maybe they don't have to ship source code for pthreads-win32,
or something.)

I do know that there is an issue with thread handles.  pthreads handles
are officially opaque, however the historical unix / linux pthreads
implementations all (nearly all?) used integral handles.  pthreads-win32,
on the other hand, uses a structure for the handle (which I think it is, in
principle, allowed to do).

However, as I understand it from Kai, lots and lots of software that
uses pthreads makes use of the fact that pthreads handles are
integral values.  (I know, for example, that gcc's pthreads version
of std::thread makes this assumption.)  So pthreads-win32 breaks
this code.  (Technically this code is non-compliant, but still, it's
better not to break it if you don't have to.)

So I believe that one of Kai's key motivations for winpthreads was
to have it use integral thread handles to be consistent with unix /
linux implementations.

There may be other issues, but licensing and integral handles are
the two that I'm aware of.

> ...
> Vadim


Best.


K. Frank

------------------------------------------------------------------------------
How ServiceNow helps IT people transform IT departments:
1. Consolidate legacy IT systems to a single system of record for IT
2. Standardize and globalize service processes across IT
3. Implement zero-touch automation to replace manual, redundant tasks
http://pubads.g.doubleclick.net/gampad/clk?id=51271111&iu=/4140/ostg.clktrk
_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to