Skip to main content

Module telemetry

Module telemetry 

Source
Expand description

Per-job structured telemetry: phase wall times, counts, resource peaks. See docs/performance/TELEMETRY.md for the design contract. Per-job telemetry: phase wall times, counts, and resource peaks.

See docs/performance/TELEMETRY.md for the design contract.

Default-on instrumentation. Coarse phase wrappers cost ~20ns each (one Instant::now() call); the math-parse histogram update is the only per-formula instrumentation and is a single atomic increment of one of 9 u32 slots.

Thread-local state. Aggregate at end-of-process via take(). All times in microseconds; counts in their natural unit.

Structs§

PhaseGuard
RAII guard returned by phase. Calls phase_exit on drop.
Telemetry
Per-job telemetry record.

Enums§

Phase
Coarse phase enum. 17 values; bumping requires updating Telemetry::write_json and tools/perf_phase_summary.py.

Functions§

add_formulae
Add to the formulae count. For streaming pass 2, which parses math one SEGMENT at a time and so never knows the document-wide count up front — set_formulae there would record only the last segment’s tally.
add_graphics_subprocess
Bulk-add subprocess counts from a worker-pool tally. Used after std::thread::scope joins because per-worker thread_local! STATE is discarded on thread exit; counts accumulated in a shared AtomicU32 are merged here.
incr_error
incr_external_tool
incr_fatal_error
incr_formulae
incr_graphics_asset
incr_graphics_subprocess
incr_warning
phase
Convenience: let _g = telemetry::phase(Phase::Digest);
phase_enter
Begin a phase. Subsequent time accrues to this phase until the matching phase_exit() (or the PhaseGuard returned by phase) drops.
phase_exit
End the innermost phase.
record_math_parse
Record one math parse: total time and number of successful parses returned (the Marpa parser may produce multiple ASF derivations for one input). Updates the histogram bucket for the elapsed time.
reset
Reset per-conversion telemetry WITHOUT reading it.
set_category
set_child_rusage_us
set_cmdline
set_db_objects
set_exit_code
set_formulae
Set the formulae count directly. Use when the document-wide count is known up front (e.g., right before MathParser::parse_math is invoked over all <XMath> nodes).
set_graphics_assets
set_host
set_max_rss_kb
set_output_bytes
set_paper_id
set_status_counts
Bulk-set status counts at finalize time from common::error::REPORT (the canonical Error!/Warn!/Fatal! counter). Avoids double-bookkeeping in every macro invocation; just snapshot once before serialization.
set_timeout_s
set_wall_us
take
Take the current telemetry record, replacing it with a fresh default. Use at end-of-process to serialize the result.
with
Read-only view for tests / instrumented assertions.