X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 719CFD1B579 for ; Sun, 18 Apr 2004 23:30:12 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 10407-02 for ; Sun, 18 Apr 2004 23:30:15 -0300 (ADT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 5D9BDD1B515 for ; Sun, 18 Apr 2004 23:30:09 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i3J2U9eT014057; Sun, 18 Apr 2004 22:30:09 -0400 (EDT) To: Greg Stark Cc: lutzeb@aeccom.com, Josh Berkus , pgsql-performance@postgresql.org, Neil Conway Subject: Re: Wierd context-switching issue on Xeon In-reply-to: <87d6647qbg.fsf@stark.xeocode.com> References: <200311251419.36771.josh@agliodbs.com> <200404151039.17763.josh@agliodbs.com> <407EE93F.3090705@aeccom.com> <200404151335.27762.josh@agliodbs.com> <407EFC95.5070805@aeccom.com> <11437.1082324861@sss.pgh.pa.us> <87d6647qbg.fsf@stark.xeocode.com> Comments: In-reply-to Greg Stark message dated "18 Apr 2004 20:40:35 -0400" Date: Sun, 18 Apr 2004 22:30:08 -0400 Message-ID: <14056.1082341808@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200404/256 X-Sequence-Number: 6556 Greg Stark 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