Move BufferGetBlockNumber() out of heap_page_is_all_visible()'s inner loop.
authorAndres Freund <andres@anarazel.de>
Fri, 14 Nov 2014 16:04:44 +0000 (17:04 +0100)
committerAndres Freund <andres@anarazel.de>
Fri, 14 Nov 2014 16:04:44 +0000 (17:04 +0100)
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

index 8dad8c269cc8d4fd5f5381af369e8f825c04760a..6db6c5cf47248ddd516dc9b622fb6e5ce6f4fb1a 100644 (file)
@@ -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