jobque: self-describing traces — named categories, colors, unit markers#3449
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR upgrades the job queue tracer into a self-describing trace format by adding marker events and on-file registries for tag categories (names + colors) and marker kinds, enabling downstream timeline viewers to interpret traces without hardcoded legends.
Changes:
- Added C++ support for trace marker events and persisted registries (
jobqueProfile) emitted alongside Perfetto-compatibletraceEvents. - Exposed new jobque tracing builtins and an AOT header surface, plus a new
daslib/jobque_profilewrapper module. - Integrated marker/unit boundaries and category registration into dasLLAMA profiling paths, and added a JSON round-trip test + documentation updates.
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/jobque/test_jobque_trace.das | New round-trip test validating categories/markers and marker instant events in saved JSON. |
| src/misc/job_que.cpp | Implements category/marker registries, marker emission, and writes jobqueProfile into saved trace JSON. |
| src/builtin/module_builtin_jobque.cpp | Adds builtins for category/marker registration and marker emission. |
| modules/dasLLAMA/dasllama/dasllama_math.das | Registers trace categories when enabling dasLLAMA trace tags; adds marker helper. |
| modules/dasLLAMA/dasllama/dasllama_common.das | Adds per-layer unit markers during prefill tracing. |
| modules/dasLLAMA/benchmarks/decode_prof.das | Adds per-token unit markers in the decode profiler loop. |
| modules/dasLLAMA/benchmarks/batch_decode_perf.das | Adds per-step unit markers in the batch decode loop. |
| include/daScript/simulate/aot_builtin_jobque.h | Declares new jobque trace builtins for AOT. |
| include/daScript/misc/job_que.h | Extends tracer internals with Marker tag and registry storage. |
| doc/source/stdlib/sec_concurrency.rst | Hooks generated jobque_profile docs into the concurrency section. |
| doc/source/stdlib/handmade/module-jobque_profile.rst | Adds handmade module overview and usage example. |
| doc/source/stdlib/handmade/function-jobque-jobque_trace_marker-0x23d3c8a055ea0170.rst | Documents marker builtin behavior and Perfetto instant event mapping. |
| doc/source/stdlib/handmade/function-jobque-jobque_trace_marker_name-0x11d82ed54aded050.rst | Documents marker kind registration builtin. |
| doc/source/stdlib/handmade/function-jobque-jobque_trace_category-0x9e6a5d0ed05ba6da.rst | Documents category registration builtin and persistence behavior. |
| doc/reflections/das2rst.das | Adds doc generation for jobque_profile and includes new builtins in jobque groups. |
| daslib/jobque_profile.das | New high-level profiling wrapper (sessions, categories, markers, palette constants). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- TraceTag::Marker + JobQue::traceCategory/traceMarkerName/traceMarker; traceSave emits markers as perfetto instant events and a "jobqueProfile" sibling key (categories with colors, marker kinds) — files stay perfetto-compatible, existing analyzers (trace_window.py et al) unaffected - new builtins: jobque_trace_category / jobque_trace_marker_name / jobque_trace_marker (hot path: relaxed-load no-op when tracing is off) - daslib/jobque_profile.das: profile_start/stop/save, profile_category (auto or explicit id, palette fallback), profile_tag, profile_marker(_id) - dasLLAMA: set_trace_tags(true) registers the 10 lane-timeline categories with the viewer's palette; unit markers "token" (decode_prof), "layer" (prefill stack), "step" (batch_decode_perf) - tests/jobque/test_jobque_trace.das: save/re-read round-trip — first coverage of the trace API - docs: das2rst module entry + handmade pages, sec_concurrency toctree Groundwork for the jobque timeline viewer tool (PR2). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…view) traceSave emitted marker args with %u while the API takes a signed int — a negative arg round-tripped as a huge unsigned value. Emit %d with a bit-preserving int32 cast, and pin it with a negative-arg case in the round-trip test. resolve_color's modulus now uses length(DEFAULT_PALETTE) instead of a hardcoded 12. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
5336061 to
5cbe5e8
Compare
…eview) set_trace_tags(true) and trace_marker gate their jobque_profile calls on is_job_que_available() — the trace-tag rail was always safe to poke without a live que (jobque_trace_tag no-ops) and now stays that way; the arming harnesses all run inside with_job_que, so behavior there is unchanged. The marker emission comment now states that global scope is deliberate (unit boundaries draw across all lanes; tid still records the caller lane). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Promotes the per-lane jobque event tracer to a self-describing common API — groundwork for the jobque timeline viewer tool (PR2 to follow).
What
job_que.h/cpp): newTraceTag::Markerkind +JobQue::traceMarker(instant "unit" event on the caller lane — token/frame/layer boundaries), and cold-path registriestraceCategory(id, name, rgb)/traceMarkerName(name).traceSavenow emits markers as perfetto instant events ("ph":"i") and appends ajobqueProfilesibling key (categories with#RRGGBBcolors, marker kinds) aftertraceEvents— Perfetto ignores unknown keys, so files stay perfetto-compatible and the existing analyzers (trace_window.py,trace_gaps.py, …) work unchanged (verified).jobque_trace_category,jobque_trace_marker_name,jobque_trace_marker(hot path = one relaxed load no-op when tracing is off), + AOT header decls.daslib/jobque_profile.das(new):profile_start/stop/save,profile_category(auto-id or explicit-id, palette fallback by name hash),profile_tag,profile_marker/profile_marker_id,PROFILE_COLOR_*constants.set_trace_tags(true)now registers the 10 lane-timeline categories with the viewer's exact names/colors, so saved traces carry the legend the browser artifact used to hardcode; unit markers stamped in the traced windows —token(decode_prof),layer(prefill stack),step(batch_decode_perf). Kills thepick_cls.py-style representative-window hunt: viewers navigate unit-to-unit.tests/jobque/test_jobque_trace.das— arm → register → team-dispatch storm with tag + markers → save → re-read JSON → assert header/categories/markers/publish-tag packing round-trip. First test coverage of the trace API.sec_concurrencytoctree.Verified
tests/jobque: 210/210 pass; new round-trip test passes.decode_prof --traceon Qwen2.5-0.5B → 106k events, all 10 categories in the header, 8tokenmarkers (args 0..7) on the caller lane, publishes tagged attn-chain/ffn-chain/classifier.trace_window.pycuts the new-format file unchanged.-Whtml build clean; noUncategorized, no doc stubs; lint/format clean on all changed.das.🤖 Generated with Claude Code