| From: | Heikki Linnakangas <hlinnaka(at)iki(dot)fi> |
|---|---|
| To: | "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Move src/backend/storage/ipc/ to just src/backend/ipc/ |
| Date: | 2026-12-02 17:02:45 |
| Message-ID: | 78aedbea-b692-4f95-b4b8-1172947c7582@iki.fi |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
It bugs me that we have source directory called
src/backend/storage/ipc/. That feels wrong, the stuff in there are
decidedly *not* storage related. Ever since I started to work on
Postgres, that's felt like a WTF.
I'd like to rename src/backend/storage/ipc/ to src/backend/ipc. And move
all the IPC related header files from src/include/storage/ to
src/include/ipc. About half of the header files in src/include/storage/
would belong under src/include/ipc in the new scheme.
Easily predictable objections are:
- it's not worth the code churn
- it'll make backpatching harder
- it'll break git history continuation
- it'll break extensions
I'm not too bothered with the first three; git handles simple renames
pretty well. We've renamed files in the past, and e.g. git blame works
across the renames.
Extensions #including those files would need to adapt, with #if version
guards to be able to compile against multiple versions. I don't want
cause pain to extension authors unnecessarily, but I think this is
acceptable; mechanical changes like this are easy to deal with.
I did a quick survey using AI of the extensions listed in Joel's list
[1], of how many extensions would be affected:
> About 259 of the 1154 extensions (22%) include at least one header your branch moves. That is most of the 322 extensions that include anything from storage/. The single biggest cause is storage/ipc.h becoming ipc/onexit.h, which by itself affects 180 extensions.
>
> Extensions affected, per header:
>
> ┌────────────────────────────────────────┬─────────────────┐
> │ Header │ Extensions │
> ├────────────────────────────────────────┼─────────────────┤
> │ storage/ipc.h (→ ipc/onexit.h) │ 180 │
> ├────────────────────────────────────────┼─────────────────┤
> │ storage/proc.h │ 103 │
> ├────────────────────────────────────────┼─────────────────┤
> │ storage/shmem.h │ 91 │
> ├────────────────────────────────────────┼─────────────────┤
> │ storage/lwlock.h │ 88 │
> ├────────────────────────────────────────┼─────────────────┤
> │ storage/latch.h │ 83 │
> ├────────────────────────────────────────┼─────────────────┤
> │ storage/spin.h │ 64 │
> ├────────────────────────────────────────┼─────────────────┤
> │ storage/lmgr.h │ 63 │
> ├────────────────────────────────────────┼─────────────────┤
> │ storage/procarray.h │ 51 │
> ├────────────────────────────────────────┼─────────────────┤
> │ storage/lock.h │ 39 │
> ├────────────────────────────────────────┼─────────────────┤
> │ storage/dsm.h │ 20 │
> ├────────────────────────────────────────┼─────────────────┤
> │ storage/shm_toc.h, storage/s_lock.h │ 18 each │
> ├────────────────────────────────────────┼─────────────────┤
> │ storage/shm_mq.h, storage/procsignal.h │ 15 each │
> ├────────────────────────────────────────┼─────────────────┤
> │ storage/pmsignal.h │ 10 │
> ├────────────────────────────────────────┼─────────────────┤
> │ everything else │ 8 or fewer each │
> └────────────────────────────────────────┴─────────────────┘
>
> Patterns:
> - Many extensions use the same small set of headers for shared memory and background workers. 22 of them use exactly ipc.h, latch.h, lwlock.h, proc.h and shmem.h. These are mostly shmem_startup_hook / RequestAddinShmemSpace boilerplate.
> - 29 extensions include only storage/ipc.h, mostly for on_proc_exit / before_shmem_exit. Keeping a compatibility storage/ipc.h that just includes ipc/onexit.h would leave those 29 unaffected.
> - Half of the affected extensions (131) use only one or two of the moved headers. The heaviest users are orioledb (19 headers), pg-strom (14), timescaledb (12), pipelinedb (11), and pglogical forks, pg_wait_sampling and pg_query_state (9 each).
>
> If you want to reduce the churn, forwarding stubs for ipc.h, proc.h, shmem.h, lwlock.h and latch.h would cover the large majority of affected extensions.
>
> How I counted: I grepped .c/.h/.cpp/.pgc files for #include "storage/X.h" lines naming any of the 35 headers your WIP commit renames, and counted each repository once per header. Hits inside vendored PostgreSQL source trees (src/backend/ or src/include/ paths inside a repo) are excluded; 8 repos had some. Forks are counted separately, so pglogical and pipelinedb appear more than once. The counts also miss includes hidden behind macros or conditional compat headers.
We could provide backwards-compatiblity stubs, or backpatch
forward-compatibility stubs into backbranches, to reduce the impact. I
feel it's better to just go cold turkey, though.
Any objections? Strong / weak? Am I missing some impact?
Why now? Well, I got annoyed by this again while working on the
interrupts patch, but it's not a blocker for that. If not now, then when?
[1] https://gist.github.com/joelonsql/e5aa27f8cc9bd22b8999b7de8aee9d47
- Heikki
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 2026-12-02 17:18:56 | Re: Move src/backend/storage/ipc/ to just src/backend/ipc/ |
| Previous Message | Nathan Bossart | 2026-12-02 16:47:40 | Re: Restore check_mut_excl_opts, usage in pg_restore and pg_dumpall |