Skip to content

jobque: self-describing traces — named categories, colors, unit markers#3449

Merged
borisbat merged 3 commits into
masterfrom
bbatkin/jobque-profile
Jul 13, 2026
Merged

jobque: self-describing traces — named categories, colors, unit markers#3449
borisbat merged 3 commits into
masterfrom
bbatkin/jobque-profile

Conversation

@borisbat

Copy link
Copy Markdown
Collaborator

Promotes the per-lane jobque event tracer to a self-describing common API — groundwork for the jobque timeline viewer tool (PR2 to follow).

What

  • C++ ring (job_que.h/cpp): new TraceTag::Marker kind + JobQue::traceMarker (instant "unit" event on the caller lane — token/frame/layer boundaries), and cold-path registries traceCategory(id, name, rgb) / traceMarkerName(name). traceSave now emits markers as perfetto instant events ("ph":"i") and appends a jobqueProfile sibling key (categories with #RRGGBB colors, marker kinds) after traceEvents — Perfetto ignores unknown keys, so files stay perfetto-compatible and the existing analyzers (trace_window.py, trace_gaps.py, …) work unchanged (verified).
  • New builtins: 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.
  • dasLLAMA: 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 the pick_cls.py-style representative-window hunt: viewers navigate unit-to-unit.
  • Test: 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.
  • Docs: das2rst group entries + handmade pages for the new builtins and module; sec_concurrency toctree.

Verified

  • tests/jobque: 210/210 pass; new round-trip test passes.
  • Real trace: decode_prof --trace on Qwen2.5-0.5B → 106k events, all 10 categories in the header, 8 token markers (args 0..7) on the caller lane, publishes tagged attn-chain/ffn-chain/classifier.
  • trace_window.py cuts the new-format file unchanged.
  • Sphinx -W html build clean; no Uncategorized, no doc stubs; lint/format clean on all changed .das.

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings July 13, 2026 02:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-compatible traceEvents.
  • Exposed new jobque tracing builtins and an AOT header surface, plus a new daslib/jobque_profile wrapper 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.

Comment thread src/misc/job_que.cpp Outdated
Comment thread daslib/jobque_profile.das Outdated
Copilot AI review requested due to automatic review settings July 13, 2026 05:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 16 out of 16 changed files in this pull request and generated 5 comments.

Comment thread src/misc/job_que.cpp
Comment thread tests/jobque/test_jobque_trace.das
Comment thread tests/jobque/test_jobque_trace.das
Comment thread tests/jobque/test_jobque_trace.das
Comment thread tests/jobque/test_jobque_trace.das
borisbat and others added 2 commits July 12, 2026 23:32
- 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>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 16 out of 16 changed files in this pull request and generated 3 comments.

Comment thread src/misc/job_que.cpp
Comment thread modules/dasLLAMA/dasllama/dasllama_math.das
Comment thread modules/dasLLAMA/dasllama/dasllama_math.das
Copilot AI review requested due to automatic review settings July 13, 2026 06:39
@borisbat borisbat force-pushed the bbatkin/jobque-profile branch from 5336061 to 5cbe5e8 Compare July 13, 2026 06:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 16 out of 16 changed files in this pull request and generated 1 comment.

Comment thread src/misc/job_que.cpp
…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>
Copilot AI review requested due to automatic review settings July 13, 2026 07:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 16 out of 16 changed files in this pull request and generated no new comments.

@borisbat borisbat merged commit fb45ea4 into master Jul 13, 2026
38 checks passed
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