From 10181c9a49c6ad41b500d239abb22752feab0853 Mon Sep 17 00:00:00 2001 From: Enguerrand Decorne Date: Wed, 29 Nov 2023 12:00:40 +0100 Subject: [PATCH 1/4] Introduce heap usage (in megabytes) in Merlin responses Co-authored-by: Sonja Heinze --- src/frontend/ocamlmerlin/new/new_merlin.ml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/frontend/ocamlmerlin/new/new_merlin.ml b/src/frontend/ocamlmerlin/new/new_merlin.ml index 2d6f16808b..ea555801a9 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 * 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); From 8091bf5981b675f453f0f63d4907150611fd7e69 Mon Sep 17 00:00:00 2001 From: Enguerrand Decorne Date: Wed, 29 Nov 2023 12:03:32 +0100 Subject: [PATCH 2/4] Use Sys.word_size for the conversion to megabytes in merlin response Co-authored-by: Sonja Heinze --- src/frontend/ocamlmerlin/new/new_merlin.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/frontend/ocamlmerlin/new/new_merlin.ml b/src/frontend/ocamlmerlin/new/new_merlin.ml index ea555801a9..446ce1aaa5 100644 --- a/src/frontend/ocamlmerlin/new/new_merlin.ml +++ b/src/frontend/ocamlmerlin/new/new_merlin.ml @@ -121,7 +121,7 @@ let run = function in let cpu_time = Misc.time_spent () -. start_cpu in let gc_stats = Gc.quick_stat () in - let heap_mbytes = gc_stats.heap_words * 8 / 1_000_000 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 = From 71ee5f9ae42d189c199aa46ceb36ab9280dc4d49 Mon Sep 17 00:00:00 2001 From: Enguerrand Decorne Date: Wed, 29 Nov 2023 12:09:45 +0100 Subject: [PATCH 3/4] Filter heap_mbytes from the responses in merlin-wrapper Co-authored-by: Sonja Heinze --- tests/merlin-wrapper | 1 + 1 file changed, 1 insertion(+) 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' From ece0ca902ef8488b33f2068df81cbc47c4505246 Mon Sep 17 00:00:00 2001 From: Enguerrand Decorne Date: Tue, 12 Dec 2023 11:11:19 +0100 Subject: [PATCH 4/4] add a CHANGES entry --- CHANGES.md | 6 ++++++ 1 file changed, 6 insertions(+) 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