Re: Issue with Linux+Pentium SMP Context Switching

From: Manfred Spraul <manfred(at)colorfullife(dot)com>
To: Josh Berkus <josh(at)agliodbs(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Issue with Linux+Pentium SMP Context Switching
Date: 2003-12-19 20:12:02
Message-ID: 3FE35B92.1000804@colorfullife.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Josh Berkus wrote:

> Initial debug logging of a test on one Xeon system demonstrating this issue
>showed a very large number of unattributed semop() calls. We are still
>following up on this.
>
Postgres has it's own user space spinlock and semaphore implementation.
Both fall back to semop if there is contention.

Hmm. You wrote that the problem is Xeon specific, and that AthlonMP are
unaffected. Perhaps Xeon cpus do not like the s_lock implementation? It
doesn't follow Intel's recommentations:
- no pause instructions.
- always TAS. The recommended approach is nonatomic tests until the
value is 0, then an atomic TAS.

Attached is a gross hack that adds pause instructions. If this doesn't
magically fix your problem, then we must figure out what causes the
semop calls, and avoid them.
Could you ask your Linux hackers why they blame the shared memory
implementation in postgres? I don't see any link between shared memory
and lock contention.

--
Manfred

Attachment Content-Type Size
patch-spinlock-i386 text/plain 497 bytes

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2003-12-19 20:41:07 Re: How can I return a pointer to a use structure from a function
Previous Message Chongbing Liu 2003-12-19 19:34:34 How can I return a pointer to a use structure from a function