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: wrong performance of malloc/free under multi-threading


On 2/26/2013 4:14 AM, Corinna Vinschen wrote:
On Feb 26 15:35, MITSUNARI Shigeo wrote:
Hi.

I found that the performance of malloc/free is wrong under multi-threading.
The following test program reproduces the problem.

The program repeats malloc and free under multi-thread.
I measured the timing on Cygwin and Linux.

timing(sec)|      threadNum
-----------+----------+-------------
            | 1        |     2
-----------+----------+-------------
Linux      | 1.45     |     0.69
-----------+----------+-------------
Cygwin     | 2.059    |    53.165
-----------+----------+-------------

The timing under Linux seems good scale but it is very wrong under Cygwin.
Is it intentional behavior or do I use pthread in bad way?

No, you're right. This is easily reproducable. I just had a look and it seems that our malloc is really slow in multi-threading scenarios. We're using Doug Lea's malloc unchanged with just additional locks surrounding the underlying malloc/free calls.

This appears to be a serious performance problem.  I just learned that
glibc uses another version of dlmalloc, called ptmalloc, which is a
derived version of dlmalloc optimized for multi-threading environments.

Perhaps we have to do the same, but I don't know how long it takes to
port ptmalloc to Cygwin and obviously I don't know how big the
performance gain might be.


Corinna



Does any host using newlib suffer from this problem, or is it exclusive to Cygwin?


Chris

--
In theory, there's no difference between theory and practice. In practice, there is.


--
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]