Expand description
Process-wide Linux ftrace / portable perf-trace backend for
Bun__linux_trace_{init,emit,close}.
§ABI (matches bun_core::perf::sys / upstream perf.zig)
int Bun__linux_trace_init(void); // 1 = backend ready, 0 = not
void Bun__linux_trace_close(void);
int Bun__linux_trace_emit(const char *event_name, int64_t duration_ns);
// emit: 0 = success, non-zero = failure§Backends
| OS | Backend |
|---|---|
| Linux/Android | trace_marker (/sys/kernel/tracing then debugfs) |
| macOS | in-process ring + temp bao-perf-trace.jsonl |
| Windows | OutputDebugStringW + temp jsonl + ring |
All platforms keep a process-local ring (4096 slots) so unit tests can
observe emit side effects when init succeeded.
Structs§
- Trace
Ring Event - One captured emit for tests / consumers of the ring.
Functions§
- Bun__
linux_ trace_ close - Close the backend and release OS resources. Idempotent / re-entrant safe.
Does not wipe the ring (tests may inspect after close); call
linux_trace_reset_for_testto clear. - Bun__
linux_ trace_ emit - Emit one complete event:
event_name+duration_ns. - Bun__
linux_ trace_ init - Initialize the platform trace backend.
- force_
link_ linux_ trace - Keep this compilation unit on the product link line.
- linux_
trace_ emit_ ok - Successful emit count since last reset (backend-write OK).
- linux_
trace_ reset_ for_ test - Close backend + clear ring + counters (test isolation).
- linux_
trace_ ring_ len - Number of events currently held in the ring.
- linux_
trace_ ring_ snapshot - Snapshot of ring events in chronological order (oldest → newest).