Обсуждение: pgsql: Don't initialize page in {vm,fsm}_extend(), not needed

Поиск
Список
Период
Сортировка

pgsql: Don't initialize page in {vm,fsm}_extend(), not needed

От
Andres Freund
Дата:
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

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/3d6a98457d8e21d85bed86cfd3e1d1df1b260721

Modified Files
--------------
src/backend/access/heap/visibilitymap.c   | 6 +-----
src/backend/storage/freespace/freespace.c | 5 +----
2 files changed, 2 insertions(+), 9 deletions(-)


Re: pgsql: Don't initialize page in {vm,fsm}_extend(), not needed

От
Tom Lane
Дата:
Andres Freund <andres@anarazel.de> writes:
> Don't initialize page in {vm,fsm}_extend(), not needed

Various buildfarm members are complaining about under-braced
initializations added by this commit.

visibilitymap.c: In function \342\200\230vm_extend\342\200\231:
visibilitymap.c:625:2: warning: missing braces around initializer [-Wmissing-braces]
  PGAlignedBlock pg = {0};
  ^
visibilitymap.c:625:2: warning: (near initialization for \342\200\230pg.data\342\200\231) [-Wmissing-braces]

freespace.c: In function \342\200\230fsm_extend\342\200\231:
freespace.c:611:2: warning: missing braces around initializer [-Wmissing-braces]
  PGAlignedBlock pg = {0};
  ^
freespace.c:611:2: warning: (near initialization for \342\200\230pg.data\342\200\231) [-Wmissing-braces]

This is from buri, similar from curculio, dragonet, idiacanthus,
xenodermus, etc

            regards, tom lane



Re: pgsql: Don't initialize page in {vm,fsm}_extend(), not needed

От
Michael Paquier
Дата:
On Wed, Apr 05, 2023 at 07:19:48PM -0400, Tom Lane wrote:
> freespace.c: In function \342\200\230fsm_extend\342\200\231:
> freespace.c:611:2: warning: missing braces around initializer [-Wmissing-braces]
>   PGAlignedBlock pg = {0};
>   ^
> freespace.c:611:2: warning: (near initialization for \342\200\230pg.data\342\200\231) [-Wmissing-braces]
>
> This is from buri, similar from curculio, dragonet, idiacanthus,
> xenodermus, etc

That's the same as d937904, it seems, requiring a {{0}}.
--
Michael

Вложения

Re: pgsql: Don't initialize page in {vm,fsm}_extend(), not needed

От
Andres Freund
Дата:
Hi,

On 2023-04-05 19:19:48 -0400, Tom Lane wrote:
> Andres Freund <andres@anarazel.de> writes:
> > Don't initialize page in {vm,fsm}_extend(), not needed
> 
> Various buildfarm members are complaining about under-braced
> initializations added by this commit.
> 
> visibilitymap.c: In function \342\200\230vm_extend\342\200\231:
> visibilitymap.c:625:2: warning: missing braces around initializer [-Wmissing-braces]
>   PGAlignedBlock pg = {0};
>   ^
> visibilitymap.c:625:2: warning: (near initialization for \342\200\230pg.data\342\200\231) [-Wmissing-braces]
> 
> freespace.c: In function \342\200\230fsm_extend\342\200\231:
> freespace.c:611:2: warning: missing braces around initializer [-Wmissing-braces]
>   PGAlignedBlock pg = {0};
>   ^
> freespace.c:611:2: warning: (near initialization for \342\200\230pg.data\342\200\231) [-Wmissing-braces]
> 
> This is from buri, similar from curculio, dragonet, idiacanthus,
> xenodermus, etc

I really don't see the point of placating old compilers for things like
this. It's just inflicting pain on ourselves without any reward. Just to be
clear: I didn't knowingly trigger the warning.

Either way, an upcoming commit will implement vm_extend() / fsm_extend() with
generic code, then the warning will be gone.

Greetings,

Andres Freund



Re: pgsql: Don't initialize page in {vm,fsm}_extend(), not needed

От
Andres Freund
Дата:
Hi,

On 2023-04-05 16:58:41 -0700, Andres Freund wrote:
> On 2023-04-05 19:19:48 -0400, Tom Lane wrote:
> > Andres Freund <andres@anarazel.de> writes:
> > > Don't initialize page in {vm,fsm}_extend(), not needed
> > 
> > Various buildfarm members are complaining about under-braced
> > initializations added by this commit.
> > 
> > visibilitymap.c: In function \342\200\230vm_extend\342\200\231:
> > visibilitymap.c:625:2: warning: missing braces around initializer [-Wmissing-braces]
> >   PGAlignedBlock pg = {0};
> >   ^
> > visibilitymap.c:625:2: warning: (near initialization for \342\200\230pg.data\342\200\231) [-Wmissing-braces]
> > 
> > freespace.c: In function \342\200\230fsm_extend\342\200\231:
> > freespace.c:611:2: warning: missing braces around initializer [-Wmissing-braces]
> >   PGAlignedBlock pg = {0};
> >   ^
> > freespace.c:611:2: warning: (near initialization for \342\200\230pg.data\342\200\231) [-Wmissing-braces]
> > 
> > This is from buri, similar from curculio, dragonet, idiacanthus,
> > xenodermus, etc
> 
> I really don't see the point of placating old compilers for things like
> this. It's just inflicting pain on ourselves without any reward. Just to be
> clear: I didn't knowingly trigger the warning.
> 
> Either way, an upcoming commit will implement vm_extend() / fsm_extend() with
> generic code, then the warning will be gone.

Done as of fcdda1e4b50249c344e510ea93d4bd74d2743430

- Andres