Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
1040 commits
Select commit Hold shift + click to select a range
4fbd8c1
Move SPI runtime accessors to executor
samwillis Jun 15, 2026
f211a71
Move transaction runtime accessors to transam
samwillis Jun 15, 2026
1e52e85
Move instrumentation runtime accessors to executor
samwillis Jun 15, 2026
a3d3c12
Move error runtime accessors to utils error
samwillis Jun 16, 2026
a5a97f1
Move regex runtime accessors to regex
samwillis Jun 16, 2026
3deaea8
Move portal runtime accessors to mmgr
samwillis Jun 16, 2026
8c88b3d
Move large object session accessors
samwillis Jun 16, 2026
a40c9c2
Move snapshot runtime accessors to time
samwillis Jun 16, 2026
1ed5a29
Move XLog insert runtime accessors
samwillis Jun 16, 2026
a8bf446
Move backup runtime accessors
samwillis Jun 16, 2026
6e69ac6
Move transaction callback runtime accessors
samwillis Jun 16, 2026
14473a2
Move parser runtime accessors
samwillis Jun 16, 2026
c898466
Move logging runtime accessors
samwillis Jun 16, 2026
7ea43ce
Move lock wait runtime accessors
samwillis Jun 16, 2026
d6920db
Move encoding runtime accessors
samwillis Jun 16, 2026
4c82e31
Move temp file runtime accessors
samwillis Jun 16, 2026
80d4d72
Move plan cache runtime accessors
samwillis Jun 16, 2026
41e7f32
Move buffer IO runtime accessors
samwillis Jun 16, 2026
a76244f
Move transaction default runtime accessors
samwillis Jun 16, 2026
22897d2
Move vacuum runtime accessors
samwillis Jun 16, 2026
fc24d7b
Move execution cache runtime accessors
samwillis Jun 16, 2026
a69512c
Move async runtime accessors
samwillis Jun 16, 2026
bb43527
Move base backup runtime accessors
samwillis Jun 16, 2026
adf9f4a
Move large object runtime accessors
samwillis Jun 16, 2026
8620126
Move node IO runtime accessors
samwillis Jun 16, 2026
1dd106c
Move matview runtime accessors
samwillis Jun 16, 2026
17b4302
Move trigger runtime accessors
samwillis Jun 16, 2026
db1ba88
Move event trigger runtime accessors
samwillis Jun 16, 2026
dcf77a2
Move logical replication runtime accessors
samwillis Jun 16, 2026
af1f46f
Move two-phase runtime accessor
samwillis Jun 16, 2026
c96c7a2
Move transaction cleanup accessors and harden GUC mutex
samwillis Jun 16, 2026
4329a96
Move valgrind runtime accessor
samwillis Jun 16, 2026
4a6efa0
Move tcop runtime accessors
samwillis Jun 16, 2026
2fe744a
Move portal runtime accessor
samwillis Jun 16, 2026
9d9f3f2
Move backend activity runtime accessors
samwillis Jun 16, 2026
8cdf773
Move async runtime accessors
samwillis Jun 16, 2026
ea48473
Move random and optimizer runtime accessors
samwillis Jun 16, 2026
17408ba
Move debug query runtime accessor
samwillis Jun 16, 2026
78c686d
Move extension runtime accessors
samwillis Jun 16, 2026
6bb1e0b
Move backend log runtime accessors
samwillis Jun 16, 2026
7dc91ef
Move backend command runtime accessors
samwillis Jun 16, 2026
ce9da68
Move backend wait runtime accessors
samwillis Jun 16, 2026
989faf4
Move backend core miscadmin accessors
samwillis Jun 16, 2026
4e00dce
Move backend interrupt runtime helpers
samwillis Jun 16, 2026
10548f3
Check encoding runtime bridge ownership
samwillis Jun 16, 2026
8e8c0bf
Move encoding runtime selector
samwillis Jun 16, 2026
476c2b9
Move regex runtime selectors
samwillis Jun 16, 2026
b47552a
Move RI runtime accessors
samwillis Jun 16, 2026
99b31da
Record post-refactor threaded validation
samwillis Jun 16, 2026
4036446
Record threaded teardown TAP evidence
samwillis Jun 16, 2026
7a23c57
Move parser runtime selector
samwillis Jun 16, 2026
930635e
Move session datetime locale selectors
samwillis Jun 16, 2026
331b25f
Record selector refactor baselines
samwillis Jun 16, 2026
bfd7ecc
Move execution memory resource SPI selectors
samwillis Jun 16, 2026
ae0336a
Move execution snapshot combo selectors
samwillis Jun 16, 2026
5eac536
Move portal runtime selectors
samwillis Jun 16, 2026
aab3734
Move vacuum analyze runtime selectors
samwillis Jun 16, 2026
57c6701
Record selector refactor validation
samwillis Jun 16, 2026
de5169e
Move transam execution runtime selectors
samwillis Jun 16, 2026
e8b9c26
Move cache execution runtime selectors
samwillis Jun 16, 2026
92d4298
Move remaining execution runtime selectors
samwillis Jun 16, 2026
f5fc6a3
Record execution selector validation
samwillis Jun 16, 2026
8ff2a6e
Split backend runtime thread tests
samwillis Jun 16, 2026
5cccb60
Split backend runtime carrier tests
samwillis Jun 16, 2026
ea76acd
Move connection adoption runtime test
samwillis Jun 16, 2026
bd6a73d
Split remaining backend runtime tests
samwillis Jun 16, 2026
331ec44
Move connection and session runtime lifecycle bridges
samwillis Jun 16, 2026
664227c
Move backend runtime lifecycle bridge
samwillis Jun 16, 2026
65b60b7
Move execution runtime lifecycle bridge
samwillis Jun 16, 2026
e23ac61
Record post-refactor world-core validation
samwillis Jun 16, 2026
8121114
Move remaining runtime accessors owner-adjacent
samwillis Jun 16, 2026
a6a4395
Run threaded TAP in world-core target
samwillis Jun 16, 2026
bca7d50
Split session planner GUC runtime tests
samwillis Jun 16, 2026
fc114f1
Split backend subsystem runtime tests
samwillis Jun 16, 2026
aea5f77
Split session cache runtime tests
samwillis Jun 16, 2026
690a95c
Split session core GUC runtime tests
samwillis Jun 16, 2026
c6c1a8d
Audit Gate E2 core closeout evidence
samwillis Jun 16, 2026
15dc3a2
Account for threaded teardown memory reclamation
samwillis Jun 16, 2026
bec3e5d
Harden PMChild publication and trim runtime root helpers
samwillis Jun 16, 2026
149c6f5
Strengthen threaded teardown reclamation evidence
samwillis Jun 16, 2026
8974290
Refresh Gate E2 core closeout audit
samwillis Jun 16, 2026
a8cc4de
Close Phase 12 planning docs
samwillis Jun 16, 2026
29a6862
Archive Phase 12 stretch goal
samwillis Jun 16, 2026
80ac110
Add runtime hot current accessors
samwillis Jun 17, 2026
8a53495
Use lseek for threaded FileSize
samwillis Jun 17, 2026
11e2285
Record Linux simple-query perf checkpoint
samwillis Jun 17, 2026
0b755dd
Hot-path predicate runtime current state
samwillis Jun 17, 2026
3700cb5
Hot-path pgstat activity current state
samwillis Jun 17, 2026
c8531f1
Report threaded wait events by signal pid
samwillis Jun 17, 2026
cc09bd6
Use self-pipe latch wakeups on Linux
samwillis Jun 17, 2026
81f390e
Align threaded local interrupt signalling
samwillis Jun 18, 2026
94282db
Merge commit 'b595d922eb' into HEAD
samwillis Jun 18, 2026
c757196
Optimize threaded interrupt pending fast path
samwillis Jun 18, 2026
6ec3d94
Optimize MyProcPort current access
samwillis Jun 18, 2026
34c8e69
Route threaded proc signals through backend registry
samwillis Jun 18, 2026
7092013
Prefer threaded hot current accessors
samwillis Jun 18, 2026
b587582
Inline bridge-backed current accessors
samwillis Jun 18, 2026
f3abc98
Optimize protocol loop current checks
samwillis Jun 18, 2026
46b81c0
Document multithreaded PostgreSQL branch
samwillis Jun 18, 2026
62bf9e3
Link multithreading background from README
samwillis Jun 18, 2026
f17376f
Add branch status and performance guidance
samwillis Jun 18, 2026
ca3da95
Fix runtime current validation regressions
samwillis Jun 18, 2026
92cfae2
Introduce wait completion publication
samwillis Jun 18, 2026
d59819c
Publish threaded waits without GUC deadlock
samwillis Jun 18, 2026
ae49640
Add real wait-completion TAP coverage
samwillis Jun 18, 2026
ca1e090
Expand Phase 13 wait-completion coverage
samwillis Jun 18, 2026
84601c2
Publish semaphore-backed wait completions
samwillis Jun 18, 2026
33eb1ac
Add pooled scheduler wait requeue scaffold
samwillis Jun 18, 2026
9e26b10
Add carrier current-work attach helpers
samwillis Jun 18, 2026
d7118d6
Add publish-only wait parking primitive
samwillis Jun 18, 2026
dc50a51
Park pooled frontend reads before blocking
samwillis Jun 18, 2026
242f0f7
Record wait completion socket readiness source
samwillis Jun 18, 2026
e6785d1
Add pooled scheduler run-next primitive
samwillis Jun 18, 2026
5169b38
Dispatch pooled scheduler socket readiness
samwillis Jun 18, 2026
595a2a3
Requeue pooled waits on logical interrupts
samwillis Jun 18, 2026
ad4fb0c
Process pooled scheduler logical timeouts
samwillis Jun 19, 2026
df49566
Snapshot pooled scheduler waits
samwillis Jun 19, 2026
e16777e
Serialize threaded locale probes
samwillis Jun 19, 2026
8d94030
Record wait completion socket metadata
samwillis Jun 19, 2026
07d9e7b
Document protocol-boundary scheduler plan
samwillis Jun 19, 2026
d90aada
Address protocol scheduler design review
samwillis Jun 19, 2026
d1aee8a
Tighten protocol park handoff contract
samwillis Jun 19, 2026
c06d140
Clarify protocol scheduler wake prerequisites
samwillis Jun 19, 2026
76d2974
Clarify buffered transport input parking
samwillis Jun 19, 2026
74a3bd8
Start Phase 14 protocol park foundation
samwillis Jun 19, 2026
5330688
Add staging protocol park carrier loop
samwillis Jun 19, 2026
8df185e
Service protocol read wakes before parking
samwillis Jun 19, 2026
d0221ee
Record protocol park wake reasons
samwillis Jun 19, 2026
dd3903f
Snapshot timeout generation for protocol parks
samwillis Jun 19, 2026
44c0ddd
Wake protocol parks on logical timeouts
samwillis Jun 19, 2026
52952a9
Track deferred notify protocol park wakes
samwillis Jun 19, 2026
427c7dd
Add staging protocol scheduler queues
samwillis Jun 19, 2026
f2dc09b
Add Phase 14 protocol scheduler TAP coverage
samwillis Jun 19, 2026
5fff572
Tighten protocol park current-work invariants
samwillis Jun 19, 2026
a7beb50
Cover protocol park wake metadata
samwillis Jun 19, 2026
f83b021
Assert deep waits remain carrier-pinned
samwillis Jun 19, 2026
a50e6c4
Add protocol park postmaster death TAP
samwillis Jun 19, 2026
f03e3c0
Cover transaction timeout protocol parks
samwillis Jun 19, 2026
0cb1365
Cover detached protocol park interrupt wakes
samwillis Jun 19, 2026
dcfcb3c
Fix bootstrap process runtime state
samwillis Jun 19, 2026
3d5901b
Align protocol scheduler TAP expectations
samwillis Jun 19, 2026
65be8eb
Complete Phase 14A verification coverage
samwillis Jun 19, 2026
f94fd43
Split pooled protocol backend model levels
samwillis Jun 19, 2026
3219635
Add pooled protocol runtime kind
samwillis Jun 19, 2026
e2d65c8
Add pooled protocol carrier count GUC
samwillis Jun 19, 2026
ce57996
Track protocol scheduler carrier resumes
samwillis Jun 19, 2026
32d8e4b
Split PMChild logical backend publication
samwillis Jun 19, 2026
b1d883c
Split thread backend logical runtime state
samwillis Jun 19, 2026
5a7d75e
Split thread carrier and logical initializers
samwillis Jun 19, 2026
3108c89
Add protocol backend lease primitive
samwillis Jun 19, 2026
6913686
Add protocol carrier pool registration
samwillis Jun 19, 2026
559fa90
Add pooled logical PMChild publication
samwillis Jun 19, 2026
a6d456a
Keep threaded reloptions process-lifetime
samwillis Jun 19, 2026
dd7c464
Treat pooled protocol as thread-backed runtime
samwillis Jun 19, 2026
e2f02ad
Select pooled protocol runtime model
samwillis Jun 19, 2026
ff3b728
Split protocol park resume boundary
samwillis Jun 19, 2026
cbdeed4
Expose protocol scheduler boundary runner
samwillis Jun 19, 2026
7a49efe
Split backend session startup from run loop
samwillis Jun 19, 2026
06e0cf0
Split pooled logical PMChild exit
samwillis Jun 19, 2026
d462b15
Split backend thread publication state
samwillis Jun 19, 2026
6420011
Expose parked protocol scheduler snapshot
samwillis Jun 19, 2026
5435fc7
Poll parked protocol reads for readiness
samwillis Jun 19, 2026
138677b
Route pooled logical exits to carrier loop
samwillis Jun 19, 2026
e3aadbd
Register pooled protocol staging carriers
samwillis Jun 19, 2026
6329383
Implement pooled protocol carrier foundation
samwillis Jun 19, 2026
033803a
Add pooled protocol sessions-over-carriers stress
samwillis Jun 19, 2026
5247c2a
Assert pooled pg_sleep stays carrier-pinned
samwillis Jun 19, 2026
aaa4a22
Seed pooled logical backend PRNG
samwillis Jun 19, 2026
6d25f8d
Cover pooled protocol shutdown and pinned waits
samwillis Jun 19, 2026
92039d0
Fix protocol scheduler same-carrier resume race
samwillis Jun 19, 2026
6ed8668
Fix threaded GUC string replay ownership
samwillis Jun 19, 2026
bfcbc23
Complete Phase 15 runtime lifecycle coverage
samwillis Jun 19, 2026
40c2345
Add pgbench runtime matrix runner
samwillis Jun 19, 2026
25ea228
Claim parked protocol backends while polling
samwillis Jun 19, 2026
0dbb5e3
Keep dedicated threaded sessions off protocol scheduler
samwillis Jun 19, 2026
d37608d
Trim protocol scheduler overhead from pinned reads
samwillis Jun 20, 2026
8e47f67
Add pooled connection-shape pgbench workloads
samwillis Jun 20, 2026
2695599
Keep pinned protocol loop off scheduler budget
samwillis Jun 20, 2026
3d0ef14
Add long think-time pgbench workloads
samwillis Jun 20, 2026
6ab9256
Sample server resources in pgbench matrix
samwillis Jun 20, 2026
1209736
Make pgbench resource sampling opt in
samwillis Jun 20, 2026
bd49a31
Add repeated pgbench matrix samples
samwillis Jun 20, 2026
4db7af9
Add Phase 15 pgbench benchmark profiles
samwillis Jun 20, 2026
0598a30
Start pooled protocol carriers on demand
samwillis Jun 20, 2026
f8653f5
Raise pgbench matrix fd budget for scale runs
samwillis Jun 20, 2026
230d7a5
Increase pgbench scale fd budget
samwillis Jun 20, 2026
b9b1624
Raise pgbench matrix nofile limit
samwillis Jun 20, 2026
39ce613
Fix threaded backend exit descriptor cleanup
samwillis Jun 20, 2026
476d952
Report benchmark ratios against selected baseline
samwillis Jun 20, 2026
f069b83
Report benchmark resource efficiency
samwillis Jun 20, 2026
d3e4f20
Report idle connection memory footprints
samwillis Jun 20, 2026
0da62ac
Trim pinned protocol read hot path
samwillis Jun 20, 2026
66fa85b
Add explicit wake idle pgbench workloads
samwillis Jun 20, 2026
3e11b27
Add protocol park memory visibility
samwillis Jun 20, 2026
8f943fd
Add idle connection memory benchmark visibility
samwillis Jun 20, 2026
69f0691
Reduce idle backend runtime state
samwillis Jun 20, 2026
9e0c932
Add lazy session-private extension state
samwillis Jun 20, 2026
32d094f
Move sepgsql session state out of core
samwillis Jun 20, 2026
2deee2a
Move contrib session state to lazy private storage
samwillis Jun 20, 2026
c8135a0
Limit pooled protocol malloc arenas
samwillis Jun 20, 2026
4b46573
Make contrib extension bridge state lazy
samwillis Jun 20, 2026
2a9e799
Finish lazy contrib execution state
samwillis Jun 20, 2026
a3bd0e9
Move contrib extension state to lazy runtime cells
samwillis Jun 20, 2026
5350a30
Lazy allocate expression interpreter reverse table
samwillis Jun 20, 2026
b4a0850
Move remaining contrib state to lazy cells
samwillis Jun 20, 2026
75ce862
Reduce idle backend memory for pooled carriers
samwillis Jun 20, 2026
9f16cd4
Share immutable built-in GUC descriptors
samwillis Jun 20, 2026
8c3fe5f
Defer unused catcache bucket allocation
samwillis Jun 20, 2026
7578152
Start backend buffer context small
samwillis Jun 20, 2026
2ce429b
Start GUC memory context small
samwillis Jun 20, 2026
3f0b45b
Start small session contexts
samwillis Jun 20, 2026
74910f0
Log empty catcache descriptors at protocol park
samwillis Jun 20, 2026
c2f6854
Lazily allocate syscache descriptors
samwillis Jun 20, 2026
3aefb54
Split cold GUC state from hot overlays
samwillis Jun 20, 2026
0bb06fb
Move cold GUC extras out of dense state
samwillis Jun 20, 2026
c6734f2
Start transient transaction contexts small
samwillis Jun 20, 2026
e2208c7
Move cold pgstat pending state out of backend
samwillis Jun 20, 2026
6b9cfd4
Move GUC reset metadata to cold state
samwillis Jun 20, 2026
a970609
Reuse immutable default GUC strings
samwillis Jun 20, 2026
509c87d
Enable trim compaction for pooled idle sessions
samwillis Jun 20, 2026
a6f2044
Log GUC memory at protocol parks
samwillis Jun 20, 2026
1b5340b
Release receive buffer while pooled idle
samwillis Jun 20, 2026
353f0e2
Shrink session GUC state overlay
samwillis Jun 21, 2026
a87d750
Preserve backend type across runtime reset
samwillis Jun 21, 2026
dad08aa
Release pgstat scratch after quiet pooled parks
samwillis Jun 21, 2026
25910f9
Shrink idle LWLock tracking state
samwillis Jun 21, 2026
0077cf2
Start search path contexts small
samwillis Jun 21, 2026
3a75711
Release buffer pin state after quiet pooled parks
samwillis Jun 21, 2026
9b58be5
Log protocol park top chunk stats
samwillis Jun 21, 2026
b41fc6d
Allocate deadlock workspace lazily
samwillis Jun 21, 2026
5e675b3
Release pgstat snapshots for idle parks
samwillis Jun 21, 2026
e251667
Detach pgstat DSA during idle parks
samwillis Jun 21, 2026
8f596d9
Add two-level pooled protocol idle scheduling
samwillis Jun 21, 2026
357f84c
Reduce pooled protocol sticky wait overhead
samwillis Jun 21, 2026
f17b1f8
Reduce connection churn memory retention
samwillis Jun 21, 2026
18196c1
Add real-ish pooled benchmark profiles
samwillis Jun 21, 2026
0a84bee
Trim branch process hot path overhead
samwillis Jun 22, 2026
7923566
Trim protocol loop current-state overhead
samwillis Jun 22, 2026
51a3c41
Trim session loop flag access
samwillis Jun 22, 2026
944f6fb
Speed buffer manager current-state access
samwillis Jun 22, 2026
0ef0d41
Compile out wait-completion publication by default
samwillis Jun 22, 2026
c93f920
Fix threaded world core checks
samwillis Jun 22, 2026
5782dcc
Retarget pooled latch wait sets on carrier attach
samwillis Jun 22, 2026
284a04f
Document Phase 15 benchmark results
samwillis Jun 22, 2026
69bbe9a
Merge pull request #3 from samwillis/phase14-protocol-boundary-scheduler
samwillis Jun 22, 2026
5e9e444
Merge pull request #4 from samwillis/phase15-real-carrier-pool
samwillis Jun 22, 2026
839a1b5
Refresh README and move planning docs
samwillis Jun 22, 2026
cdb2327
Add experimental architecture diagram
samwillis Jun 22, 2026
93f654a
Link branch diff PR from README
samwillis Jun 22, 2026
6304caf
Clarify connection scalability goal
samwillis Jun 22, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
105 changes: 105 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# Multithreaded PostgreSQL Agent Guide

This repository is an experimental branch for making PostgreSQL capable of
running backend sessions in a multithreaded runtime. Keep process-mode
PostgreSQL working while advancing the threaded runtime.

## Mandatory Reading

- `plan_docs/MULTITHREADED_PLAN.md`: active staged plan, validation strategy,
gates, and risk register.
- `plan_docs/MULTITHREADED_ARCHITECTURE.md`: desired end-state architecture.
- `plan_docs/MULTITHREADED_AGENT_REFERENCE.md`: source orientation, build/test
notes, platform friction, and terminology.
- `MULTITHREADED_RUNTIME_LIFECYCLE.tsv`: checked runtime-root lifecycle
manifest.
- `MULTITHREADED_RUNTIME_OWNERS.tsv`: checked legacy-symbol owner map.

Conditional references:

- `plan_docs/MULTITHREADED_PHASE12_STATE.md`: archival Phase 12 implementation
ledger and Gate E2-Core evidence. Read it when investigating Phase 12
regressions or updating closeout evidence.
- `plan_docs/MULTITHREADED_AGENT_PHASE12_GUIDE.md`: detailed Phase 12 workflow
rules. Read it before reopening Phase 12 state/lifecycle migration work.
- `plan_docs/MULTITHREADED_THREADING_REVIEW.md`: historical Gate E2 blocker
rationale.
- `refs/REFERENCES.md` and
`refs/pgconf-2025-multithreading-transcript.md`: motivating background
material.

## Current Direction

Phase 12 / Gate E2-Core is closed for the scoped core thread-per-session
runtime. Phase 13 is the active direction: make wait boundaries
scheduler-aware while preserving the thread-per-session fallback.

Do not reopen broad Phase 12 migration, refactor, or documentation churn unless
runtime evidence proves a core blocker. Valid evidence includes threaded TAP
failures, retained-root warnings, lifecycle/global-lifetime checker failures,
crashes, hangs, or process-mode regressions.

Phase 16 / Gate E2-Extensions owns contrib-wide threaded support, bundled
procedural languages beyond PL/pgSQL, and the full custom/extension GUC
matrix. Use "defer with invariant" for intentional exclusions: explain why the
scope is safe now, which guard would catch a wrong assumption, and which later
phase/gate owns completion.

## Development Rules

- Keep documentation and code commits coherent. Prefer one conceptual change
per commit.
- After each commit, push the current branch immediately unless explicitly told
not to.
- Before editing core code, read the surrounding implementation and comments.
PostgreSQL has many invariants documented only locally.
- Keep process mode green.
- Use static annotations and tools to classify globals before moving state.
- Prefer larger coherent batches when ownership and validation surface match.
Avoid one-variable commits unless the variable sits on a fragile lifecycle
path.
- Keep `src/backend/utils/init/backend_runtime.c` focused on root runtime
construction, current-pointer installation, process/thread symmetry, and
top-level adoption/reset orchestration. Put owner-specific accessors and
simple lifecycle helpers in owner-adjacent subsystem files.
- Add backend-runtime tests to the split object-family test files under
`src/test/modules/test_backend_runtime`, not back into the old monolith.
- Before adding handwritten lifecycle lists, use the checked bucket `.def`
files and `PG_RUNTIME_DEFINE_*` helpers where they fit. Semantic cleanup
stays handwritten near the owning subsystem.
- When local build/test friction repeats, update
`plan_docs/MULTITHREADED_AGENT_REFERENCE.md` rather than growing this file.

## Validation Defaults

- For doc-only changes, run `git diff --check`.
- For ordinary code changes, keep `gmake check` and `gmake check-threaded`
green.
- For runtime-root, lifecycle, GUC, teardown, worker, or wait-boundary changes,
also run the focused target that matches the touched surface and the relevant
guardrails:
`gmake check-threaded-workers`, `gmake check-threaded-world-core`,
`gmake check-runtime-lifecycles`, and/or
`gmake check-global-lifetimes`.

## Working Assumptions

- Use Heikki Linnakangas's multithreading branch as reference material, not as
a base to merge wholesale.
- Preserve multiprocess PostgreSQL as a supported backend model.
- The first native threading target is thread-per-session. The longer-term
target is an explicit scheduler that can map sessions/executions to carriers.
- Thread-per-session for regular client backends is not the final normal-mode
target. Normal threaded server mode should eventually run in-tree
server-owned workers as threaded runtime-owned workers rather than forked
subprocesses.
- Single-user mode, bootstrap mode, frontend command-line utilities,
postmaster/control-plane process lifetime, and crash-escalation paths are
deliberate process-lifetime exceptions.
- Do not overfit the design to WASM. Keep the main-loop and wait-boundary
abstractions clean enough for a future host-driven runtime.
- Existing third-party C extensions may be process-backend-only. Existing
third-party background workers may remain process-only or be rejected in
threaded mode unless explicit worker-runtime metadata opts them in.
- In-tree modules and important bundled languages, especially PL/pgSQL, should
have a plausible path to work in threaded mode.
107 changes: 103 additions & 4 deletions GNUmakefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,61 @@ distclean:
@rm -rf autom4te.cache/
rm -f config.cache config.log config.status GNUmakefile

check-tests: | temp-install
check check-tests installcheck installcheck-parallel installcheck-tests: CHECKPREP_TOP=src/test/regress
check check-tests installcheck installcheck-parallel installcheck-tests: submake-generated-headers
THREADED_WORLD_CORE_CONFIG = $(abs_top_srcdir)/src/test/regress/threaded_workers.conf
THREADED_WORLD_CORE_TAP_DIR = $(abs_top_srcdir)/src/test/modules/test_backend_runtime
THREADED_WORLD_CORE_TAP_TESTS = \
t/001_threaded_runtime.pl \
t/002_threaded_bgworker_crash.pl \
t/003_milestone_w_core_smoke.pl \
t/004_phase13_wait_completion.pl \
t/005_phase14_protocol_scheduler.pl \
t/006_phase14_protocol_postmaster_death.pl \
t/007_phase15_pooled_protocol_mode.pl \
t/008_phase15_pooled_protocol_postmaster_death.pl \
t/009_phase15_pooled_deep_waits_pinned.pl
THREADED_WORLD_CORE_TAP_PERL5LIB = \
$(abs_top_builddir)/.perl5/lib/perl5:$(abs_top_builddir)/.perl5/lib/perl5/darwin-thread-multi-2level:$(abs_top_srcdir)/src/test/perl:$(THREADED_WORLD_CORE_TAP_DIR)
THREADED_WORLD_CORE_PROVE = $(if $(PROVE),$(PROVE),prove)

check-tests check-threaded check-threaded-workers check-threaded-smoke check-threaded-150 check-threaded-200: | temp-install
check check-tests check-threaded check-threaded-workers check-threaded-smoke check-threaded-150 check-threaded-200 installcheck installcheck-parallel installcheck-tests: CHECKPREP_TOP=src/test/regress
check check-tests check-threaded check-threaded-workers check-threaded-smoke check-threaded-150 check-threaded-200 installcheck installcheck-parallel installcheck-tests: submake-generated-headers
$(MAKE) -C src/test/regress $@

check-threaded-world-core: CHECKPREP_TOP=src/test/regress
check-threaded-world-core: | temp-install
check-threaded-world-core: submake-generated-headers
check-threaded-world-core:
$(MAKE) -C src/test/regress check-threaded-workers
$(MAKE) -C src/pl/plpgsql/src check TEMP_CONFIG=$(THREADED_WORLD_CORE_CONFIG)
$(MAKE) -C src/test/isolation check TEMP_CONFIG=$(THREADED_WORLD_CORE_CONFIG)
$(MAKE) -C src/test/modules/test_backend_runtime DESTDIR=$(abs_top_builddir)/tmp_install install
$(MAKE) -C src/test/modules/test_backend_runtime check
$(MAKE) check-threaded-world-core-tap
$(MAKE) check-runtime-lifecycles
$(MAKE) check-global-lifetimes

check-threaded-world-core-tap: CHECKPREP_TOP=src/test/regress
check-threaded-world-core-tap: | temp-install
check-threaded-world-core-tap: submake-generated-headers
check-threaded-world-core-tap:
$(MAKE) -C src/test/modules/test_backend_runtime DESTDIR=$(abs_top_builddir)/tmp_install install
rm -rf '$(THREADED_WORLD_CORE_TAP_DIR)'/tmp_check
$(MKDIR_P) '$(THREADED_WORLD_CORE_TAP_DIR)'/tmp_check/log
cd '$(THREADED_WORLD_CORE_TAP_DIR)' && \
TESTLOGDIR='$(THREADED_WORLD_CORE_TAP_DIR)'/tmp_check/log \
TESTDATADIR='$(THREADED_WORLD_CORE_TAP_DIR)'/tmp_check \
PATH='$(abs_top_builddir)'/tmp_install$(bindir):'$(THREADED_WORLD_CORE_TAP_DIR)':$$PATH \
$(call add_to_path,$(strip $(ld_library_path_var)),$(abs_top_builddir)/tmp_install$(libdir)) \
INITDB_TEMPLATE='$(abs_top_builddir)'/tmp_install/initdb-template \
PGPORT=65432 \
top_builddir='$(abs_top_builddir)' \
PG_REGRESS='$(abs_top_builddir)'/src/test/regress/pg_regress \
share_contrib_dir='$(abs_top_builddir)'/tmp_install$(datadir)/$(datamoduledir) \
GMAKE='$(MAKE)' \
PERL5LIB='$(THREADED_WORLD_CORE_TAP_PERL5LIB)':$${PERL5LIB} \
$(THREADED_WORLD_CORE_PROVE) -I '$(abs_top_srcdir)'/src/test/perl -I '$(THREADED_WORLD_CORE_TAP_DIR)' $(PROVE_FLAGS) $(THREADED_WORLD_CORE_TAP_TESTS)

$(call recurse,check-world,src/test src/pl src/interfaces contrib src/bin src/tools/pg_bsd_indent,check)
$(call recurse,checkprep, src/test src/pl src/interfaces contrib src/bin)

Expand Down Expand Up @@ -134,4 +184,53 @@ headerscheck: submake-generated-headers
cpluspluscheck: submake-generated-headers
$(top_srcdir)/src/tools/pginclude/headerscheck --cplusplus $(top_srcdir) $(abs_top_builddir)

.PHONY: dist distcheck docs install-docs world check-world install-world installcheck-world headerscheck cpluspluscheck
check-global-lifetimes:
$(PERL) $(top_srcdir)/src/tools/global_lifetime/scan_global_lifetimes.pl \
--baseline $(top_srcdir)/src/tools/global_lifetime/global_lifetime_baseline.tsv \
--enforce-local-runtime-boundary

check-runtime-lifecycles:
$(PERL) $(top_srcdir)/src/tools/runtime_lifecycle/check_runtime_lifecycles.pl \
--header $(top_srcdir)/src/include/utils/backend_runtime.h \
--manifest $(top_srcdir)/MULTITHREADED_RUNTIME_LIFECYCLE.tsv \
--owner-map $(top_srcdir)/MULTITHREADED_RUNTIME_OWNERS.tsv \
--source $(top_srcdir)/src/backend/utils/init/backend_runtime.c \
--source $(top_srcdir)/src/backend/utils/init/backend_runtime_backend.c \
--source $(top_srcdir)/src/backend/utils/init/backend_runtime_execution.c \
--source $(top_srcdir)/src/backend/utils/init/backend_runtime_session.c \
--source $(top_srcdir)/src/backend/utils/init/backend_runtime_teardown.c \
--source $(top_srcdir)/src/backend/tcop/backend_runtime_tcop.c \
--source $(top_srcdir)/src/backend/utils/cache/backend_runtime_cache.c \
--source $(top_srcdir)/src/backend/utils/activity/backend_runtime_pgstat.c \
--source $(top_srcdir)/src/backend/utils/activity/backend_status.c \
--source $(top_srcdir)/src/backend/utils/adt/backend_runtime_pseudorandom.c \
--source $(top_srcdir)/src/backend/utils/adt/backend_runtime_ri.c \
--source $(top_srcdir)/src/backend/utils/error/backend_runtime_error.c \
--source $(top_srcdir)/src/backend/utils/fmgr/backend_runtime_extension.c \
--source $(top_srcdir)/src/backend/utils/misc/backend_runtime_guc.c \
--source $(top_srcdir)/src/backend/utils/misc/backend_runtime_utility.c \
--source $(top_srcdir)/src/backend/utils/misc/timeout.c \
--source $(top_srcdir)/src/backend/utils/mb/backend_runtime_mb.c \
--source $(top_srcdir)/src/backend/utils/mmgr/backend_runtime_memory.c \
--source $(top_srcdir)/src/backend/utils/mmgr/backend_runtime_portal.c \
--source $(top_srcdir)/src/backend/regex/backend_runtime_regex.c \
--source $(top_srcdir)/src/backend/optimizer/util/backend_runtime_optimizer.c \
--source $(top_srcdir)/src/backend/commands/backend_runtime_async.c \
--source $(top_srcdir)/src/backend/commands/event_trigger.c \
--source $(top_srcdir)/src/backend/commands/backend_runtime_event_trigger.c \
--source $(top_srcdir)/src/backend/commands/backend_runtime_trigger.c \
--source $(top_srcdir)/src/backend/replication/logical/backend_runtime_logical.c \
--source $(top_srcdir)/src/backend/postmaster/interrupt.c \
--source $(top_srcdir)/src/backend/jit/backend_runtime_jit.c \
--source $(top_srcdir)/src/backend/access/transam/backend_runtime_parallel.c \
--source $(top_srcdir)/src/backend/access/transam/backend_runtime_xact.c \
--source $(top_srcdir)/src/backend/libpq/backend_runtime_connection.c \
--source $(top_srcdir)/src/backend/storage/large_object/backend_runtime_large_object.c \
--source $(top_srcdir)/src/backend/storage/buffer/backend_runtime_buffer.c \
--source $(top_srcdir)/src/backend/storage/file/backend_runtime_file.c \
--source $(top_srcdir)/src/backend/storage/lmgr/backend_runtime_lmgr.c \
--source $(top_srcdir)/src/backend/storage/ipc/backend_runtime_ipc.c \
--source $(top_srcdir)/src/backend/storage/ipc/dsm.c \
--source $(top_srcdir)/src/backend/storage/ipc/ipc.c

.PHONY: dist distcheck docs install-docs world check-world install-world installcheck-world headerscheck cpluspluscheck check-global-lifetimes check-runtime-lifecycles check-threaded-world-core check-threaded-world-core-tap
Loading