---
title: "How posix_spawn & close_range “fixed” cold starts"
description: "Neon's Pageserver regressed cold-start and first-query-after-idle latency to seconds after it began shutting down idle per-tenant walredo sidecar processes."
url: "https://swe.quest/articles/how-posix-spawn-close-range-fixed-cold-starts-0c769ed6733a0a1b"
canonical: "https://neon.com/blog/posix_spawn-close_range-fixed-cold-starts"
source: "Neon"
published: "2024-02-21"
difficulty: "medium"
kind: "Incident"
reading_minutes: 14
tags: ["linux","performance","debugging","rust","postgres"]
---

# How posix\_spawn & close\_range “fixed” cold starts

A post on [Neon](https://swe.quest/sources/neon.md), published 2024-02-21, 14 min read, Incident. Original: [https://neon.com/blog/posix\_spawn-close\_range-fixed-cold-starts](https://neon.com/blog/posix_spawn-close_range-fixed-cold-starts)

## Summary

Neon's Pageserver regressed cold-start and first-query-after-idle latency to seconds after it began shutting down idle per-tenant walredo sidecar processes. Spawning them was slow because a pre\_exec hook (used to mark inherited file descriptors close-on-exec) forced Rust's std::process::Command to fall back from posix\_spawn to fork+exec. The real cost turned out to be the close\_fds crate's fallback: CLOSE\_RANGE\_CLOEXEC isn't supported on Linux 5.10, so it issued one fcntl per open FD, roughly 2s across ~200k descriptors. Moving a plain close\_range call into the walredo process itself cut basebackup latency from ~2s mean and ~10s p99 to the low hundreds of milliseconds.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Linux](https://swe.quest/tags/linux.md) (Infrastructure)
- [Performance engineering](https://swe.quest/tags/performance.md) (Reliability & operations)
- [Debugging](https://swe.quest/tags/debugging.md) (Engineering practices)
- [Rust](https://swe.quest/tags/rust.md) (Languages)
- [PostgreSQL](https://swe.quest/tags/postgres.md) (Data & databases)

## Prerequisites

- Unix process creation (fork/exec)
- file descriptors and FD\_CLOEXEC
- Postgres WAL basics ([easy posts on PostgreSQL](https://swe.quest/tags/postgres.md?difficulty=easy))

## Keywords

Neon, Pageserver, walredo, posix\_spawn, close\_range, strace, seccomp, close\_fds

## Related posts

- [parking\_lot: ffffffffffffffff...](https://swe.quest/articles/parking-lot-ffffffffffffffff-e7cd36eac4ddf5cc.md): Fly.io · 2025-05-28 · Hard · 16 min read · Concurrency, Rust, Debugging, Incidents & postmortems, Load balancing
  Fly.io's Rust Anycast router, fly-proxy, kept deadlocking after Catalog state was moved to lazy loading.
- [Why we rewrote WAL-G for Postgres backups in Rust: Meet WAL-RUS](https://swe.quest/articles/why-we-rewrote-wal-g-for-postgres-backups-in-rust-meet-wal-rus-a99cc2a7ede61ae3.md): ClickHouse · 2026-06-25 · Medium · 4 min read · PostgreSQL, Rust, Memory management, Storage systems, Go
  WAL-RUS is an open-source Rust rewrite of WAL-G's Postgres backup and WAL archival tooling, built because Go's garbage-collected runtime made virtual memory hard to predict in resource-constrained managed Postgres environments where overcommit is disabled.
- [Everyone gets faster writes: We turned off FPW's in Neon](https://swe.quest/articles/everyone-gets-faster-writes-we-turned-off-fpw-s-in-neon-60d0cd25f29077e7.md): Neon · 2026-05-07 · Hard · 7 min read · PostgreSQL, Storage engines, Performance engineering, Distributed databases
  Neon disabled Postgres full-page writes fleet-wide because its stateless compute streams WAL to a Paxos safekeeper quorum and has no local disk pages that can tear.
- [Zero-Downtime Patching Part 1: Prewarming](https://swe.quest/articles/zero-downtime-patching-part-1-prewarming-370c0c7ccc8bd249.md): Neon · 2026-03-27 · Medium · 4 min read · PostgreSQL, Deployment, Performance engineering, Caching
  Neon and Databricks Lakebase avoid the post-restart performance hit of cold Postgres caches by prewarming a replacement compute before planned maintenance.
- [Cold starts just got hot](https://swe.quest/articles/cold-starts-just-got-hot-2fb157f3acc4ca83.md): Neon · 2023-07-25 · Medium · 7 min read · Serverless, PostgreSQL, Performance engineering, System design
  Neon cut serverless Postgres compute cold starts from 3-6 seconds to roughly 500 ms by skipping work and reframing the problem.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
