pgsql: Optimize sifting down in binaryheap. - Mailing list pgsql-committers

From Nathan Bossart
Subject pgsql: Optimize sifting down in binaryheap.
Date
Msg-id E1t6BZJ-003AmX-1k@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Optimize sifting down in binaryheap.

Presently, each iteration of the loop in sift_down() will perform
3 comparisons if both children are larger than the parent node (2
for comparing each child to the parent node, and a third to compare
the children to each other).  By first comparing the children to
each other and then comparing the larger child to the parent node,
we can accomplish the same thing with just 2 comparisons (while
also not affecting the number of comparisons in any other case).

Author: ChangAo Chen
Reviewed-by: Robert Haas
Discussion: https://postgr.es/m/tencent_0142D8DA90940B9930BCC08348BBD6D0BB07%40qq.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/849110dd3eec3e21c358e24f11c6d501d05eee72

Modified Files
--------------
src/common/binaryheap.c | 29 +++++++++--------------------
1 file changed, 9 insertions(+), 20 deletions(-)


pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: pgsql: Stabilize jsonb_path_query test case.
Next
From: Peter Geoghegan
Date:
Subject: pgsql: Clarify nbtree array exhaustion comments.