Skip to content

Commit

Permalink
Report current heap usage on Merlin response (ocaml#1717)
Browse files Browse the repository at this point in the history
from Engil/heap_usage_on_response
  • Loading branch information
voodoos authored Dec 13, 2023
2 parents b06a4e4 + ece0ca9 commit d989b6b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
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'

0 comments on commit d989b6b

Please sign in to comment.