mirror of
https://github.com/gadgethd/ukmesh.git
synced 2026-12-06 11:14:26 +00:00
Compress full-page WAL images in the lean PostgreSQL default
This commit is contained in:
1 parent
6a470f4546
commit
42698d26a2
4 files changed
+38
-5
No files matched your search
@@ -202,6 +202,10 @@ HOPREACH_MEMORY_LIMIT=768m
|
||||
POSTGRES_SHARED_BUFFERS=256MB
|
||||
POSTGRES_MAINTENANCE_WORK_MEM=64MB
|
||||
POSTGRES_AUTOVACUUM_WORK_MEM=32MB
|
||||
# Lossless full-page WAL compression trades some logging/replay CPU for less I/O.
|
||||
# Normal Compose can explicitly override this, e.g. POSTGRES_WAL_COMPRESSION=off.
|
||||
# Local DEV clears caller settings and uses the policy's lz4 default.
|
||||
POSTGRES_WAL_COMPRESSION=lz4
|
||||
# A larger VPS may explicitly consume the same policy in its existing external
|
||||
# infrastructure Compose service and override the memory settings
|
||||
# for that host. VPS adoption remains a separate, explicit deployment action.
|
||||
|
||||
@@ -19,6 +19,8 @@ services:
|
||||
- maintenance_work_mem=${POSTGRES_MAINTENANCE_WORK_MEM:-64MB}
|
||||
- -c
|
||||
- autovacuum_work_mem=${POSTGRES_AUTOVACUUM_WORK_MEM:-32MB}
|
||||
- -c
|
||||
- wal_compression=${POSTGRES_WAL_COMPRESSION:-lz4}
|
||||
cpus: 2
|
||||
mem_limit: &postgres-memory 2g
|
||||
memswap_limit: *postgres-memory
|
||||
|
||||
@@ -1912,3 +1912,27 @@ qualification. Do not change workloads, timing or acceptance limits.
|
||||
packet data is untouched. This evidence supports region semantic equivalence,
|
||||
not raw-byte equality or an integrated latency claim. Preserve all calculations,
|
||||
pools, deadlines, admission/publication ownership and fresh qualification gates.
|
||||
|
||||
|
||||
## Compress full-page WAL images at the main PostgreSQL policy owner
|
||||
|
||||
- The failed9d2aa47 short run generated547,995,216 WAL bytes during1,800 ACKs,
|
||||
including its auxiliary and background work. A requested checkpoint overlapped
|
||||
the map outliers. This motivates reducing disk traffic without raising WAL or
|
||||
memory allowances; it does not establish the cause of every slow read.
|
||||
- PostgreSQL17 documents lossless compression of full-page WAL images and their
|
||||
decompression during replay, with extra logging/replay CPU:
|
||||
https://www.postgresql.org/docs/17/runtime-config-wal.html#GUC-WAL-COMPRESSION.
|
||||
Root's read-only BEGIN/SET LOCAL/ROLLBACK capability receipt at
|
||||
final-evidence/read-failure-668dd8b-ttdkqi77/wal-lz4-capability.json confirms
|
||||
lz4 is supported by both current PostgreSQL builds. Both returned to off after
|
||||
rollback, with fsync, full_page_writes and synchronous_commit on throughout.
|
||||
- Add wal_compression=lz4 to the existing shared main PostgreSQL command, with
|
||||
POSTGRES_WAL_COMPRESSION as an explicit normal-Compose override. DEV's clean
|
||||
environment uses the source default. Beacon's separate database command and
|
||||
CI's distinct policy remain unchanged. Preserve all pages, backups, durability,
|
||||
checkpoint settings, memory, CPU, worker and connection bounds.
|
||||
- Only full-page images are compressible under this setting, not all measured
|
||||
WAL. The I/O benefit and CPU cost require the existing next qualification run;
|
||||
no latency or resource pass is claimed. Extend the existing Compose policy
|
||||
tests for the default, override isolation and unchanged CI/resources.
|
||||
@@ -59,7 +59,7 @@ class LocalMemoryPolicy(unittest.TestCase):
|
||||
'shared_preload_libraries': 'timescaledb,pg_stat_statements',
|
||||
'max_parallel_workers_per_gather': '0', 'max_connections': '100',
|
||||
'shared_buffers': '256MB', 'maintenance_work_mem': '64MB',
|
||||
'autovacuum_work_mem': '32MB',
|
||||
'autovacuum_work_mem': '32MB', 'wal_compression': 'lz4',
|
||||
})
|
||||
self.assertEqual(database['image'], 'timescale/timescaledb@sha256:22e8a5ae7aef121d1537afe946dd7cc5deeeb63ab36ce19849d671bd3b663509')
|
||||
self.assertEqual(float(database['cpus']), 2)
|
||||
@@ -79,13 +79,15 @@ class LocalMemoryPolicy(unittest.TestCase):
|
||||
self.assertTrue(schema['read_only'])
|
||||
self.assertEqual(database['healthcheck']['test'], ['CMD-SHELL', 'pg_isready -h 127.0.0.1 -U meshcore -d meshcore'])
|
||||
|
||||
def test_postgres_memory_overrides_change_only_three_settings_without_changing_resources(self):
|
||||
def test_postgres_overrides_change_only_declared_settings_without_changing_resources(self):
|
||||
before = compose('scripts/local-sample/compose.yml')
|
||||
after = compose('scripts/local-sample/compose.yml', POSTGRES_SHARED_BUFFERS='512MB',
|
||||
POSTGRES_MAINTENANCE_WORK_MEM='128MB', POSTGRES_AUTOVACUUM_WORK_MEM='64MB')
|
||||
POSTGRES_MAINTENANCE_WORK_MEM='128MB', POSTGRES_AUTOVACUUM_WORK_MEM='64MB',
|
||||
POSTGRES_WAL_COMPRESSION='off')
|
||||
self.assertEqual(set(after), set(before))
|
||||
expected = self.postgres_settings(before['db'])
|
||||
expected.update(shared_buffers='512MB', maintenance_work_mem='128MB', autovacuum_work_mem='64MB')
|
||||
expected.update(shared_buffers='512MB', maintenance_work_mem='128MB',
|
||||
autovacuum_work_mem='64MB', wal_compression='off')
|
||||
self.assertEqual(self.postgres_settings(after['db']), expected)
|
||||
for service in before:
|
||||
if service != 'db':
|
||||
@@ -119,11 +121,12 @@ class LocalMemoryPolicy(unittest.TestCase):
|
||||
self.assertNotIn('random_page_cost', database)
|
||||
self.assertNotIn('effective_cache_size', database)
|
||||
|
||||
def test_ci_retains_its_distinct_database_capacity_and_is_not_affected_by_memory_overrides(self):
|
||||
def test_ci_retains_its_distinct_database_capacity_and_is_not_affected_by_policy_overrides(self):
|
||||
files = ('docker-compose.yml', 'docker-compose.ci.yml')
|
||||
before = compose(*files)['timescaledb']
|
||||
after = compose(*files, POSTGRES_SHARED_BUFFERS='512MB',
|
||||
POSTGRES_MAINTENANCE_WORK_MEM='128MB', POSTGRES_AUTOVACUUM_WORK_MEM='64MB',
|
||||
POSTGRES_WAL_COMPRESSION='off',
|
||||
DATABASE_ANALYTICS_RANDOM_PAGE_COST='2.5', DATABASE_ANALYTICS_EFFECTIVE_CACHE_SIZE='1GB')['timescaledb']
|
||||
self.assertEqual(after, before)
|
||||
self.assertEqual(int(before['mem_limit']), 4096 * MIB)
|
||||
|
||||
Reference in new issue
Block a user