From 0c5af0a537a2d6320eb8ef7f401401aa1f47b79e Mon Sep 17 00:00:00 2001 From: Andres Freund Date: Fri, 14 Nov 2014 17:04:44 +0100 Subject: [PATCH] Move BufferGetBlockNumber() out of heap_page_is_all_visible()'s inner loop. In some workloads BufferGetBlockNumber() shows up in profiles due to the sheer number of calls to it (and because it causes cache misses). The compiler can't move it out of the loop because it's a full extern function call... --- src/backend/commands/vacuumlazy.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/backend/commands/vacuumlazy.c b/src/backend/commands/vacuumlazy.c index 8dad8c269c..6db6c5cf47 100644 --- a/src/backend/commands/vacuumlazy.c +++ b/src/backend/commands/vacuumlazy.c @@ -1754,6 +1754,7 @@ static bool heap_page_is_all_visible(Relation rel, Buffer buf, TransactionId *visibility_cutoff_xid) { Page page = BufferGetPage(buf); + BlockNumber blockno = BufferGetBlockNumber(buf); OffsetNumber offnum, maxoff; bool all_visible = true; @@ -1778,7 +1779,7 @@ heap_page_is_all_visible(Relation rel, Buffer buf, TransactionId *visibility_cut if (!ItemIdIsUsed(itemid) || ItemIdIsRedirected(itemid)) continue; - ItemPointerSet(&(tuple.t_self), BufferGetBlockNumber(buf), offnum); + ItemPointerSet(&(tuple.t_self), blockno, offnum); /* * Dead line pointers can have index pointers pointing to them. So