delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2013/02/26/04:14:48

X-Recipient: archive-cygwin AT delorie DOT com
X-Spam-Check-By: sourceware.org
Date: Tue, 26 Feb 2013 10:14:03 +0100
From: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: wrong performance of malloc/free under multi-threading
Message-ID: <20130226091403.GB2388@calimero.vinschen.de>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <2265626 DOT 1033831361860540947 DOT herumi AT nifty DOT com>
MIME-Version: 1.0
In-Reply-To: <2265626.1033831361860540947.herumi@nifty.com>
User-Agent: Mutt/1.5.21 (2010-09-15)
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

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

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019