janestreet / janestreet/memtrace

Would be nice to show (OCaml + custom) heap size

Open
#24 0 comments 0 reactions 0 assignees View on GitHub
forwarded-to-js-devs
Dominant language
OCaml
Stars
87
Forks
26
PR merge metrics
No merged PRs in 30d

Description

Memtrace currently shows live allocations, however when investigating Gc behaviour you might also want to see the OCaml and C heap size (to see the effect of fragmentation, Gc pacing, compaction, etc.), and finding the point in the program with peak memory usage
(which may not always coincide with the point of peak live memory usage).

This would be especially useful for a program that uses bigarrays, where you'd want to find out why the GC is seemingly not freeing it as quickly as you'd expect it to (which may [turn out to be a bug in the runtime](https://github.com/ocaml/ocaml/pull/14825)).

There are workarounds for approximating this information (`live` at `peak` filter, or showing only allocations in the major heap with a lifetime >1s), although that still leaves the Gc accounting behaviour invisible, and you can only find the peak live memory.

A workaround is to use `/usr/bin/time` to get a MaxRSS for the lifetime of the program (or to periodically sample maxRSS as the application is running), but would be nice if either memtrace or olly supported this.

Related: https://github.com/tarides/runtime_events_tools/issues/91

Contributor guide

Open the contributing guide

Research direction

Start by reviewing how memtrace and olly currently report live allocations, then consult the related runtime_events_tools issue for context. Define how OCaml heap size, C heap size, and peak memory usage should be represented; the work is done when one of these tools exposes the requested GC accounting and peak-usage information.

Written by the indexing model from the issue text.

Assessment

Tech stack
ocaml
Domain
devtools, performance
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.