delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2018/01/12/09:33:56

X-Recipient: archive-cygwin AT delorie DOT 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:date:from:to:subject:message-id:reply-to
:references:mime-version:content-type:in-reply-to; q=dns; s=
default; b=n3sZJUrlFhiRL+ytasZTSKA0mnAnT2PbwGHGW8LoZlDb9GL2vYSfX
b9qlNb9v8mMtBmifEkZGaK89eyt/haPXMR9w4hsMgZqK++anD7ux4AYN/hRspsaV
jXlwR3qf43fjonwN52Yk3LRPTeFjB5PWHCMaIITtiGV1WtBLkePy1s=
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:date:from:to:subject:message-id:reply-to
:references:mime-version:content-type:in-reply-to; s=default;
bh=k+tO1khzIoU/Ga8nhdf9dKuAeAg=; b=jcMebW9+y+SQyttHqoNf5Tjuf6zM
H9FVCWVipwa7sBQ2Cyf6LJToFBQiHrE6YJ/ACXBvBl+a04TGGkG6HlMVewKiIhAR
DR+RHLQg4cgXUOhkp45u5tXZiyGTouiNtugNfInLZyNX7zwBQTqrwd8p5BplGdiz
lgV/Y+SGUlEzqmo=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.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
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=-99.1 required=5.0 tests=AWL,BAYES_05,GOOD_FROM_CORINNA_CYGWIN,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_BRBL_LASTEXT,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=busy, reserves, zerofilling, i72600k
X-HELO: drew.franken.de
Date: Fri, 12 Jan 2018 15:33:39 +0100
From: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: calloc speed difference
Message-ID: <20180112143339.GE24623@calimero.vinschen.de>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <CAD8GWsvxzFe0dPnxO-odTY+EG5XOAApLjcOSN5d7vXhtLW0GmQ AT mail DOT gmail DOT com> <46515148-9f8e-6eae-69f9-9bf20921097a AT t-online DOT de>
MIME-Version: 1.0
In-Reply-To: <46515148-9f8e-6eae-69f9-9bf20921097a@t-online.de>
User-Agent: Mutt/1.9.1 (2017-09-22)

--RnlQjJ0d97Da+TV1
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Jan 12 15:06, Christian Franke wrote:
> Lee wrote:
> > Why is the cygwin gcc calloc so much slower than the
> > i686-w64-mingw32-gcc calloc?
> >    1:12 vs 0:11
> >=20
> > $cat calloc-test.c
> > #include <stdio.h>
> > #include <stdlib.h>
> > #define ALLOCATION_SIZE (100 * 1024 * 1024)
> > int main (int argc, char *argv[]) {
> >      for (int i =3D 0; i < 10000; i++) {
> >          void *temp =3D calloc(ALLOCATION_SIZE, 1);
> >          if ( temp =3D=3D NULL ) {
> >             printf("drat! calloc returned NULL\n");
> >             return 1;
> >          }
> >          free(temp);
> >      }
> >      return 0;
> > }
> >=20
>=20
> Could reproduce the difference on an older i7-2600K machine:
>=20
> Cygwin: ~20s
> MinGW: ~4s
>=20
> Timing [cm]alloc() calls without actually using the allocated memory might
> produce misleading results due to lazy page allocation and/or zero-fillin=
g.
>=20
> MinGW binaries use calloc() from msvcrt.dll. This calloc() does not call
> malloc() and then memset(). It directly calls:
>=20
>   mem =3D HeapAlloc(_crtheap, HEAP_ZERO_MEMORY, size);
>=20
> which possibly only reserves allocate-and-zero-fill-on-demand pages for
> later.
>=20
> 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.


Corinna

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

--RnlQjJ0d97Da+TV1
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----

iQIzBAEBCAAdFiEEoVYPmneWZnwT6kwF9TYGna5ET6AFAlpYx0MACgkQ9TYGna5E
T6DB/g/9EHqVffSQL9YzEex8xo3m/f6wfh4ua/yKkass6YAvFFcWeSln04x0adfp
xuklqxXadPHW7B4+Z8Smc9M5EeO63ZEEh++8ryEqrjzSI0GC/j+IKVsLRj/IWmty
6oAXXi4FXZLvDcb8b1ivYmuELE5/cvfMAqQY7esp1b4TYJJuxIzJy4hba4NH5JHx
3Z4rWXT+76+Cghcn7FiecjYAUecGaAD9r9AElT3JQcBuOd6aRac+2jke5PDJ90ue
rHH0Ce862RDatMwvL/TXABiaYEr5fDrGYr118vJw2VbwuqEQm+WePHG/T6tNRGsQ
Yhncrvtz0V7PxXwspQjXEQ8qD96lKVotWJt/QeoG9g818Z3/b7V59Np9NiGZEtBe
gGYqQYKgoSeWTmojalNHsE09AhHwkj3XqGf2MQd5o+lbeYpbkgQeEcybt4kPHiOy
bjVvopBkMXM905vzi4L8N7RtgTAsYSLlbgJVnF2Ntlh3ZDLAHp/JlN/G6YbJkCKn
u33MA88nGPqKSZoEKsfpbDKpuCTBfRl5rdoss5rr5LuMXT4tT2Y2rUUmicpwPkoT
yfRT3uHYvikuEDixZWdb5idmOiOZL9RRes6qI1mNavJiR5axgGiFr0RL4qt2uohn
UMlNniLsgFUKaKUGNcKC9yBVJER8547C+A+7ih/RPVRN4rfcDWg=
=LcJB
-----END PGP SIGNATURE-----

--RnlQjJ0d97Da+TV1--

- Raw text -


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