diff --git a/CHANGES.md b/CHANGES.md index 4d8107b8ec..c64e869f21 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -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 diff --git a/src/frontend/ocamlmerlin/new/new_merlin.ml b/src/frontend/ocamlmerlin/new/new_merlin.ml index 2d6f16808b..446ce1aaa5 100644 --- a/src/frontend/ocamlmerlin/new/new_merlin.ml +++ b/src/frontend/ocamlmerlin/new/new_merlin.ml @@ -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 = @@ -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); diff --git a/tests/merlin-wrapper b/tests/merlin-wrapper index 3f40e5e103..b343c6cb26 100755 --- a/tests/merlin-wrapper +++ b/tests/merlin-wrapper @@ -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'