X-Recipient: archive-cygwin@delorie.com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
	:list-unsubscribe:list-subscribe:list-archive:list-post
	:list-help:sender:mime-version:in-reply-to:references:from:date
	:message-id:subject:to:content-type; q=dns; s=default; b=DEVP7f4
	w4P4KJZCly6J97vo1N2l37xfJIZWUB0XPf7+MULEyQ5lcJl60YBk6c6rBgIr04tm
	C7/uZomVSW3hzRI2mweoHv8pwXKWEHqZQa/uImV40O0lko7rZcWql2EyQvqgTdU4
	kgfg/d/k/7/Wa8UJb7aqRv3HcUd6z4RXWNL4=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
	:list-unsubscribe:list-subscribe:list-archive:list-post
	:list-help:sender:mime-version:in-reply-to:references:from:date
	:message-id:subject:to:content-type; s=default; bh=aV8DOBuNVrZhk
	KD6ABBhvzxljP4=; b=EbrUb9vJv+eHruD6h97FcKdferpeUUVcRykIIS8Gq9XQy
	F6QrxUHRPMe5tfeiWXJqrRI7EVaBfAtKDipCsvsSJirM/oegOFWuFqz4kyjugWvV
	pjd59GY9Y0EL0a6U+0p3EvrwYUHuDB1CqBPRoHqETOs6jt0aRTGcu6eDarFmfs=
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=-1.6 required=5.0 tests=AWL,BAYES_00,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=no version=3.3.2 spammy=assist
X-HELO: mail-it0-f48.google.com
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;        d=1e100.net; s=20161025;        h=x-gm-message-state:mime-version:in-reply-to:references:from:date         :message-id:subject:to;        bh=AefSvWg6gHogW8P2Jle9wbRQH29/SVw98qjQigibev0=;        b=gBkUju06f2rTSycpJejmka0YaMIFjOOBq6UwuevCQwqWwYmzb1heqFBUWy/x9sdAxj         It0cj3TDMIPRLivo8nAyTocAj8LkZ50wpw+vlEhtajuI2xfkqlJiAx8Kp1v/o43TDnt8         fUJCHpy4WKGQCbXsnhur/0YZO2tclhik2xP79J6rdFCIdTTy0j6PPqeItt2hG4xOwkgm         ZDwcCoxiq/LQb8s4FOAry229A63LYWOKb4sgP9IUOwSvCqRa6so9UJVr4GmlCSQYxSDW         5l8jd2DJ3tgfHpfJVkwLbnwfyZs1FRVY/Tbq/ze6XnGwRnKUNw8R1ho3ucOkKrHz1jfr         /Liw==
X-Gm-Message-State: AKwxytc27tIWz8RomW3RqP0In0G/rj/gmXkDRZmYHrmCCKUttDt2yVwL	gKa/9h2EBiEeIHXfFCwPZaETkZF/Bj/xJALzPsM=
X-Google-Smtp-Source: ACJfBov2XBN9jWAfrWKjEjVKMUnVg52kfwKiCcQcMZpbvpT63/garaqsRKKoFbsFNgaj3Hk5mAx8Xj2tzaFlntKqEnA=
X-Received: by 10.36.58.11 with SMTP id m11mr7146012itm.89.1515840521729; Sat, 13 Jan 2018 02:48:41 -0800 (PST)
MIME-Version: 1.0
In-Reply-To: <3acfae95-e62b-40d5-d094-44e651dd6b79@gmail.com>
References: <CAD8GWsvxzFe0dPnxO-odTY+EG5XOAApLjcOSN5d7vXhtLW0GmQ@mail.gmail.com> <46515148-9f8e-6eae-69f9-9bf20921097a@t-online.de> <20180112143339.GE24623@calimero.vinschen.de> <b7ab3fe3-fa81-432d-33ad-9c0d7948b044@gmail.com> <20180112204149.GF24623@calimero.vinschen.de> <3acfae95-e62b-40d5-d094-44e651dd6b79@gmail.com>
From: Lee <ler762@gmail.com>
Date: Sat, 13 Jan 2018 05:48:40 -0500
Message-ID: <CAD8GWsudgtkQJe=EuXj+VT=PiJpF8kwHPR=zidMutDc_EajJwQ@mail.gmail.com>
Subject: Re: calloc speed difference
To: cygwin@cygwin.com
Content-Type: text/plain; charset="UTF-8"
X-IsSubscribed: yes

On 1/12/18, cyg Simple  wrote:
> On 1/12/2018 3:41 PM, Corinna Vinschen wrote:
>> On Jan 12 14:59, cyg Simple wrote:
>>> On 1/12/2018 9:33 AM, Corinna Vinschen wrote:
>>>> On Jan 12 15:06, Christian Franke wrote:
>>>>> Timing [cm]alloc() calls without actually using the allocated memory
>>>>> might
>>>>> produce misleading results due to lazy page allocation and/or
>>>>> zero-filling.
>>>>>
>>>>> MinGW binaries use calloc() from msvcrt.dll. This calloc() does not
>>>>> call
>>>>> malloc() and then memset(). It directly calls:
>>>>>
>>>>>   mem = HeapAlloc(_crtheap, HEAP_ZERO_MEMORY, size);
>>>>>
>>>>> which possibly only reserves allocate-and-zero-fill-on-demand pages
>>>>> for
>>>>> later.
>>>>>
>>>>> Cygwin's calloc() is different.
>>>>
>>>> But then again, Cygwin's malloc *is* slow, particulary in
>>>> memory-demanding multi-threaded scenarios since that serializes all
>>>> malloc/free calls.
>>>>
>>>> The memory handling within Cygwin is tricky.  Attempts to replace good
>>>> old dlmalloc with a fresher jemalloc or ptmalloc failed, but that only
>>>> means the developer (i.e., me, in case of ptmalloc) was too lazy...
>>>> busy! I mean busy... to pull this through.
>>>>
>>>> Having said that, if somebody would like to take a stab at replacing
>>>> dlmalloc with something leaner, I would be very happy and assist as
>>>> much as I can.
>>>
>>> Corina, how reliable is the Cygwin time function on a non-Cygwin
>>> executable?  Isn't this a comparison of apples to oranges?

The wall-clock time seems reliable.  Timing a non-Cygwin executable
gives you 0.0 for the user & sys categories but I don't care about
them anywhere near as much as how long it takes for the program to
run.

>> I wasn't comparing, in fact.  I was just saying that Cygwin's malloc
>> is slow, partially because dlmalloc is not the fastest one, partially
>> due to the serialization overhead in multithreading scenarios.
>
> No, but the OP *is* doing a compare.  From what I remember doing a time
> comparison of a non-Cygwin app compared to a Cygwin app isn't really a
> logical comparison.

I'm probably missing something, but.. I have the source code.  I have
the choice of using the cygwin gcc compiler or the mingw cross
compiler.  If both executables produce the same results then comparing
execution times seems perfectly valid.

On the other hand, if the program produces text output (ie. dos vs.
unix line endings) then dealing with dos line endings in the cygwin
environment might be enough of a pain that I accept the ease-of-use
vs. execution time tradeoff and keep everything compatible w/ cygwin.

>  Even if the two were a Cygwin app multiple runs of
> the same app will show variance.

But not the seconds vs. minutes difference that I occasionally see
when comparing cygwin vs. native app performance.

Regards,
Lee

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

