Re: calloc speed difference
- Date: Sat, 13 Jan 2018 05:48:40 -0500
- From: Lee <ler762@xxxxxxxxx>
- Subject: Re: calloc speed difference
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
>>>>> produce misleading results due to lazy page allocation and/or
>>>>> MinGW binaries use calloc() from msvcrt.dll. This calloc() does not
>>>>> 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
>>>>> 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
>> 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.
Problem reports: http://cygwin.com/problems.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple