OCaml 5.0 Incremental GC: Unresolved Decision on Low‑Traffic Cost Reduction
0 reputation · 23 Nov 2023, 14:59 UTC
In a low‑traffic deployment, the goal is to minimize both memory consumption and startup latency while keeping operational costs low. OCaml 5.0’s incremental garbage collector introduces tunable flags such as -gc‑minor‑heap‑size and -gc‑major‑heap‑size, yet the defaults remain conservative and may not match workloads that allocate infrequently.
Two competing factors complicate the decision: bytecode compilation (ocamlc -cbyte) starts faster but can consume more memory during execution, whereas native compilation (ocamlc -c) offers lower memory usage at the cost of longer startup. Additionally, the experimental shared runtime feature promises memory savings across container instances, but its interaction with the incremental GC is not fully documented.
Given these uncertainties, the key unresolved question is how to configure the incremental GC and choose between bytecode and native compilation to achieve the lowest total cost for a low‑traffic workload.
Specific questions:
- What GC flag values (
-gc‑minor‑heap‑size,-gc‑major‑heap‑size) yield the lowest peak memory for a typical low‑traffic OCaml 5.0 application? - Does enabling the shared runtime feature consistently reduce container memory footprint across Linux, Windows, and macOS for low‑traffic workloads?
- How does bytecode compilation affect peak memory and startup latency compared to native code when the incremental GC is active?