Skip to content

Commit

Permalink
Add -min-trigger-time to delay installing breakpoint
Browse files Browse the repository at this point in the history
This allows capturing traces with `-trigger` symbols that get called
with very high (possibly bursty) frequency, where we otherwise migt
trigger before the snapshot buffer has a chance to fill up.

Closes janestreet#56.

Signed-off-by: Tudor Brindus <[email protected]>
  • Loading branch information
Xyene committed Apr 10, 2022
1 parent 9db29e6 commit c846898
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/trace.ml
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ module Make_commands (Backend : Backend_intf.S) = struct
type t =
{ backend_opts : Backend.Record_opts.t
; multi_snapshot : bool
; min_trigger_span : Time.Span.t
; when_to_snapshot : When_to_snapshot.t
; record_dir : string
; executable : string
Expand Down Expand Up @@ -228,6 +229,7 @@ module Make_commands (Backend : Backend_intf.S) = struct
| None -> Deferred.unit
| Some { Elf.Stop_info.name; addr; _ } ->
Core.eprintf "[Attaching to %s @ 0x%016Lx]\n%!" name addr;
let%bind () = Async_unix.after opts.min_trigger_span in
(* This is a safety feature so that if you accidentally attach to a symbol that
gets called very frequently, in single snapshot mode it will only trigger the
breakpoint once before the breakpoint gets disabled. In [multi_snapshot] mode
Expand Down Expand Up @@ -339,6 +341,14 @@ module Make_commands (Backend : Backend_intf.S) = struct
materially impacted.\n\
(2) Each snapshot linearly increases the size of the trace file. Large trace \
files may crash the trace viewer."
and min_trigger_span =
flag
"-min-trigger-time"
(optional_with_default Time.Span.zero Time_unix.Span.arg_type)
~doc:
"SPAN Ignore [-trigger] symbol hits that occur earlier than this. Allows \
collecting meaningful traces for symbols that are called very frequently. \
Accepts time units, e.g. '100ms'."
and trace_mode = Trace_mode.param
and timer_resolution = Timer_resolution.param
and backend_opts = Backend.Record_opts.param in
Expand All @@ -358,6 +368,7 @@ module Make_commands (Backend : Backend_intf.S) = struct
f
{ Record_opts.backend_opts
; multi_snapshot
; min_trigger_span
; when_to_snapshot
; record_dir
; executable
Expand Down

0 comments on commit c846898

Please sign in to comment.