Skip to content

Support CM time_metric (NS/MS/SEC/US) across reader and viz#99

Open
rayandrew wants to merge 8 commits into
llnl:developfrom
rayandrew:feat/server-query-improv
Open

Support CM time_metric (NS/MS/SEC/US) across reader and viz#99
rayandrew wants to merge 8 commits into
llnl:developfrom
rayandrew:feat/server-query-improv

Conversation

@rayandrew

Copy link
Copy Markdown
Collaborator

Summary

Traces can declare their time unit via the CM time_metric metadata event (NS, MS, SEC, or US; absent means US).
Until now everything assumed microseconds, so an NS trace showed timestamps and durations 1000x too large and mislabeled.
This adds first-class handling so every consumer sees correct time.

Reader (Python / Arrow / C++)

Adds an opt-in normalize_time option that scales ts/dur into a target unit; the default is native, with no scaling and no cost.
The Python API takes a TimeUnit enum (NS/US/MS/SEC) or the equivalent string, forwarded through both read_arrow/iter_arrow and read_json/iter_json.
The file's unit is resolved once from a cheap header probe that is independent of any query filter, so scaling stays correct even when a query drops the CM line.
Scaling is fused into the existing row-build pass and short-circuits for US traces, so it adds no measurable cost.
Query predicates (ts >= ...) continue to match the native index and are unaffected.

Server / viz

The server now presents all timestamps and durations in microseconds regardless of the trace's native unit.
TraceIndex resolves one unit per trace and converts at its boundary: request begin/end map microseconds-to-native for the scan, and /info bounds plus every response value (event ts/dur, density blocks, stats, histogram, calltree, counters, breaks, proctree) map native-to-microseconds.
Every conversion is identity for US traces, so existing behavior is unchanged.

Tests and docs

Adds a time_metric unit test, a Python normalize_time suite (including enum, query-filtered, and gzip cases), and a server integration test that verifies an NS trace is served in microseconds.
Existing reader and server suites pass unchanged.
Documents normalize_time/TimeUnit in the quickstart and adds a "Time units" note to the server API docs.

@rayandrew
rayandrew force-pushed the feat/server-query-improv branch from d8667e5 to a5f62e2 Compare July 20, 2026 23:25
@rayandrew
rayandrew force-pushed the feat/server-query-improv branch from a5f62e2 to ee805ad Compare July 20, 2026 23:34
fold_summary's column-discovery block iterated
`ar.get_object().value_unsafe()` directly in a range-for. The
simdjson_result temporary is destroyed at the end of the statement, so
the bound dom::object's tape pointer dangles and object::end() reads
freed memory. Crashed the scan thread on the first event with args,
leaving /viz/breaks and /viz/events empty. Only reproduced on
Linux/aarch64 at -O2 (same class as the bloom_visitor fix).

Bind the object to a named local before iterating.
Route cores to /tmp/cores (overriding apport/systemd-coredump), enable
`ulimit -c unlimited` for the test/coverage/python steps, and on failure
run `gdb thread apply all bt full` over each core and upload the cores
plus backtraces as an artifact. Catches crashes in a spawned subprocess
(e.g. dftracer_server) that surface only as an empty response in the
test binary. The tests preset is already RelWithDebInfo with DEBUG=ON,
so symbols are present.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants