Skip to content

Commit cd0ecca

Browse files
committed
Avoid unnecessary gc_collect_cycles if there's no open span
This can be significant in terms of performance during shutdown, especially if it happens for no actual reason. Signed-off-by: Bob Weinand <[email protected]>
1 parent 4fb6495 commit cd0ecca

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

ext/span.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,8 +1132,10 @@ void ddtrace_serialize_closed_spans_with_cycle(ddog_TracesBytes *traces) {
11321132
// We need to loop here, as closing the last span root stack could add other spans here
11331133
while (DDTRACE_G(top_closed_stack)) {
11341134
ddtrace_serialize_closed_spans(traces);
1135-
// Also flush possible cycles here
1136-
gc_collect_cycles();
1135+
if (DDTRACE_G(open_spans_count)) {
1136+
// Also flush possible cycles here, if there are remaining open spans
1137+
gc_collect_cycles();
1138+
}
11371139
}
11381140
}
11391141

0 commit comments

Comments
 (0)