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

From: "Dickson S(dot) Guedes" <listas(at)guedesoft(dot)net>
To: Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgreSQL(dot)org>
Subject: Re: Better LWLocks with compare-and-swap (9.4)
Date: 2013-05-18 00:52:25
Message-ID: 5196D0C9.8010200@guedesoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

-----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
> compare-and-swap instruction for the contention-critical part.
>
> I realized that we could also use compare-and-swap to make LWLocks
> scale better. The LWLock struct is too large to compare-and-swap
> atomically, but we can still use CAS to increment/decrement the
> shared/exclusive counters, when there's no need to manipulate the
> wait queue. That would help with workloads where you have a lot of
> CPUs, and a lot of backends need to acquire the same lwlock in
> shared mode, but there's no real contention (ie. few exclusive
> lockers).
>
> 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% GetSnapshotData - 46.78%
> LWLockRelease GetSnapshotData + GetTransactionSnapshot + 2.97%
> postgres postgres [.] tas + 1.53% postgres
> libc-2.13.so [.] 0x119873 + 1.44% postgres postgres
> [.] GetSnapshotData + 1.29% postgres [kernel.kallsyms] [k]
> arch_local_irq_enable + 1.18% postgres postgres [.]
> AllocSetAlloc ...

I'd like to test this here but I couldn't reproduce that perf output
here in a 64-core or 24-core machines, could you post the changes to
postgresql.conf and the perf arguments that you used?

Thanks!

[]s
- --
Dickson S. Guedes
mail/xmpp: guedes(at)guedesoft(dot)net - skype: guediz
http://guedesoft.net - http://www.postgresql.org.br
http://github.net/guedes - twitter: @guediz
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJRltDJAAoJEBa5zL7BI5C7UQkH/Au8p90pTMl1qvbft3q1Gtxp
a4PV8fjOrzQou2I+9Sxu5W1ql3qyVmfFare+bJVKg5L3LmvACjZ6bbw9oKBEnPGB
vzE9nB6+3F3eyo464Niq19cTVgmyRQBcuOT/Ye88Uh2mrrgUYB+lGfk9M2Af7on1
nUZI5YsWWXt/bm9wf6rRCzDs76fS7ity943V0aSg2AHryjfcB8o4oBhJBnrRfnm7
v+SxLg0xDEWQPo8VOCQlIw5IhoxNokHjMAt8Ho7o0dXJRR91vSerdulK4Uxkz13Q
E9GlDBDBzZsHmqHCGECNSglqVegXRA5g2i/o3tmQ/lEKzCF9OiX7GBSkXN+gEsc=
=nGJ5
-----END PGP SIGNATURE-----

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Liming Hu 2013-05-18 03:57:14 Re: request a new feature in fuzzystrmatch
Previous Message Nicolas Barbier 2013-05-17 21:53:32 Re: counting algorithm for incremental matview maintenance