Обсуждение: pgsql: Convert all remaining subsystems to use the new shmem allocation

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

pgsql: Convert all remaining subsystems to use the new shmem allocation

От
Heikki Linnakangas
Дата:
Convert all remaining subsystems to use the new shmem allocation API

This removes all remaining uses of ShmemInitStruct() and
ShmemInitHash() from built-in code.

Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Reviewed-by: Matthias van de Meent <boekewurm+postgres@gmail.com>
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Discussion: https://www.postgresql.org/message-id/CAExHW5vM1bneLYfg0wGeAa=52UiJ3z4vKd3AJ72X8Fw6k3KKrg@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/9b5acad3f40fa6015f367fbf887ae5c1a93a3698

Modified Files
--------------
src/backend/access/common/syncscan.c               |  76 +++++----
src/backend/access/nbtree/nbtutils.c               |  54 ++++---
src/backend/access/transam/twophase.c              |  75 ++++-----
src/backend/access/transam/xlog.c                  |  82 +++++-----
src/backend/access/transam/xlogprefetcher.c        |  51 +++---
src/backend/access/transam/xlogrecovery.c          |  35 +++--
src/backend/access/transam/xlogwait.c              |  50 +++---
src/backend/postmaster/autovacuum.c                |  79 +++++-----
src/backend/postmaster/bgworker.c                  | 105 ++++++-------
src/backend/postmaster/checkpointer.c              |  56 +++----
src/backend/postmaster/datachecksum_state.c        |  41 ++---
src/backend/postmaster/pgarch.c                    |  43 +++--
src/backend/postmaster/walsummarizer.c             |  60 +++----
src/backend/replication/logical/launcher.c         |  56 +++----
src/backend/replication/logical/logicalctl.c       |  29 ++--
src/backend/replication/logical/origin.c           |  59 ++++---
src/backend/replication/logical/slotsync.c         |  41 ++---
src/backend/replication/slot.c                     |  64 ++++----
src/backend/replication/walreceiverfuncs.c         |  51 +++---
src/backend/replication/walsender.c                |  59 ++++---
src/backend/storage/ipc/ipci.c                     | 124 +--------------
src/backend/storage/lmgr/lock.c                    | 109 +++++--------
src/backend/utils/activity/backend_status.c        | 173 ++++++++-------------
src/backend/utils/activity/pgstat_shmem.c          | 158 ++++++++++---------
src/backend/utils/activity/wait_event.c            |  83 +++++-----
src/backend/utils/misc/injection_point.c           |  57 ++++---
src/include/access/nbtree.h                        |   2 -
src/include/access/syncscan.h                      |   2 -
src/include/access/twophase.h                      |   3 -
src/include/access/xlog.h                          |   2 -
src/include/access/xlogprefetcher.h                |   3 -
src/include/access/xlogrecovery.h                  |   3 -
src/include/access/xlogwait.h                      |   2 -
src/include/pgstat.h                               |   4 -
src/include/postmaster/autovacuum.h                |   4 -
src/include/postmaster/bgworker_internals.h        |   2 -
src/include/postmaster/bgwriter.h                  |   3 -
src/include/postmaster/datachecksum_state.h        |   4 -
src/include/postmaster/pgarch.h                    |   2 -
src/include/postmaster/walsummarizer.h             |   2 -
src/include/replication/logicalctl.h               |   2 -
src/include/replication/logicallauncher.h          |   3 -
src/include/replication/origin.h                   |   4 -
src/include/replication/slot.h                     |   4 -
src/include/replication/slotsync.h                 |   2 -
src/include/replication/walreceiver.h              |   2 -
src/include/replication/walsender.h                |   2 -
src/include/storage/lock.h                         |   2 -
src/include/storage/subsystemlist.h                |  27 ++++
src/include/utils/backend_status.h                 |   8 -
src/include/utils/injection_point.h                |   3 -
src/include/utils/wait_event.h                     |   2 -
.../modules/injection_points/injection_points.c    |  59 +++----
src/test/modules/test_aio/test_aio.c               | 107 ++++++-------
54 files changed, 927 insertions(+), 1208 deletions(-)


Re: pgsql: Convert all remaining subsystems to use the new shmem allocation

От
Michael Paquier
Дата:
On Sun, Apr 05, 2026 at 11:27:44PM +0000, Heikki Linnakangas wrote:
> Convert all remaining subsystems to use the new shmem allocation API
>
> This removes all remaining uses of ShmemInitStruct() and
> ShmemInitHash() from built-in code.
>
> src/backend/utils/misc/injection_point.c           |  57 ++++---

drongo, that compiles without USE_INJECTION_POINTS, is complaining
about this bit around line 240:
const ShmemCallbacks InjectionPointShmemCallbacks = {
#ifdef USE_INJECTION_POINTS
    .request_fn = InjectionPointShmemRequest,
    .init_fn = InjectionPointShmemInit,
#endif
};

Link:
https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=drongo&dt=2026-04-06%2004%3A09%3A20
And the error:
../pgsql/src/backend/utils/misc/injection_point.c(240): error C2059: syntax error: '}'

Why not putting the whole InjectionPointShmemCallbacks inside a
USE_INJECTION_POINTS block?  We should not care about shmem
allocations when --enable-injection-points is not used.

subsystemlist.h expects the callbacks to always be defined, so your
intention is to have no ifdefs there.  Still, it seems a bit pointless
to me to define callbacks we are not going to use depending on the
build options evoked?  Attached is one idea, which I doubt you'll
like.  :)
--
Michael

Вложения

Re: pgsql: Convert all remaining subsystems to use the new shmem allocation

От
Heikki Linnakangas
Дата:
On 06/04/2026 08:41, Michael Paquier wrote:
> On Sun, Apr 05, 2026 at 11:27:44PM +0000, Heikki Linnakangas wrote:
>> Convert all remaining subsystems to use the new shmem allocation API
>>
>> This removes all remaining uses of ShmemInitStruct() and
>> ShmemInitHash() from built-in code.
>>
>> src/backend/utils/misc/injection_point.c           |  57 ++++---
> 
> drongo, that compiles without USE_INJECTION_POINTS, is complaining
> about this bit around line 240:
> const ShmemCallbacks InjectionPointShmemCallbacks = {
> #ifdef USE_INJECTION_POINTS
>      .request_fn = InjectionPointShmemRequest,
>      .init_fn = InjectionPointShmemInit,
> #endif
> };
> 
> Link:
> https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=drongo&dt=2026-04-06%2004%3A09%3A20
> And the error:
> ../pgsql/src/backend/utils/misc/injection_point.c(240): error C2059: syntax error: '}'

Oh, I didn't realize that that an empty initializer isn't allowed.

> Why not putting the whole InjectionPointShmemCallbacks inside a
> USE_INJECTION_POINTS block?  We should not care about shmem
> allocations when --enable-injection-points is not used.
> 
> subsystemlist.h expects the callbacks to always be defined, so your
> intention is to have no ifdefs there.  Still, it seems a bit pointless
> to me to define callbacks we are not going to use depending on the
> build options evoked?  Attached is one idea, which I doubt you'll
> like.  :)

Looks perfectly fine to me, I'll push that. Thanks!

- Heikki