@@ -45,26 +45,29 @@ let tracker : (unit, unit) Gc.Memprof.tracker =
4545 Printexc.get_callstack in the other functions. Plus for some reason the
4646 memprof backtraces seem way more comprehensive than those from
4747 Printexc.get_callstack *)
48- let alloc_minor {Gc.Memprof. callstack; _} =
49- emit_point_event callstack ;
48+ let alloc_minor { Gc.Memprof. callstack; _ } =
49+ emit_point_event callstack;
5050 (* Don't care about tacking on any data to memory *)
5151 None
5252 in
53- let alloc_major {Gc.Memprof. callstack; _} =
54- emit_point_event callstack ; None
53+ let alloc_major { Gc.Memprof. callstack; _ } =
54+ emit_point_event callstack;
55+ None
5556 in
5657 let promote () = None in
5758 let dealloc_minor = Fun. id in
5859 let dealloc_major = Fun. id in
59- {Gc.Memprof. alloc_minor; alloc_major; promote; dealloc_minor; dealloc_major}
60+ { Gc.Memprof. alloc_minor; alloc_major; promote; dealloc_minor; dealloc_major }
6061
6162(* 1e-6 is nice but chosen somewhat randomly. Too high and you end up sending
6263 too many points and overwhelming the profiler, too little and you don't get
6364 enough info *)
6465let with_memprof_sampler ?(sampling_rate = 1e-6 ) f =
6566 let memprof = Gc.Memprof. start ~sampling_rate tracker in
6667 Fun. protect
67- ~finally: (fun () -> Gc.Memprof. stop () ; Gc.Memprof. discard memprof)
68+ ~finally: (fun () ->
69+ Gc.Memprof. stop () ;
70+ Gc.Memprof. discard memprof)
6871 f
6972
7073let maybe_with_memprof_sampler ?sampling_rate f =
@@ -74,7 +77,6 @@ let maybe_with_memprof_sampler ?sampling_rate f =
7477(* Profiler code *)
7578(* ****************************************************************************)
7679let create_cursor path pid = Runtime_events. create_cursor (Some (path, pid))
77-
7880let empty_callbacks = Runtime_events.Callbacks. create ()
7981
8082(* Minimize work we do in process event since the instrumented program can write
@@ -83,8 +85,7 @@ let process_event now interval sample_points = function
8385 | Point (time , raw_st ) ->
8486 if now -. time < interval then
8587 sample_points := (time, raw_st) :: ! sample_points
86- | Partial _ ->
87- ()
88+ | Partial _ -> ()
8889
8990let read_poll ?(max_events = None ) ?(callbacks = empty_callbacks) cursor
9091 interval =
@@ -97,7 +98,7 @@ let read_poll ?(max_events = None) ?(callbacks = empty_callbacks) cursor
9798 _event_t (e : marshaled ) ->
9899 e
99100 |> event_of_perf_event event_buffer
100- |> process_event now interval sample_points )
101+ |> process_event now interval sample_points)
101102 callbacks
102103 in
103104 (* TODO? Multithread this? *)
@@ -113,9 +114,9 @@ let read_poll ?(max_events = None) ?(callbacks = empty_callbacks) cursor
113114 don't have a sample within 1ms or some other resolution of the sample
114115 time *)
115116 List. sort (fun (a_time , _ ) (b_time , _ ) ->
116- Float. compare (now -. a_time) (now -. b_time) )
117+ Float. compare (now -. a_time) (now -. b_time))
117118 |> List. map (fun (_ , raw_st ) -> Stack_trace. t_of_raw_stack_trace raw_st)
118119 |> List. sort_uniq (fun a b ->
119- Int. compare a.Stack_trace. thread_id b.Stack_trace. thread_id )
120+ Int. compare a.Stack_trace. thread_id b.Stack_trace. thread_id)
120121 in
121122 sample_points
0 commit comments