Re: profiling connection overhead - Mailing list pgsql-hackers

From Andres Freund
Subject Re: profiling connection overhead
Date
Msg-id 201011291849.12406.andres@anarazel.de
Whole thread Raw
In response to Re: profiling connection overhead  (Robert Haas <robertmhaas@gmail.com>)
List pgsql-hackers
On Monday 29 November 2010 18:34:02 Robert Haas wrote:
> On Mon, Nov 29, 2010 at 12:24 PM, Andres Freund <andres@anarazel.de> wrote:
> > Hm. A quick test shows that its quite a bit faster if you allocate memory
> > with:
> > size_t s = 512*1024*1024;
> > char *bss = mmap(0, s, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_POPULATE|
> > MAP_ANONYMOUS, -1, 0);
> 
> Numbers?
malloc alloc: 43
malloc memset1: 438763
malloc memset2: 98764
total: 537570

mmap alloc: 296065
mmap memset1: 99203
mmap memset2: 100608
total: 495876

But you don't actually need the memset1 in the mmap case as MAP_ANONYMOUS 
memory is already zeroed. We could actually use that knowledge even without 
MAP_POPULATE if we somehow keep track whether an allocated memory region is 
still zeroed.

Taking that into account its:

malloc alloc: 47
malloc memset1: 437819
malloc memset2: 98317
total: 536183
mmap alloc: 292904
mmap memset1: 1
mmap memset2: 99284
total: 392189


I am somewhat reluctant to believe thats the way to go.

Andres


pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: PROPOSAL of xmlvalidate
Next
From: Jeff Janes
Date:
Subject: Re: profiling connection overhead