Skip to content

Commit 8a2a718

Browse files
tracing: remove counters
1 parent dbf13b5 commit 8a2a718

File tree

7 files changed

+17
-28
lines changed

7 files changed

+17
-28
lines changed

src/core/lwt.ml

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1672,8 +1672,6 @@ include Pending_promises
16721672

16731673

16741674
let tracing_context = new_key ()
1675-
let tracing_counter = ref 0
1676-
let tracing_counter () = incr tracing_counter; !tracing_counter
16771675

16781676
module Sequential_composition :
16791677
sig
@@ -1908,7 +1906,6 @@ struct
19081906

19091907
let backtrace_bind loc_f loc_l add_loc p f =
19101908
let trace_context = Sequence_associated_storage.get tracing_context in
1911-
let trace_counter = tracing_counter () in
19121909
let Internal p = to_internal_promise p in
19131910
let p = underlying p in
19141911

@@ -1918,7 +1915,7 @@ struct
19181915
let saved_storage = !current_storage in
19191916

19201917
let callback p_result =
1921-
if trace then Lwt_rte.emit_trace End trace_context trace_counter loc_f loc_l;
1918+
if trace then Lwt_rte.emit_trace End trace_context loc_f loc_l;
19221919
match p_result with
19231920
| Fulfilled v ->
19241921
current_storage := saved_storage;
@@ -1962,7 +1959,7 @@ struct
19621959
to_public_promise {state = Rejected (add_loc exn)}
19631960

19641961
| Pending p_callbacks ->
1965-
Lwt_rte.emit_trace Begin trace_context trace_counter loc_f loc_l;
1962+
Lwt_rte.emit_trace Begin trace_context loc_f loc_l;
19661963
let (p'', callback) = create_result_promise_and_callback_if_deferred true () in
19671964
add_implicitly_removed_callback p_callbacks callback;
19681965
p''
@@ -2092,7 +2089,6 @@ struct
20922089

20932090
let backtrace_catch loc_f loc_l add_loc f h =
20942091
let trace_context = Sequence_associated_storage.get tracing_context in
2095-
let trace_counter = tracing_counter () in
20962092
let p =
20972093
try f ()
20982094
with exn when Exception_filter.run exn -> fail exn
@@ -2106,7 +2102,7 @@ struct
21062102
let saved_storage = !current_storage in
21072103

21082104
let callback p_result =
2109-
if traced then Lwt_rte.emit_trace End trace_context trace_counter loc_f loc_l;
2105+
if traced then Lwt_rte.emit_trace End trace_context loc_f loc_l;
21102106
match p_result with
21112107
| Fulfilled _ as p_result ->
21122108
let State_may_now_be_pending_proxy p'' = may_now_be_proxy p'' in
@@ -2151,7 +2147,7 @@ struct
21512147
(p'', callback, p.state))
21522148

21532149
| Pending p_callbacks ->
2154-
Lwt_rte.emit_trace Begin trace_context trace_counter loc_f loc_l;
2150+
Lwt_rte.emit_trace Begin trace_context loc_f loc_l;
21552151
let (p'', callback) = create_result_promise_and_callback_if_deferred true () in
21562152
add_implicitly_removed_callback p_callbacks callback;
21572153
p''
@@ -2233,7 +2229,6 @@ struct
22332229

22342230
let backtrace_try_bind loc_f loc_l add_loc f f' h =
22352231
let trace_context = Sequence_associated_storage.get tracing_context in
2236-
let trace_counter = tracing_counter () in
22372232
let p =
22382233
try f ()
22392234
with exn when Exception_filter.run exn -> fail exn
@@ -2247,7 +2242,7 @@ struct
22472242
let saved_storage = !current_storage in
22482243

22492244
let callback p_result =
2250-
if traced then Lwt_rte.emit_trace End trace_context trace_counter loc_f loc_l;
2245+
if traced then Lwt_rte.emit_trace End trace_context loc_f loc_l;
22512246
match p_result with
22522247
| Fulfilled v ->
22532248
current_storage := saved_storage;
@@ -2307,7 +2302,7 @@ struct
23072302
(p'', callback, p.state))
23082303

23092304
| Pending p_callbacks ->
2310-
Lwt_rte.emit_trace Begin trace_context trace_counter loc_f loc_l;
2305+
Lwt_rte.emit_trace Begin trace_context loc_f loc_l;
23112306
let (p'', callback) = create_result_promise_and_callback_if_deferred true () in
23122307
add_implicitly_removed_callback p_callbacks callback;
23132308
p''

src/core/lwt_rte.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ val emit_sch_call_end : unit -> unit
44
val emit_sch_lap : unit -> unit
55
val emit_job_count : int -> unit
66
type span = Begin | End
7-
val emit_trace : span -> string option -> int -> string -> int -> unit
7+
val emit_trace : span -> string option -> string -> int -> unit

src/core/lwt_rte.with.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ let emit_sch_call_end () = Lwt_runtime_events.emit_sch_call_end ()
44
let emit_sch_lap v = Lwt_runtime_events.emit_sch_lap v
55
let emit_job_count v = Lwt_runtime_events.emit_job_count v
66
type span = Runtime_events.Type.span = Begin | End
7-
let emit_trace kind context count filename line = Lwt_runtime_events.Trace.emit {kind; context; count; filename; line}
7+
let emit_trace kind context filename line = Lwt_runtime_events.Trace.emit {kind; context; filename; line}

src/core/lwt_rte.without.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ let emit_sch_call_end () = ()
44
let emit_sch_lap _v = ()
55
let emit_job_count _v = ()
66
type span = Begin | End
7-
let emit_trace _ _ _ _ _ = ()
7+
let emit_trace _ _ _ _ = ()

src/runtime_events/lwt_runtime_events.ml

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ module Trace = struct
2020
type t =
2121
{ kind: Runtime_events.Type.span;
2222
context: string option;
23-
count: int;
2423
filename: string;
2524
line: int; }
2625

@@ -38,9 +37,6 @@ module Trace = struct
3837
let offset = offset + 1 in
3938
let context = if context_size = 0 then None else Some (Bytes.sub_string b offset context_size) in
4039
let offset = offset + context_size in
41-
(* count *)
42-
let count = BytesLabels.get_uint16_be b offset in
43-
let offset = offset + 2 in
4440
(* line *)
4541
let line = Bytes.get_uint16_be b offset in
4642
let offset = offset + 2 in
@@ -50,9 +46,9 @@ module Trace = struct
5046
let filename = Bytes.sub_string b offset filename_size in
5147
let offset = offset + filename_size in
5248
assert (offset = i);
53-
{ kind; context; count; filename; line }
49+
{ kind; context; filename; line }
5450

55-
let encode b { kind; context; count; filename; line } =
51+
let encode b { kind; context; filename; line } =
5652
let offset = 0 in
5753
(* BEGIN|END *)
5854
Bytes.set b offset (match kind with Begin -> 'B' | End -> 'E');
@@ -67,9 +63,6 @@ module Trace = struct
6763
Bytes.blit_string context 0 b offset (String.length context);
6864
offset + String.length context
6965
in
70-
(* count *)
71-
Bytes.set_uint16_be b offset count;
72-
let offset = offset + 2 in
7366
(* line *)
7467
Bytes.set_uint16_be b offset line;
7568
let offset = offset + 2 in

src/runtime_events/lwt_runtime_events.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ val unix_job_count : int Runtime_events.User.t
1616
val emit_job_count : int -> unit
1717

1818
module Trace : sig
19-
type t = { kind: Runtime_events.Type.span; context: string option; count: int; filename: string; line: int; }
19+
type t = { kind: Runtime_events.Type.span; context: string option; filename: string; line: int; }
2020
val t : t Runtime_events.Type.t
2121

2222
type Runtime_events.User.tag += T

test/tracing/tailgate.ml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,11 @@ let simplify_fname fname =
3333
|> List.rev
3434
|> String.concat ""
3535

36-
let name_of { Lwt_runtime_events.Trace.context; count; filename; line; kind=_ } =
36+
let name_of { Lwt_runtime_events.Trace.context; filename; line; kind=_ } =
37+
let shortloc = simplify_fname filename ^ ":" ^ string_of_int line in
3738
match context with
38-
| Some c -> c ^ "#" ^ string_of_int count
39-
| None -> simplify_fname filename ^ ":" ^ string_of_int line ^ "#" ^ string_of_int count
39+
| Some c -> c ^ "@" ^ shortloc
40+
| None -> shortloc
4041

4142
let ts_to_us ts = Int64.(div ts (of_int 1000))
4243

@@ -50,7 +51,7 @@ let () =
5051
(fun rid t u x ->
5152
match Runtime_events.User.tag u with
5253
| Lwt_runtime_events.Trace.T -> begin
53-
let { Lwt_runtime_events.Trace.kind; context=_; count=_; filename; line } = x in
54+
let { Lwt_runtime_events.Trace.kind; context=_; filename; line } = x in
5455
Printf.fprintf oc
5556
"{\"name\": \"%s\", \"cat\": \"PERF\", \"ph\":\"%s\", \"ts\":%Ld, \"pid\": %d, \"tid\": %d, \"args\": {\"location\": \"%s:%d\"}},\n"
5657

0 commit comments

Comments
 (0)