From 4a22562bfad70383e2c5cfecf476423c6ce31429 Mon Sep 17 00:00:00 2001 From: curche <72807749+curche@users.noreply.github.com> Date: Tue, 10 Feb 2026 11:48:11 +0530 Subject: [PATCH 1/5] detect when lost events occur & report in summary Previously the runtime callback for whenever lost events occur only prints out that info into stdin With this commit, olly keeps note of lost events using a ref so as to print a warning towards the end of the summary --- lib/olly_common/launch.ml | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/olly_common/launch.ml b/lib/olly_common/launch.ml index 5ba4505..409cbd6 100644 --- a/lib/olly_common/launch.ml +++ b/lib/olly_common/launch.ml @@ -1,6 +1,16 @@ +let lost_event_count = ref 0 + +let update_lost_event_count num = + lost_event_count := !lost_event_count + num + let lost_events ring_id num = + update_lost_event_count num; Printf.eprintf "[ring_id=%d] Lost %d events\n%!" ring_id num +let print_warning_if_lost_events = fun () -> + if !lost_event_count <> 0 then + Printf.eprintf "\nWarning: Summary may be inaccurate since some runtime events were lost before they could be read.\nRefer to 'Missed events' section in repo README%!" + type subprocess = { alive : unit -> bool; cursor : Runtime_events.cursor; @@ -69,6 +79,7 @@ let exec_process (config : runtime_events_config) (argsl : string list) : | p, _ when p = child_pid -> false | _, _ -> assert false and close () = + print_warning_if_lost_events (); Runtime_events.free_cursor cursor; (* We need to remove the ring buffers ourselves because we told the child process not to remove them *) @@ -89,7 +100,9 @@ let attach_process (dir : string) (pid : int) : subprocess = Unix.kill pid 0; true with Unix.Unix_error (Unix.ESRCH, _, _) -> false - and close () = Runtime_events.free_cursor cursor in + and close () = + print_warning_if_lost_events (); + Runtime_events.free_cursor cursor in { alive; cursor; close; pid } let launch_process config (exec_args : exec_config) : subprocess = From a09ffdd7cf0c9a34acf0716e554b9d8184b8d6fd Mon Sep 17 00:00:00 2001 From: curche <72807749+curche@users.noreply.github.com> Date: Tue, 10 Feb 2026 12:04:27 +0530 Subject: [PATCH 2/5] add newline to warning message --- lib/olly_common/launch.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/olly_common/launch.ml b/lib/olly_common/launch.ml index 409cbd6..2f8ed39 100644 --- a/lib/olly_common/launch.ml +++ b/lib/olly_common/launch.ml @@ -9,7 +9,7 @@ let lost_events ring_id num = let print_warning_if_lost_events = fun () -> if !lost_event_count <> 0 then - Printf.eprintf "\nWarning: Summary may be inaccurate since some runtime events were lost before they could be read.\nRefer to 'Missed events' section in repo README%!" + Printf.eprintf "\nWarning: Summary may be inaccurate since some runtime events were lost before they could be read.\nRefer to 'Missed events' section in repo README\n\n%!" type subprocess = { alive : unit -> bool; From 9ee4bb5bd3dcd30e4b74db19c4bbf25be0311a4d Mon Sep 17 00:00:00 2001 From: curche <72807749+curche@users.noreply.github.com> Date: Tue, 10 Feb 2026 12:05:12 +0530 Subject: [PATCH 3/5] print warning after cleanup --- lib/olly_common/launch.ml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/olly_common/launch.ml b/lib/olly_common/launch.ml index 2f8ed39..6b16d9f 100644 --- a/lib/olly_common/launch.ml +++ b/lib/olly_common/launch.ml @@ -79,7 +79,6 @@ let exec_process (config : runtime_events_config) (argsl : string list) : | p, _ when p = child_pid -> false | _, _ -> assert false and close () = - print_warning_if_lost_events (); Runtime_events.free_cursor cursor; (* We need to remove the ring buffers ourselves because we told the child process not to remove them *) @@ -101,7 +100,6 @@ let attach_process (dir : string) (pid : int) : subprocess = true with Unix.Unix_error (Unix.ESRCH, _, _) -> false and close () = - print_warning_if_lost_events (); Runtime_events.free_cursor cursor in { alive; cursor; close; pid } @@ -151,8 +149,9 @@ let empty_config = } let olly config (exec_args : exec_config) = + let cleanup () = config.cleanup (); print_warning_if_lost_events () in config.init (); - Fun.protect ~finally:config.cleanup (fun () -> + Fun.protect ~finally:cleanup (fun () -> let runtime_config = { dir = config.runtime_events_dir; From 1cde718f99a13e021d952dbd14665e74b443d57d Mon Sep 17 00:00:00 2001 From: curche <72807749+curche@users.noreply.github.com> Date: Tue, 10 Feb 2026 19:28:04 +0530 Subject: [PATCH 4/5] Rephrase lost event warning lost events can also occur during tracing and so it didn't make sense to refer to just Summary in the warning message. An alternative idea was to add a new lost_event handler in config and only keep a counter during gc_stats while defaulting to the previous behaviour (just printing) while tracing. However, having a warning felt sensible for both tracing & gc_stats for now and we can address it in future if required --- lib/olly_common/launch.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/olly_common/launch.ml b/lib/olly_common/launch.ml index 6b16d9f..32b95c5 100644 --- a/lib/olly_common/launch.ml +++ b/lib/olly_common/launch.ml @@ -9,7 +9,7 @@ let lost_events ring_id num = let print_warning_if_lost_events = fun () -> if !lost_event_count <> 0 then - Printf.eprintf "\nWarning: Summary may be inaccurate since some runtime events were lost before they could be read.\nRefer to 'Missed events' section in repo README\n\n%!" + Printf.eprintf "\nWarning: Results may be inaccurate since some runtime events were lost before they could be read.\nRefer to 'Missed events' section in repo README\n\n%!" type subprocess = { alive : unit -> bool; From 9cbcf1e5575954c18b28c4a4a971f5728698648a Mon Sep 17 00:00:00 2001 From: curche <72807749+curche@users.noreply.github.com> Date: Wed, 11 Feb 2026 16:05:52 +0530 Subject: [PATCH 5/5] apply linting using fmt patch from ci --- lib/olly_common/launch.ml | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/lib/olly_common/launch.ml b/lib/olly_common/launch.ml index 32b95c5..6c6bb30 100644 --- a/lib/olly_common/launch.ml +++ b/lib/olly_common/launch.ml @@ -1,15 +1,19 @@ let lost_event_count = ref 0 - -let update_lost_event_count num = - lost_event_count := !lost_event_count + num +let update_lost_event_count num = lost_event_count := !lost_event_count + num let lost_events ring_id num = update_lost_event_count num; Printf.eprintf "[ring_id=%d] Lost %d events\n%!" ring_id num -let print_warning_if_lost_events = fun () -> +let print_warning_if_lost_events = + fun () -> if !lost_event_count <> 0 then - Printf.eprintf "\nWarning: Results may be inaccurate since some runtime events were lost before they could be read.\nRefer to 'Missed events' section in repo README\n\n%!" + Printf.eprintf + "\n\ + Warning: Results may be inaccurate since some runtime events were lost \ + before they could be read.\n\ + Refer to 'Missed events' section in repo README\n\n\ + %!" type subprocess = { alive : unit -> bool; @@ -99,8 +103,7 @@ let attach_process (dir : string) (pid : int) : subprocess = Unix.kill pid 0; true with Unix.Unix_error (Unix.ESRCH, _, _) -> false - and close () = - Runtime_events.free_cursor cursor in + and close () = Runtime_events.free_cursor cursor in { alive; cursor; close; pid } let launch_process config (exec_args : exec_config) : subprocess = @@ -149,7 +152,10 @@ let empty_config = } let olly config (exec_args : exec_config) = - let cleanup () = config.cleanup (); print_warning_if_lost_events () in + let cleanup () = + config.cleanup (); + print_warning_if_lost_events () + in config.init (); Fun.protect ~finally:cleanup (fun () -> let runtime_config =