Improving Lakebase Postgres Compute Cache on Neon, Part 1
On large fixed-size Lakebase Postgres computes, Neon now disables its NVMe-backed local file cache and sets shared buffers to 75% of DRAM (up from a 1 GB cap), backed by explicit 2 MB HugeTLB pages provisioned through host, hypervisor and guest VM. Huge pages cut per-backend page table overhead by 512× and reduce TLB misses, lowering tail read latency by up to ~40% and CPU by up to ~30% in benchmarks. Production endpoints saw up to 2× throughput, 5× fewer storage GetPage requests and 5× lower CPU, with near-100% cache hit rates. Autoscaling computes with dynamic shared buffers are planned for part 2.
Related posts
- Separation of storage and compute without a performance tradeoff
Neon easyNovice
Neon's Local File Cache (LFC) sits between Postgres shared buffers and Neon's remote multi-tenant page storage. It uses the Linux page cache for RAM-like latency and can spill to local NVMe, so Neon keeps elastic, decoupled storage while matching local-disk Postgres performance. On a TPCC-like sysbench benchmark at 8CU, a 500GB LFC raised QPS from 12,512 to 17,030 and cut p99 latency from 593ms to 384ms, close to a local-disk setup needing 929GB. Sizing the LFC to the estimated working set (180GB) lost only about 10% of peak QPS.
- Dynamically estimating and scaling Postgres’ working set size
Neon mediumAdept
Neon autoscales Postgres compute to keep the workload's working set in memory, using a modified HyperLogLog whose register bits are replaced with timestamps so the number of distinct pages accessed can be estimated for any lookback window. A heuristic scans windows from a 5-minute offset up to one hour and treats the point where the estimate jumps sharply as the end of the current workload's plateau. Scaling then projects working set growth to avoid repeated cache evictions. In benchmarks this matched fixed-size compute performance at 30% lower cost, roughly tripled throughput on a bursty pgbench workload, and raised cache hit rate from 30-70% to 100% on a batch workload.
- How we configure huge pages in ClickHouse Managed Postgres
ClickHouse mediumAdept
ClickHouse Managed Postgres runs every server's shared_buffers on 2MB huge pages, which avoids per-backend page-table bloat and improves TLB reach. The setup has three parts. A quarter of RAM is reserved as huge pages before Postgres starts, after dropping caches and compacting memory. Postgres is pinned to huge_pages='on' so it fails at boot instead of silently falling back to 4KB pages. shared_buffers is sized in two passes using `postgres -C shared_memory_size` so the full segment, including roughly 750MB of overhead, fits the pool. On an r7i.4xlarge with 32GB shared_buffers, page tables grew 31MB per connection with 4KB pages (6.1GB at 200 connections) versus 111MB total with huge pages, and select-only pgbench throughput rose 12%.
- Zero-Downtime Patching Part 1: Prewarming
Neon mediumAdept
Neon and Databricks Lakebase avoid the post-restart performance hit of cold Postgres caches by prewarming a replacement compute before planned maintenance. Shortly before the scheduled restart, the control plane starts a hidden new compute, sends it the list of pages in the primary's cache, and loads them from shared storage. It then tails WAL from Safekeepers, applying only records that touch cached pages, and finally promotes it with pg_promote without restarting the server. In 10 GB pgbench tests, throughput recovers almost immediately with prewarming, compared with a roughly 70% TPS drop and slow recovery on a cold restart, with the largest gain on read-only workloads.
- Recent Storage Performance Improvements at Neon
Neon hardMaster
Neon shipped a set of storage-layer optimizations across Safekeepers and Pageservers. WAL is now decoded once at Safekeepers and routed only to the relevant shard, which roughly doubles ingest throughput for large tenants. Protobuf-encoded, Zstd-compressed WAL cuts Safekeeper-to-Pageserver bandwidth by about 70%. Sparse files via ftruncate and fewer fsyncs give about 3.3x WAL write throughput. Scan prefetching of up to 100 pages made schema finalization 4x faster, prioritizing L0 compaction with ingest backpressure halved p99 read amplification, pipelined parallel S3 uploads doubled upload rate, and a graduated shard split policy (4/8/16 shards at 16 GB/1 TB/2 TB) improves mid-size and very large tenants.