Re: Misaligned BufferDescriptors causing major performance problems on AMD

From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Bruce Momjian <bruce(at)momjian(dot)us>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Greg Stark <stark(at)mit(dot)edu>, Peter Geoghegan <pg(at)heroku(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Misaligned BufferDescriptors causing major performance problems on AMD
Date: 2015-01-28 11:47:19
Message-ID: 20150128114719.GA6325@awork2.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2015-01-26 21:13:31 -0500, Robert Haas wrote:
> On Mon, Jan 26, 2015 at 9:08 PM, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
> >> Contrary opinions? Robert?
> >
> > I'm totally OK with further aligning just that one allocation.
>
> Of course, now that I think about it, aligning it probably works
> mostly because the size is almost exactly one cache line.

Not just almost - it's precisely 64 byte on x86-64 linux. And I think
it'll also be that on other 64bit platforms. The only architecture
dependant thing in there is the spinlock and that already can be between
1 and 4 bytes without changing the size of the struct.

> If it were any bigger or smaller, aligning it more wouldn't help.

Yea.

> So maybe we should also do something like what LWLocks do, and make a
> union between the actual structure and an appropriate array of padding
> bytes - say either 64 or 128 of them.

Hm. That's a bit bigger patch. I'm inclined to just let it slide for the
moment. I still have plans to downsize some of sbufdesc's content (move
the io lock out) and move the content lwlock inline. Then we're not
going to have much choice but do this...

Greetings,

Andres Freund

--
Andres Freund http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Stephen Frost 2015-01-28 13:15:45 Re: pg_upgrade and rsync
Previous Message Petr Jelinek 2015-01-28 10:33:55 Re: TABLESAMPLE patch