Re: Delaying/avoiding BTreeTupleGetNAtts() call within _bt_compare()

From: Peter Geoghegan <pg(at)bowt(dot)ie>
To: Floris Van Nee <florisvannee(at)optiver(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Andres Freund <andres(at)anarazel(dot)de>
Subject: Re: Delaying/avoiding BTreeTupleGetNAtts() call within _bt_compare()
Date: 2020-01-28 22:55:41
Message-ID: CAH2-Wz=6JudYYijcbSg8ooVk3DsxS7FDUP6mw5V3UJUh_pKwMA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Jan 28, 2020 at 1:34 PM Floris Van Nee <florisvannee(at)optiver(dot)com> wrote:
> With Andres' instructions I ran a couple of tests. With your patches I can reproduce a speedup of ~3% on single core tests reliably on a dual-socket 36-core machine for the pgbench select-only test case.

Thanks for testing!

Attached is v2 of patch series, which makes the changes to 0001-*
requested by Andres. I restructured the loop in a way that allows the
compiler to assume that there will always be at least one loop
iteration -- so I'm not quite as aggressive as I was with v1. We don't
actually delay the call to BTreeTupleGetNAtts() as such in v2.

Can you test this version, Floris? The second two patches are probably
not helping here, so it would be useful if you could just test 0001-*,
and then test all three together. I can toss the latter two patches if
there is no additional speedup.

If we're lucky, then Andres will have been right to suspect that there
might be a smaller stall caused by the new branch in the loop that
existed in v1. Maybe this will show up at higher client counts.

I should point out that the deduplication patch changes the definition
of BTreeTupleGetNAtts(), making it slightly more complicated. With the
deduplication patch, we have to check that the tuple isn't a posting
list tuple, which uses the INDEX_ALT_TID_MASK/INDEX_AM_RESERVED_BIT
bit to indicate a non-standard tuple header format, just like the
current pivot tuple format (we need to check a BT_RESERVED_OFFSET_MASK
bit to further differentiate posting list tuples from pivot tuples).
This increase in the complexity of BTreeTupleGetNAtts() will probably
further tip things in favor of this patch.

There are no changes in either 0002-* or 0003-* patches for v2. I'm
including the same patches here a second time for completeness.

--
Peter Geoghegan

Attachment Content-Type Size
v2-0003-Remove-negative-infinity-check-from-_bt_compare.patch application/x-patch 2.9 KB
v2-0002-Inline-_bt_compare.patch application/x-patch 2.6 KB
v2-0001-Avoid-pipeline-stall-in-_bt_compare.patch application/x-patch 1.7 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Willis 2020-01-28 23:02:27 psqlODBC development
Previous Message Thomas Munro 2020-01-28 22:54:23 Re: [HACKERS] kqueue