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:reply-to:subject:to:references:from:message-id :date:mime-version:in-reply-to:content-type :content-transfer-encoding; q=dns; s=default; b=rPdNP1wbmHmpa2kr ul8kDWAvqwjR/EsCg/4Ft44Rev8ry316JjjgFQqz2Xo1DIUzMaZAJGG1Oa0xm7Fr qYnxnkbRPRWnnsAQ/SsJagIafI4Gzgc5kcwImN9GhRMMNvjr26Fn38mVWWPwzpx0 2fE+gGP7JGgb0bIdxHSYax0Uzzk= 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:reply-to:subject:to:references:from:message-id :date:mime-version:in-reply-to:content-type :content-transfer-encoding; s=default; bh=NX/w5cdvr414aljFiK8/pj og+fI=; b=vT0CssMW7rNPIUIgV41tppWdINWtrdDPossXn0SVGHxn7m8mgz6TIy 8xCkiUR1V7fMiNiAUf3Zy3XXbxWog03M0DQJZq9/kKR/b1LDRoosyvMsjxV79h6l PvyFeceeMeGpra1KQca6R5VnOfkzLQiBVf86f00Aafq75Am2y7E9E= Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , 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=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=210s, 310s, HContent-Transfer-Encoding:8bit X-HELO: mailsrv.cs.umass.edu Reply-To: moss AT cs DOT umass DOT edu Subject: Re: calloc speed difference To: cygwin AT cygwin DOT com References: <46515148-9f8e-6eae-69f9-9bf20921097a AT t-online DOT de> From: Eliot Moss Message-ID: Date: Fri, 12 Jan 2018 17:00:24 -0500 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: <46515148-9f8e-6eae-69f9-9bf20921097a@t-online.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-IsSubscribed: yes Note-from-DJ: This may be spam On 1/12/2018 9:06 AM, Christian Franke wrote: > This variant of the above code adds one write access to each 4KiB page (guarded by "volatile" to > prevent dead assignment optimization): > > #include > #include > #define ALLOCATION_SIZE (100 * 1024 * 1024) > int main (int argc, char *argv[]) { >     for (int i = 0; i < 1000; i++) { >         void *temp = calloc(ALLOCATION_SIZE, 1); >         if ( temp == NULL ) { >            printf("drat! calloc returned NULL\n"); >            return 1; >         } >         for (int j = 0; j < ALLOCATION_SIZE; j += 4096) >           ((volatile char *)temp)[j] = (char)i; >         free(temp); >     } >     return 0; > } > > Results: > > Cygwin: ~310s > MinGW: ~210s Good analysis! There remains a lot of room for improvement, but this shows good reasons to dig deeper to understand what goes on with large allocations. EM -- 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