Skip to main content

Module tracy

Module tracy 

Source
Expand description

Tracy profiler span instrumentation.

Martensite instruments layout, paint, and reactive dispatch with profiling spans so that frame bottlenecks can be located without external tooling. Because the crate is #![forbid(unsafe_code)], it cannot link the native Tracy client library (which is inherently unsafe). Instead, this module provides a safe, allocation-free re-implementation of the Tracy span API that records region durations with std::time::Instant into a thread-local ring buffer. The recorded data feeds the in-app diagnostic HUD and can be queried programmatically.

The instrumentation is designed for sub-microsecond overhead: a span begin/end pair performs two Instant::now() calls and a fixed-size array write, with no heap allocation. The DevTools overhead gate (§5.3 of the v0.9.0 milestone) requires that active profiling contributes < 0.1ms per 60fps frame; see the tracy_overhead_under_100us_per_frame test for the exit-criterion verification.

§Examples

use martensite_devtools::tracy;

// Scoped span: records its duration on drop.
let _guard = tracy::span("layout_pass");
// ... layout work ...

// Manual span lifecycle.
let span = tracy::TracySpan::begin("paint_encode");
// ... paint work ...
span.end();

// Frame and plot markers.
tracy::frame_mark();
tracy::plot("gpu_wait_ms", 0.42);

Structs§

SpanRecord
A single recorded profiling span.
TracySpan
A profiling span that records the duration of a code region.
TracySpanGuard
RAII guard for a scoped profiling span.

Functions§

frame_count
Return the per-thread frame counter value.
frame_mark
Emit a frame marker for Tracy’s frame profiling.
last_span_duration
Return the most recently recorded duration (in nanoseconds) for the named span on the current thread, if any.
plot
Record a plot point for Tracy’s value plots.
plot_value
Return the last recorded value for the named plot on the current thread, if any.
span
Create a scoped profiling span that records its duration on drop.
span_record_count
Return the number of span records currently held in the current thread’s ring buffer.