pgsql: Micro-optimize GenericXLogFinish(). - Mailing list pgsql-committers

From Tom Lane
Subject pgsql: Micro-optimize GenericXLogFinish().
Date
Msg-id E1ap2LO-0007CY-UZ@gemulon.postgresql.org
Whole thread Raw
List 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(-)


pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: pgsql: Fix PL/Python ereport() test to work on Python 2.3.
Next
From: Tom Lane
Date:
Subject: pgsql: Further minor improvement in generic_xlog.c: always say REGBUF_S