pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Manfred Spraul <manfred@colorfullife.com>
To: Marc Colosimo <mcolosimo@mitre.org>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-hackers@postgresql.org
Subject: Re: tweaking MemSet() performance - 7.4.5
Date: Sat, 18 Sep 2004 17:38:36 +0200
Message-ID: <414C567C.3060503@colorfullife.com> (raw)
In-Reply-To: <E60A72E0-08E7-11D9-B617-000A95A5D8B2@mitre.org>
References: <8A6E7DA4-0654-11D9-800C-000A95A5D8B2@mitre.org>
	<24165.1095450900@sss.pgh.pa.us>
	<E60A72E0-08E7-11D9-B617-000A95A5D8B2@mitre.org>

Marc Colosimo wrote:

> Oops, I used the same setting as in the old hacking message (-O2, gcc 
> 3.3). If I understand what you are saying, then it turns out yes, PG's 
> MemSet is faster for smaller blocksizes (see below, between 32 and 
> 64). I just replaced the whole MemSet with memset and it is not very 
> low when I profile.

Could you check what the OS-X memset function does internally?
One trick to speed up memset it to bypass the cache and bulk-write 
directly from write buffers to main memory. i386 cpus support that and 
in microbenchmarks it's 3 times faster (or something like that). 
Unfortunately it's a loss in real-world tests: Typically a structure is 
initialized with memset and then immediately accessed. If the memset 
bypasses the cache then the following access will cause a cache line 
miss, which can be so slow that using the faster memset can result in a 
net performance loss.

> I could squeeze more out of it if I spent more time trying to 
> understand it (change MEMSET_LOOP_LIMIT to 32 and then add memset 
> after that?). I'm now working one understanding  Spin Locks and 
> friends. Putting in a sync call (in s_lock.h) is really a time killer 
> and bad for performance (it takes up 35 cycles).
>
That's the price you pay for weakly ordered memory access.
Linux on ppc uses eieio, on ppc64 lwsync is used. Could you check if 
they are faster?

--
    Manfred



view thread (13+ messages)  latest in thread

Message-ID: <414C567C.3060503@colorfullife.com>
Permalink:  ../414C567C.3060503@colorfullife.com/
Also on:    postgresql.org/message-id/414C567C.3060503@colorfullife.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: manfred@colorfullife.com, mcolosimo@mitre.org, tgl@sss.pgh.pa.us
  Subject: Re: tweaking MemSet() performance - 7.4.5
  In-Reply-To: <414C567C.3060503@colorfullife.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox