pgsql: Micro-optimize GenericXLogFinish().

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Micro-optimize GenericXLogFinish().
Date: 2016-04-09 23:31:10
Message-ID: E1ap2LO-0007CY-UZ@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Micro-optimize GenericXLogFinish().

Make the inner comparison loops of computeDelta() as tight as possible by
pulling considerations of valid and invalid ranges out of the inner loops,
and extending a match or non-match detection as far as possible before
deciding what to do next. To keep this tractable, give up the possibility
of merging fragments across the pd_lower to pd_upper gap. The fraction of
pages where that could happen (ie, there are 4 or fewer bytes in the gap,
*and* data changes immediately adjacent to it on both sides) is too small
to be worth spending cycles on.

Also, avoid two BLCKSZ-length memcpy()s by computing the delta before
moving data into the target buffer, instead of after. This doesn't save
nearly as many cycles as being tenser about computeDelta(), but it still
seems worth doing.

On my machine, this patch cuts a full 40% off the runtime of
contrib/bloom's regression test.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/68689c66efcda6f217119432edfbdf95a50b26e2

Modified Files
--------------
src/backend/access/transam/generic_xlog.c | 218 +++++++++++++++++++-----------
1 file changed, 138 insertions(+), 80 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Noah Misch 2016-04-09 23:43:32 Re: [COMMITTERS] pgsql: Bloom index contrib module
Previous Message Tom Lane 2016-04-09 20:44:58 pgsql: Fix PL/Python ereport() test to work on Python 2.3.