Designing and implementing a monitoring feature in PostgreSQL
summary
New core PostgreSQL feature (committed for PostgreSQL 18) implements on‑demand memory‑context dumps using dynamic shared memory: a coordinating backend creates a DSA (dynamic shared area) via DSA allocate/DSA free, target processes attach via DSM handles, copy their tree of memory contexts into the DSA, then wake the waiter using LW locks and condition variables. Exposed as PG_get_process_memory_context(pid, get_summary, timeout), supports summary mode to reduce size, configurable timeout, and measured tradeoffs between response latency and extra memory use.
AI-written summary · about
chapters (17)
- 0:00Introduction to PostgreSQL monitoring
- 1:17Types of PostgreSQL statistics
- 3:52Designing monitoring features
- 6:24Memory context basics
- 8:55Need for memory context stats
- 10:19Implementation of monitoring function
- 11:27Dynamic shared memory framework
- 13:37Dynamic shared area (DSA)
- 16:47Shared memory structure
- 18:55Data flow in monitoring function
- 21:45Synchronization primitives
- 22:29Dynamic vs static memory
- 24:15Handling large statistics
- 25:02Function API and output
- 28:31Customizing memory context output
- 29:17Future API for on-demand stats
- 31:28Summary and Q&A
related talks
25mDesigning a monitoring feature in PostgreSQL
45mEnhancing PostgreSQL Plasticity: New Frontiers in Memory Management
31mAll in a context!
50mInside PostgreSQL Shared Memory
53mThe Future of Observability in Postgres
32mMonitoring Waits in PostgreSQL
56mPostgreSQL at low Level: stay curious!
52mMulti-threaded PostgreSQL?
