Skip to content

Commit 3d6a984

Browse files
committed
Don't initialize page in {vm,fsm}_extend(), not needed
The read path needs to be able to initialize pages anyway, as relation extensions are not durable. By avoiding initializing pages, we can, in a future patch, extend the relation by multiple blocks at once. Using smgrextend() for {vm,fsm}_extend() is not a good idea in general, as at least one page of the VM/FSM will be read immediately after, always causing a cache miss, requiring us to read content we just wrote. Discussion: https://postgr.es/m/20230301223515.pucbj7nb54n4i4nv@awork3.anarazel.de
1 parent 86a3fc7 commit 3d6a984

File tree

2 files changed

+2
-9
lines changed

2 files changed

+2
-9
lines changed

src/backend/access/heap/visibilitymap.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -622,11 +622,9 @@ static void
622622
vm_extend(Relation rel, BlockNumber vm_nblocks)
623623
{
624624
BlockNumber vm_nblocks_now;
625-
PGAlignedBlock pg;
625+
PGAlignedBlock pg = {0};
626626
SMgrRelation reln;
627627

628-
PageInit((Page) pg.data, BLCKSZ, 0);
629-
630628
/*
631629
* We use the relation extension lock to lock out other backends trying to
632630
* extend the visibility map at the same time. It also locks out extension
@@ -662,8 +660,6 @@ vm_extend(Relation rel, BlockNumber vm_nblocks)
662660
/* Now extend the file */
663661
while (vm_nblocks_now < vm_nblocks)
664662
{
665-
PageSetChecksumInplace((Page) pg.data, vm_nblocks_now);
666-
667663
smgrextend(reln, VISIBILITYMAP_FORKNUM, vm_nblocks_now, pg.data, false);
668664
vm_nblocks_now++;
669665
}

src/backend/storage/freespace/freespace.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -608,10 +608,9 @@ static void
608608
fsm_extend(Relation rel, BlockNumber fsm_nblocks)
609609
{
610610
BlockNumber fsm_nblocks_now;
611-
PGAlignedBlock pg;
611+
PGAlignedBlock pg = {0};
612612
SMgrRelation reln;
613613

614-
PageInit((Page) pg.data, BLCKSZ, 0);
615614

616615
/*
617616
* We use the relation extension lock to lock out other backends trying to
@@ -649,8 +648,6 @@ fsm_extend(Relation rel, BlockNumber fsm_nblocks)
649648
/* Extend as needed. */
650649
while (fsm_nblocks_now < fsm_nblocks)
651650
{
652-
PageSetChecksumInplace((Page) pg.data, fsm_nblocks_now);
653-
654651
smgrextend(reln, FSM_FORKNUM, fsm_nblocks_now,
655652
pg.data, false);
656653
fsm_nblocks_now++;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy