Skip to content

Add basic support for tracing#1524

Merged
baijumeswani merged 6 commits intomainfrom
edgchen1/tracing
Jun 10, 2025
Merged

Add basic support for tracing#1524
baijumeswani merged 6 commits intomainfrom
edgchen1/tracing

Conversation

@edgchen1
Copy link
Contributor

@edgchen1 edgchen1 commented Jun 3, 2025

Add some basic support for tracing. Currently, we can record durations in a timeline. This is useful for understanding how long different pieces of code take to run.

Tracing can be enabled with CMake build option ENABLE_TRACING.

@edgchen1 edgchen1 requested a review from baijumeswani June 3, 2025 19:36
@baijumeswani
Copy link
Collaborator

Could you maybe post a snippet of what the output trace looks like and how it gets rendered through perfetto?

@baijumeswani
Copy link
Collaborator

Looks good.

@edgchen1
Copy link
Contributor Author

edgchen1 commented Jun 7, 2025

Could you maybe post a snippet of what the output trace looks like and how it gets rendered through perfetto?

sure, here's a screenshot from Perfetto UI:
image

and some of the trace file:

[{"name": "Generator::AppendTokens", "cat": "perf", "ph": "B", "pid": 0, "tid": 14528, "ts": 9},
{"name": "DecoderOnlyPipelineState::Run", "cat": "perf", "ph": "B", "pid": 0, "tid": 14528, "ts": 33},
{"name": "DecoderOnlyPipelineState::RunPipeline[0]", "cat": "perf", "ph": "B", "pid": 0, "tid": 14528, "ts": 2291},
{"name": "State::Run", "cat": "perf", "ph": "B", "pid": 0, "tid": 14528, "ts": 2299},
{"cat": "perf", "ph": "E", "pid": 0, "tid": 14528, "ts": 10115},
{"cat": "perf", "ph": "E", "pid": 0, "tid": 14528, "ts": 10150},
{"name": "DecoderOnlyPipelineState::RunPipeline[1]", "cat": "perf", "ph": "B", "pid": 0, "tid": 14528, "ts": 10154},
{"name": "State::Run", "cat": "perf", "ph": "B", "pid": 0, "tid": 14528, "ts": 10162},
{"cat": "perf", "ph": "E", "pid": 0, "tid": 14528, "ts": 10720},
{"cat": "perf", "ph": "E", "pid": 0, "tid": 14528, "ts": 10734},
{"name": "DecoderOnlyPipelineState::RunPipeline[2]", "cat": "perf", "ph": "B", "pid": 0, "tid": 14528, "ts": 10737},
{"name": "State::Run", "cat": "perf", "ph": "B", "pid": 0, "tid": 14528, "ts": 10756},
{"cat": "perf", "ph": "E", "pid": 0, "tid": 14528, "ts": 104758},
{"cat": "perf", "ph": "E", "pid": 0, "tid": 14528, "ts": 104800},
{"name": "DecoderOnlyPipelineState::RunPipeline[3]", "cat": "perf", "ph": "B", "pid": 0, "tid": 14528, "ts": 104805},
{"name": "State::Run", "cat": "perf", "ph": "B", "pid": 0, "tid": 14528, "ts": 104829},
{"cat": "perf", "ph": "E", "pid": 0, "tid": 14528, "ts": 230213},
{"cat": "perf", "ph": "E", "pid": 0, "tid": 14528, "ts": 230246},
{"name": "DecoderOnlyPipelineState::RunPipeline[4]", "cat": "perf", "ph": "B", "pid": 0, "tid": 14528, "ts": 230250},
{"name": "State::Run", "cat": "perf", "ph": "B", "pid": 0, "tid": 14528, "ts": 230279},
{"cat": "perf", "ph": "E", "pid": 0, "tid": 14528, "ts": 326432},
{"cat": "perf", "ph": "E", "pid": 0, "tid": 14528, "ts": 326487},
{"name": "DecoderOnlyPipelineState::RunPipeline[5]", "cat": "perf", "ph": "B", "pid": 0, "tid": 14528, "ts": 326492},
{"name": "State::Run", "cat": "perf", "ph": "B", "pid": 0, "tid": 14528, "ts": 326524},
{"cat": "perf", "ph": "E", "pid": 0, "tid": 14528, "ts": 443239},
{"cat": "perf", "ph": "E", "pid": 0, "tid": 14528, "ts": 443285},
{"name": "DecoderOnlyPipelineState::RunPipeline[10]", "cat": "perf", "ph": "B", "pid": 0, "tid": 14528, "ts": 443290},
{"name": "State::Run", "cat": "perf", "ph": "B", "pid": 0, "tid": 14528, "ts": 443300},
{"cat": "perf", "ph": "E", "pid": 0, "tid": 14528, "ts": 449290},
{"cat": "perf", "ph": "E", "pid": 0, "tid": 14528, "ts": 449318},
{"cat": "perf", "ph": "E", "pid": 0, "tid": 14528, "ts": 449368},
{"cat": "perf", "ph": "E", "pid": 0, "tid": 14528, "ts": 449374},
...

add [[nodiscard]] on DurationTrace ctors
@baijumeswani baijumeswani merged commit 31a00fc into main Jun 10, 2025
14 checks passed
@baijumeswani baijumeswani deleted the edgchen1/tracing branch June 10, 2025 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants