Re: Possible performance regression in version 10.1 with pgbench read-write tests.
Thomas Munro <thomas.munro@enterprisedb.com>
From: Thomas Munro <thomas.munro@enterprisedb.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Alvaro Herrera <alvherre@2ndquadrant.com>,
Amit Kapila <amit.kapila16@gmail.com>, Robert Haas <robertmhaas@gmail.com>, Mithun Cy <mithun.cy@enterprisedb.com>, pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2018-07-20T05:22:17Z
Lists: pgsql-hackers
On Fri, Jul 20, 2018 at 7:56 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Alvaro Herrera <alvherre@2ndquadrant.com> writes:
>> On 2018-Jul-19, Amit Kapila wrote:
>>> It appears so. I think we should do something about it as the
>>> regression is quite noticeable.
>
> It's not *that* noticeable, as I failed to demonstrate any performance
> difference before committing the patch. I think some more investigation
> is warranted to find out why some other people are getting different
> results.
Maybe false sharing is a factor, since sizeof(sem_t) is 32 bytes on
Linux/amd64 and we're probably hitting elements clustered at one end
of the array? Let's see... I tried sticking padding into
PGSemaphoreData and I got ~8% more TPS (72 client on multi socket
box, pgbench scale 100, only running for a minute but otherwise the
same settings that Mithun showed).
--- a/src/backend/port/posix_sema.c
+++ b/src/backend/port/posix_sema.c
@@ -45,6 +45,7 @@
typedef struct PGSemaphoreData
{
sem_t pgsem;
+ char padding[PG_CACHE_LINE_SIZE - sizeof(sem_t)];
} PGSemaphoreData;
That's probably not the right idiom and my tests probably weren't long
enough, but there seems to be some effect here.
--
Thomas Munro
http://www.enterprisedb.com
Commits
-
Pad semaphores to avoid false sharing.
- 46201d603f9c 10.5 landed
- f2db5f3bb0b5 11.0 landed
- 2d3067595299 12.0 landed