Garbage collection pause statistics?

I’d like to get information about GC pauses, for OCaml 5.0.0 (and above). Looking at Module Gc, I only see the verbosity option 0x001 which looks like it might be used to get such information, but when I enabled it it apparently printed nothing.

Check out GitHub - tarides/runtime_events_tools for GC pauses.

If you see no output, it might be the case that no major GCs were performed. You can use verbosity 0x400 to print the count of the major and minor GCs. If you see major cycles but no other output with 0x401 or 0x1, it might indicate a bug.

Thanks for the link, it works nicely.

Using 0x401 I get the statistics on exit, which tells me that there were 380 major collections. I get the same output with 0x400, so 0x001 apparently doesn’t print anything. This is on OCaml 5.0.0.

Could you try setting verbosity using the OCAMLRUNPARAM environment variable ? Something like OCAMLRUNPARAM='v=0x001' ./my_program.exe on Unix-like systems.
It would be interesting to know if you get the same output or not.

I’m actually using OCAMLRUNPARAM on Ubuntu right now. I give a concrete example here which is hopefully reproducible. I have test.ml:

type tree
  = Node of tree * tree
  | Leaf of int

let rec mktree (n : int) =
  let rec go n n = match (n, n) with
    | 0, _ -> Leaf(0)
    | _, 0 -> Leaf(0)
    | n, m -> Node(go (n - 1) (m - 1), go (m - 1) (n - 1)) in
  go n n

let () =
  print_string "prog start\n\n";
  for i = 0 to 10 do
    let _ = mktree 20 in
    ()
  done

Then I hit export OCAMLRUNPARAM='v=0x401';ocamlc test.ml -o test;./test or the same with ocamlopt, and I get major collections but apparently no 0x1 output. I’m on Ubuntu 22.04.2 and OCaml 5.0.0.

Apparently most of the verbosity flags have not been ported to OCaml 5. The one that prints stats at the end (0x400) appears to be the only exception.

@kayceesrk do you know if there is any plan to restore support for them ? I guess it would be complicated to do it for multiple domains, but we might be able to support it until a new domain has been spawned.
Either way, we should probably update the documentation of the Gc module to clarify that the verbosity values outside 0x400 don’t work at the moment.

It might be useful to make an issue first that this option is broken. I’d like to see it fixed, as you say, at least until the first domain is spanwed.