Upgrading Semgrep from OCaml 4 to OCaml 5 + dynamic_gc utility

I’ve written up my experience upgrading Semgrep to OCaml 5. The main barrier we faced was increased memory consumption, but I was able to tune the garbage collector to address this problem. We have also open-sourced the utility I wrote to adjust the space_overhead GC parameter based on heap size. We are looking forward to taking advantage of all the great new features in OCaml 5!

19 Likes

You could include some named sample configurations in the module (could be inside a sub module Config). That way they become easy to use with { DynamicGc.Config.simple with heap_really_worry_mb = ...}.

I like that idea. I’m not entirely sure what sensible defaults would be, but perhaps something starting at space_overhead 120 (the default) and becoming somewhat more restrictive? I’ll think about it, and would also welcome PRs.

1 Like

Thanks for the excellent writeup Nat.

It is great that SemGrep was able to move to OCaml 5 with negligible performance impact compared to OCaml 4. As a matter of fact, other users reported that they saw reasonable performance only at very small space_overhead parameter. OCaml compiler devs are aware of the pacing issues and have been pushing some fixes in Jane Street’s OCaml compiler. These improvements will eventually be opened as upstream PRs after they’ve been tested at scale.

5 Likes