Skip to content

Commit

Permalink
chore(docs): add tracing conventions
Browse files Browse the repository at this point in the history
  • Loading branch information
batzor committed Aug 8, 2024
1 parent eac3c62 commit 1e7bee9
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions docs/how_to_contribute/conventions.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,23 @@ We use `VLOG` messages in our code to show us the progress of the current runnin
- Output of the proof
- Output of the verifying key serialization

## Profiling with Perfetto

We are currently using Perfetto for tracing and profiling Tachyon. Perfetto provides two primary macros for tracing events: `TRACE_EVENT()` and `TRACE_EVENT_BEGIN()`|`TRACE_EVENT_END()`.

- **`TRACE_EVENT()`**: Use this macro when you want the trace slice to continue until the scope in which it is defined ends. This is the preferred method whenever possible, as it simplifies the code and ensures the trace slice duration is managed by the scope itself.

- **`TRACE_EVENT_BEGIN()` and `TRACE_EVENT_END()`**: Use these macros when you need to manually specify the beginning and end of a trace slice. This approach is suitable for tracing code segments that are too long or complex for a single scope, where adding a scope would be impractical.

### Conventions

- **Preferred Usage**: Always try to use `TRACE_EVENT()` whenever possible for its simplicity and automatic scope management.
- **Manual Tracing**: Use `TRACE_EVENT_BEGIN()` and `TRACE_EVENT_END()` for longer or more complex code segments where adding a new scope is not feasible.

### Trace Categories

The trace categories are defined in the [`profiler.h`](https://github.com/kroma-network/tachyon/blob/main/tachyon/base/profiler.h) header. When defining trace names, avoid adding scope to the trace name whenever possible. For example, private functions that are always called from other functions with a scoped trace name do not need their own scoped trace name.

## Commits

### Commit Type Classification
Expand Down

0 comments on commit 1e7bee9

Please sign in to comment.