# Garbage collection pause statistics?

**URL:** <https://discuss.ocaml.org/t/garbage-collection-pause-statistics/12867>\
**Category:** Ecosystem\
**Tags:** runtime\
**Created:** [August 21, 2023, 11:47am UTC](https://discuss.ocaml.org/t/garbage-collection-pause-statistics/12867 "2023-08-21T11:47:34Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![AndrasKovacs](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/andraskovacs/32/4638_2.png) [@AndrasKovacs](https://discuss.ocaml.org/u/AndrasKovacs)\
**Post date:** [August 21, 2023, 11:47am UTC](https://discuss.ocaml.org/t/garbage-collection-pause-statistics/12867/1 "2023-08-21T11:47:34Z")

</div>

I’d like to get information about GC pauses, for OCaml 5.0.0 (and above). Looking at [Module Gc](https://v2.ocaml.org/api/Gc.html), 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.

---

<div class="post-metadata">

**Author:** ![kayceesrk](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/kayceesrk/32/1936_2.png) [@kayceesrk](https://discuss.ocaml.org/u/kayceesrk)\
**Post date:** [August 21, 2023, 11:54am UTC](https://discuss.ocaml.org/t/garbage-collection-pause-statistics/12867/2 "2023-08-21T11:54:41Z")

</div>

Check out [GitHub - tarides/runtime\_events\_tools](https://github.com/tarides/runtime_events_tools#olly) 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.

---

<div class="post-metadata">

**Author:** ![AndrasKovacs](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/andraskovacs/32/4638_2.png) [@AndrasKovacs](https://discuss.ocaml.org/u/AndrasKovacs)\
**Post date:** [August 21, 2023, 12:41pm UTC](https://discuss.ocaml.org/t/garbage-collection-pause-statistics/12867/3 "2023-08-21T12:41:16Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![vlaviron](https://avatars.discourse-cdn.com/v4/letter/v/ec9cab/32.png) [@vlaviron](https://discuss.ocaml.org/u/vlaviron)\
**Post date:** [August 21, 2023, 1:12pm UTC](https://discuss.ocaml.org/t/garbage-collection-pause-statistics/12867/4 "2023-08-21T13:12:12Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![AndrasKovacs](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/andraskovacs/32/4638_2.png) [@AndrasKovacs](https://discuss.ocaml.org/u/AndrasKovacs)\
**Post date:** [August 21, 2023, 1:26pm UTC](https://discuss.ocaml.org/t/garbage-collection-pause-statistics/12867/5 "2023-08-21T13:26:57Z")

</div>

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

```auto
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.

---

<div class="post-metadata">

**Author:** ![vlaviron](https://avatars.discourse-cdn.com/v4/letter/v/ec9cab/32.png) [@vlaviron](https://discuss.ocaml.org/u/vlaviron)\
**Post date:** [August 21, 2023, 2:18pm UTC](https://discuss.ocaml.org/t/garbage-collection-pause-statistics/12867/6 "2023-08-21T14:18:55Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![kayceesrk](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/kayceesrk/32/1936_2.png) [@kayceesrk](https://discuss.ocaml.org/u/kayceesrk)\
**Post date:** [August 21, 2023, 3:46pm UTC](https://discuss.ocaml.org/t/garbage-collection-pause-statistics/12867/7 "2023-08-21T15:46:04Z")

</div>

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.
