Re: Spinlock implementation on x86_64 (was Re: [HACKERS] Better LWLocks with compare-and-swap (9.4))

2013-08-29 Thread Heikki Linnakangas
On 28.08.2013 20:21, Tom Lane wrote: Heikki Linnakangashlinnakan...@vmware.com writes: So, my plan is to apply the attached non-locked-tas-spin-x86_64.patch to master. But I would love to get feedback from people running different x86_64 hardware. Surely this patch should update the existing

Spinlock implementation on x86_64 (was Re: [HACKERS] Better LWLocks with compare-and-swap (9.4))

2013-08-28 Thread Heikki Linnakangas
On 21.05.2013 00:20, Heikki Linnakangas wrote: On 16.05.2013 01:08, Daniel Farina wrote: On Mon, May 13, 2013 at 5:50 AM, Heikki Linnakangas hlinnakan...@vmware.com wrote: pgbench -S is such a workload. With 9.3beta1, I'm seeing this profile, when I run pgbench -S -c64 -j64 -T60 -M prepared on

Re: Spinlock implementation on x86_64 (was Re: [HACKERS] Better LWLocks with compare-and-swap (9.4))

2013-08-28 Thread Tom Lane
Heikki Linnakangas hlinnakan...@vmware.com writes: So, my plan is to apply the attached non-locked-tas-spin-x86_64.patch to master. But I would love to get feedback from people running different x86_64 hardware. Surely this patch should update the existing comment at line 209? Or at least

Re: [HACKERS] Better LWLocks with compare-and-swap (9.4)

2013-05-20 Thread Dickson S. Guedes
Em Dom, 2013-05-19 às 09:29 +0300, Heikki Linnakangas escreveu: On 18.05.2013 03:52, Dickson S. Guedes wrote: pgbench -S is such a workload. With 9.3beta1, I'm seeing this profile, when I run pgbench -S -c64 -j64 -T60 -M prepared on a 32-core Linux machine: - 64.09% postgres postgres

Re: [HACKERS] Better LWLocks with compare-and-swap (9.4)

2013-05-20 Thread Andres Freund
On 2013-05-20 09:31:15 -0300, Dickson S. Guedes wrote: Hum, I was supposing that I was doing something wrong but I'm getting the same result as before even using your test case and my results is still different from yours: + 71,27% postgres postgres [.] AtEOXact_Buffers + 7,67%

Re: [HACKERS] Better LWLocks with compare-and-swap (9.4)

2013-05-20 Thread Dickson S. Guedes
Em Seg, 2013-05-20 às 14:35 +0200, Andres Freund escreveu: On 2013-05-20 09:31:15 -0300, Dickson S. Guedes wrote: Hum, I was supposing that I was doing something wrong but I'm getting the same result as before even using your test case and my results is still different from yours: +

Re: [HACKERS] Better LWLocks with compare-and-swap (9.4)

2013-05-20 Thread Heikki Linnakangas
On 13.05.2013 17:21, Merlin Moncure wrote: On Mon, May 13, 2013 at 7:50 AM, Heikki Linnakangas hlinnakan...@vmware.com wrote: The attached patch is still work-in-progress. There needs to be a configure test and fallback to spinlock if a CAS instruction is not available. I used the gcc

Re: [HACKERS] Better LWLocks with compare-and-swap (9.4)

2013-05-20 Thread Bruce Momjian
On Thu, May 16, 2013 at 12:08:40PM -0400, Tom Lane wrote: Stephen Frost sfr...@snowman.net writes: Isn't this the same issue which has prompted multiple people to propose (sometimes with code, as I recall) to rip out our internal spinlock system and replace it with kernel-backed calls which

Re: [HACKERS] Better LWLocks with compare-and-swap (9.4)

2013-05-20 Thread Alvaro Herrera
diff --git a/configure.in b/configure.in index 4ea5699..ff8470e 100644 --- a/configure.in +++ b/configure.in @@ -1445,17 +1445,6 @@ fi AC_CHECK_FUNCS([strtoll strtoq], [break]) AC_CHECK_FUNCS([strtoull strtouq], [break]) -AC_CACHE_CHECK([for builtin locking functions],

Re: [HACKERS] Better LWLocks with compare-and-swap (9.4)

2013-05-20 Thread Heikki Linnakangas
On 20.05.2013 23:01, Bruce Momjian wrote: On Thu, May 16, 2013 at 12:08:40PM -0400, Tom Lane wrote: Stephen Frostsfr...@snowman.net writes: Isn't this the same issue which has prompted multiple people to propose (sometimes with code, as I recall) to rip out our internal spinlock system and

Re: [HACKERS] Better LWLocks with compare-and-swap (9.4)

2013-05-20 Thread Heikki Linnakangas
On 20.05.2013 23:11, Alvaro Herrera wrote: diff --git a/configure.in b/configure.in index 4ea5699..ff8470e 100644 --- a/configure.in +++ b/configure.in @@ -1445,17 +1445,6 @@ fi AC_CHECK_FUNCS([strtoll strtoq], [break]) AC_CHECK_FUNCS([strtoull strtouq], [break]) -AC_CACHE_CHECK([for

Re: [HACKERS] Better LWLocks with compare-and-swap (9.4)

2013-05-20 Thread Bruce Momjian
On Mon, May 20, 2013 at 11:16:41PM +0300, Heikki Linnakangas wrote: On 20.05.2013 23:01, Bruce Momjian wrote: On Thu, May 16, 2013 at 12:08:40PM -0400, Tom Lane wrote: Stephen Frostsfr...@snowman.net writes: Isn't this the same issue which has prompted multiple people to propose (sometimes

Re: [HACKERS] Better LWLocks with compare-and-swap (9.4)

2013-05-20 Thread Heikki Linnakangas
On 16.05.2013 01:08, Daniel Farina wrote: On Mon, May 13, 2013 at 5:50 AM, Heikki Linnakangas hlinnakan...@vmware.com wrote: pgbench -S is such a workload. With 9.3beta1, I'm seeing this profile, when I run pgbench -S -c64 -j64 -T60 -M prepared on a 32-core Linux machine: - 64.09% postgres

Re: [HACKERS] Better LWLocks with compare-and-swap (9.4)

2013-05-19 Thread Heikki Linnakangas
On 18.05.2013 03:52, Dickson S. Guedes wrote: pgbench -S is such a workload. With 9.3beta1, I'm seeing this profile, when I run pgbench -S -c64 -j64 -T60 -M prepared on a 32-core Linux machine: - 64.09% postgres postgres [.] tas - tas - 99.83% s_lock - 53.22% LWLockAcquire + 99.87%

Re: [HACKERS] Better LWLocks with compare-and-swap (9.4)

2013-05-17 Thread Dickson S. Guedes
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Em 13-05-2013 09:50, Heikki Linnakangas escreveu: I've been working on-and-off on the WAL-insert scaling patch. It's in pretty good shape now, and I'll post it shortly, but one thing I noticed is that it benefits a lot from using an atomic

Re: [HACKERS] Better LWLocks with compare-and-swap (9.4)

2013-05-16 Thread Stephen Frost
* Heikki Linnakangas (hlinnakan...@vmware.com) wrote: My theory is that after that point all the cores are busy, and processes start to be sometimes context switched while holding the spinlock, which kills performance. Has anyone else seen that pattern? Isn't this the same issue which has

Re: [HACKERS] Better LWLocks with compare-and-swap (9.4)

2013-05-16 Thread Tom Lane
Stephen Frost sfr...@snowman.net writes: Isn't this the same issue which has prompted multiple people to propose (sometimes with code, as I recall) to rip out our internal spinlock system and replace it with kernel-backed calls which do it better, specifically by dealing with issues like the

Re: [HACKERS] Better LWLocks with compare-and-swap (9.4)

2013-05-15 Thread Daniel Farina
On Mon, May 13, 2013 at 5:50 AM, Heikki Linnakangas hlinnakan...@vmware.com wrote: pgbench -S is such a workload. With 9.3beta1, I'm seeing this profile, when I run pgbench -S -c64 -j64 -T60 -M prepared on a 32-core Linux machine: - 64.09% postgres postgres [.] tas - tas

Re: [HACKERS] Better LWLocks with compare-and-swap (9.4)

2013-05-15 Thread Daniel Farina
On Wed, May 15, 2013 at 3:08 PM, Daniel Farina dan...@heroku.com wrote: On Mon, May 13, 2013 at 5:50 AM, Heikki Linnakangas hlinnakan...@vmware.com wrote: pgbench -S is such a workload. With 9.3beta1, I'm seeing this profile, when I run pgbench -S -c64 -j64 -T60 -M prepared on a 32-core Linux

[HACKERS] Better LWLocks with compare-and-swap (9.4)

2013-05-13 Thread Heikki Linnakangas
I've been working on-and-off on the WAL-insert scaling patch. It's in pretty good shape now, and I'll post it shortly, but one thing I noticed is that it benefits a lot from using an atomic compare-and-swap instruction for the contention-critical part. I realized that we could also use

Re: [HACKERS] Better LWLocks with compare-and-swap (9.4)

2013-05-13 Thread Merlin Moncure
On Mon, May 13, 2013 at 7:50 AM, Heikki Linnakangas hlinnakan...@vmware.com wrote: The attached patch is still work-in-progress. There needs to be a configure test and fallback to spinlock if a CAS instruction is not available. I used the gcc __sync_val_compare_and_swap() builtin directly, that