Skip to content

Commit

Permalink
Use fiber_key
Browse files Browse the repository at this point in the history
  • Loading branch information
emberian authored Jan 10, 2024
1 parent 2b50e18 commit 81bc38f
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/lib/o1trace/webkit_event/o1trace_webkit_event.ml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ let new_event (k : event_kind) : event =
; tid = 0
}

let new_thread_event ?(include_name = false) thread_key tid event_kind =
let new_thread_event ?(include_name = "") thread_key tid event_kind =
{ (new_event event_kind) with
tid
; name = (if include_name then String.concat ~sep:"/" thread_key else "")
; name = include_name
}

(*
Expand Down Expand Up @@ -95,13 +95,14 @@ module T = struct
let on_job_enter (fiber : O1trace.Thread.Fiber.t) =
if fiber.id <> !most_recent_id then (
most_recent_id := fiber.id ;
emit_event (new_thread_event fiber.key fiber.id Thread_switch) )
emit_event (new_thread_event fiber.id Thread_switch) )

let on_job_exit _fiber _time_elapsed = ()

let on_new_fiber (fiber : O1trace.Thread.Fiber.t) =
let fullname = String.concat ~sep:"/" (O1trace.Thread.Fiber.fiber_key fiber) in
emit_event
(new_thread_event ~include_name:true fiber.key fiber.id New_thread)
(new_thread_event ~include_name:fullname fiber.id New_thread)

let on_cycle_end () =
if !emitted_since_cycle_ended then emit_event (new_event Cycle_end) ;
Expand All @@ -114,9 +115,7 @@ let start_tracing wr =
else (
current_wr := Some wr ;
emit_event (new_event Pid_is) ;
O1trace.Thread.iter_fibers ~f:(fun fiber ->
emit_event
(new_thread_event ~include_name:true fiber.key fiber.id New_thread) ) ;
O1trace.Thread.iter_fibers ~f:T.on_new_fiber ;
O1trace.Plugins.enable_plugin (module T) )

let stop_tracing () =
Expand Down

0 comments on commit 81bc38f

Please sign in to comment.