Re: Wierd context-switching issue on Xeon
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Greg Stark <gsstark@mit.edu>
Cc: lutzeb@aeccom.com, Josh Berkus <josh@agliodbs.com>, pgsql-performance@postgresql.org, Neil Conway <neilc@samurai.com>
Date: 2004-04-19T02:30:08Z
Lists: pgsql-performance
Greg Stark <gsstark@mit.edu> writes: > There's nothing about the way Postgres spinlocks are coded that affects this? No. AFAICS our spinlock sequences are pretty much equivalent to the way the Linux kernel codes its spinlocks, so there's no deep dark knowledge to be mined there. We could possibly use some more-efficient blocking mechanism than semop() once we've decided we have to block (it's a shame Linux still doesn't have cross-process POSIX semaphores). But the striking thing I learned from looking at the oprofile results is that most of the inefficiency comes at the very first TAS() operation, before we've even "spun" let alone decided we have to block. The s_lock() subroutine does not account for more than a few percent of the runtime in these tests, compared to 15% at the inline TAS() operations in LWLockAcquire and LWLockRelease. I interpret this to mean that once it's acquired ownership of the cache line, a Xeon can get through the "spinning" loop in s_lock() mighty quickly. regards, tom lane