Skip to content
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

Report current heap usage on Merlin response #1717

Merged
merged 4 commits into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
merlin NEXT_VERSION
===================

+ merlin binary
- Add a "heap_mbytes" field to Merlin server responses to report heap usage (#1717)

merlin 4.13
===========
Fri Dec 1 15:00:42 CET 2023
Expand Down
5 changes: 4 additions & 1 deletion src/frontend/ocamlmerlin/new/new_merlin.ml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ let run = function
("error", `String (Format.flush_str_formatter ()))
in
let cpu_time = Misc.time_spent () -. start_cpu in
let gc_stats = Gc.quick_stat () in
let heap_mbytes = gc_stats.heap_words * (Sys.word_size / 8) / 1_000_000 in
let clock_time = Unix.gettimeofday () *. 1000. -. start_clock in
let timing = Mpipeline.timing_information pipeline in
let pipeline_time =
Expand All @@ -134,7 +136,8 @@ let run = function
`Assoc [
"class", `String class_; "value", message;
"notifications", `List (List.rev_map notify !notifications);
"timing", `Assoc (List.map format_timing timing)
"timing", `Assoc (List.map format_timing timing);
"heap_mbytes", `Int heap_mbytes
]
in
log ~title:"run(result)" "%a" Logger.json (fun () -> json);
Expand Down
1 change: 1 addition & 0 deletions tests/merlin-wrapper
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ fi

ocamlmerlin "$@" \
| jq 'del(.timing)' \
| jq 'del(.heap_mbytes)' \
| sed -e 's:"[^"]*lib/ocaml:"lib/ocaml:g' \
| sed -e 's:\\n:\
:g'