Skip to content

Conversation

tmcgilchrist
Copy link
Contributor

@tmcgilchrist tmcgilchrist commented Aug 14, 2025

Currently the documentation for this runtime option says "Output GC statistics at program exit." which might be interpreted as covering GC statistics for a multi-domain program. At least that's how I read it. Looking at the implementation in caml_do_exit it accesses caml_domain_state so is more accurately described as printing the initial domain's GC stats.

The code in question https://github.com/ocaml/ocaml/blob/trunk/runtime/sys.c#L135-L181

This documentation update applies since OCaml 5.0. Probably doesn't need an entry in Changes.

@nojb
Copy link
Contributor

nojb commented Sep 3, 2025

Discussed at today's triage meeting. Instead of documenting the current behaviour, we should fix the code so that GC stats for the whole program are printed at program exit.

@gasche
Copy link
Member

gasche commented Sep 3, 2025

caml_compute_gc_stats is supposed to compute global statistics for all domains, not just domain-local statistics. It is possible that there is a bug in this function, but I'm not sure that there actually is an issue. (It should be even easier to reason about programs that have cleanly joined all their extra domains before termination, but in theory the gc-stats machinery tries to return something not wildly inaccurate even if the other domains are still running.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants