Expand description
Retroactive telemetry aggregation over a completed (corpus, service) run.
The latexml-oxide cortex_worker writes a per-job telemetry.json into every result archive
(wall/RSS, per-phase microseconds, message + asset counts). This module reads those records back
off disk — one random-access by_name("telemetry.json") seek per result ZIP, mirroring
crate::helpers’s read_cortex_log — and rolls them up into a TelemetrySummary:
nearest-rank wall/RSS percentiles, a per-phase P99 breakdown, an outcome mix, and the slowest /
highest-RSS witness papers.
It is read-only and off the dispatch hot path — the frontend telemetry dashboard
(crate::frontend::telemetry) drives it lazily on a cache miss. Every field of a record is
#[serde(default)], because the worker’s failure path emits only paper_id/category/
exit_code; a missing numeric or array field is simply zero / empty, never a parse error.
Structs§
- Math
Stats - Math-parsing rollup.
parses_per_formula=parse_count / attempts— the corpus-wide grammar ambiguity (over-parse) multiplier that semantics-pruning then collapses. - Outcome
Wall - Wall-time profile of one outcome bucket — used to show that
fatalpapers are bimodal (most fail fast; a slow-runaway subset burns ~timeout before dying). - Percentiles
- Nearest-rank percentiles of a sample (plus its max), in whatever unit the input carries.
- RssBuckets
- Peak-RSS bucket counts — how many papers cross each memory line (the 4 GiB alloc wall being the release concern).
- Tail
Stats - Wall-time tail concentration: how top-heavy the run is, and how close the slowest papers get to
the conversion timeout.
topN_pct_wall_shareis the fraction (%) of all wall time held by the slowest N% of papers; theover_*scounts are papers at/above that wall threshold. - Telemetry
Record - One worker
telemetry.jsonrecord. Every field is#[serde(default)]: the worker’s failure path emits onlypaper_id/category/exit_code, so a missing numeric field decodes to0and a missingphase_usto an empty vector rather than failing the whole parse. - Telemetry
Summary - The rolled-up telemetry of a completed
(corpus, service)run — the shared read model for both the telemetry dashboard screen and its agent JSON twin.
Constants§
- PHASES
- The 17 conversion phases the worker times, in emission order — the index into a
TelemetryRecord::phase_usentry and the label of a per-phase P99 row. Kept in lock-step with the latexml-oxide worker’s telemetry writer; a shorter/absentphase_us(the failure path) simply contributes nothing to the tail phases.
Functions§
- aggregate
- Aggregates the telemetry of a completed run: reads each task
entry’s result-archivetelemetry.jsonin parallel (a boundedstd::thread::scopepool,N = available_parallelismcapped at 16, the entries chunked evenly across threads), skipping any archive that is missing / unreadable / lacks a telemetry record, thensummarizes.sandbox_idis threaded throughresult_archive_pathso a sandbox corpus reads its own name-scoped archives, not the parent’s. - percentiles
- Nearest-rank percentiles of
values(the copy is sorted; the input may be unsorted). The rank for percentilepisceil(p/100 * n)clamped to[1, n], taken at indexrank - 1. An empty sample yields all-zeros. - read_
telemetry_ json - Reads and decodes the
telemetry.jsonmember of a result.zip. Mirrorscrate::helpers’sread_cortex_log: the pure-Rustzipcrate’s random-accessby_nameseeks straight totelemetry.jsonvia the central directory, never decompressing the (potentially large) converted output. Returns the decoded record, or anErrdescribing why it couldn’t (a non-zip / corrupt archive, a missingtelemetry.json, or invalid JSON) — the caller counts that as a skipped sample rather than failing the whole aggregation. - summarize
- Rolls a slice of telemetry records into a
TelemetrySummary. Pure and DB-free (the reading isaggregate’s job): outcome bucketing, unit conversions (µs→ms, KiB→MiB), nearest-rank percentiles, per-phase P99, witnesses, and totals.skippedis left0—aggregatefills it from the read pass.