Forty Gigabytes To Spawn

A search service keeps a 40 GiB in-memory index in a single multi-threaded process. Roughly once a second it shells out to a small helper binary using the usual fork() then execvp() pair. Tail latency shows a spike on every spawn, even though the helper itself finishes in 8 ms.

Which change addresses the actual cost?

A

Raise the helper's nice value so it stops competing with the search threads for CPU

B

Replace the pair with posix_spawn(), which on Linux creates the child with CLONE_VM | CLONE_VFORK and never duplicates the parent's page tables

C

Keep fork() plus execvp(). Copy-on-write means no index pages are copied, so the spawn is already close to free

D

Call fork() from a dedicated spawner thread so the request-serving threads are not the ones paying the cost