New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
incorrect GC statistics on program exit #11663
Comments
I think the answer is unfortunately rather trivial. If you look at the code of |
Thanks for the analysis! I haven't checked but it makes sense.
Why "unfortunately"? I like when bugs have simple fixes. Are you planning to submit a bugfix PR, or should I try to do it based on your analysis? P.S.: yes, we should rewrite the computation of |
I was hoping that I would learn more about the multicore GC in the process, but in the end there wasn't much to look at outside the GC stats computation. I did take the opportunity to look at the shared heap implementation though, so not everything is lost.
I'm not planning a PR, but if we forget about this long enough for the stale bot to complain I'll probably feel guilty enough to write and submit a patch. |
(It would be more work, more useful and more interesting to compute proper maxima at the end of each major GC cycle, to get a meaningful value instead of our shoddy sum of local maxima. I'm not planning to work on this just yet.) |
In some cases the option
OCAMLRUNPARAM="v=0x400
, which prints GC statistics on program exit, reports incorrect statistics on trunk (and I suppose 5.0).Repro case:
On my machine, running this program on trunk with
OCAMLRUNPARAM="v=0x400"
shows GC stats on program exit with the following:it makes no sense to have
heap_words > top_heap_words
, clearly the statistics are wrong.(On my machine, the wrong result is deterministic with these constants in the repro case, but with other constants only some runs would have this wrong property.)
Adding a call to
Gc.major ()
at the end of the program fixes the issue.(Calling
Gc.full_major ()
also works and decreases the finalheap_words
value by a lot.)It is known that statistics are only in a partially-inconsistent state in-between two major GCs, and that some statistics can only be trusted at the end of each GC cycle. The observed behavior is still clearly a bug. Forcing a major collection cycle on program exit in v=0x400 mode would fix the observed behavior, but I suspect that it would only hide the underlying bug -- I don't see why it would ever be correct to have
heap_words > top_heap_words
, even in-between cycles.The text was updated successfully, but these errors were encountered: