Dtrace json output of control instrumentation to reduce overhead at hwcontext destructor - #103
Open
garimadhaked wants to merge 6 commits into
Open
Dtrace json output of control instrumentation to reduce overhead at hwcontext destructor #103garimadhaked wants to merge 6 commits into
garimadhaked wants to merge 6 commits into
Conversation
…gin. Apply Debug.dtrace_output_json_format and dtrace_coalesce_result before XRT initializes dtrace so results are emitted as coalesced JSON on hw context teardown. Co-authored-by: Cursor <cursoragent@cursor.com>
The dtrace engine drops the CT COUNTER_METADATA comment block from the JSON output, so the JSON dump lacked the per-counter metadata that the python dump carries. Rather than modifying the aiebu dtrace engine, keep the change in the xdp plugin: capture the metadata during CT generation and inject it into the JSON dump on hw context teardown (finish_flush_device -> endPollforDevice -> finalizeDtraceDump), which runs after core writes dtrace_dump_ctx_<slot>_*.json. Also make the metadata a single source of truth so the python (CT comment) and JSON metadata are identical for every bandwidth metric set, and keep each counter as a distinct JSON key via self-describing read_reg variable names. Co-authored-by: Cursor <cursoragent@cursor.com>
Move the JSON dtrace_dump counter-metadata injection out of the VE2 impl into aie_dtrace/util (invoked via the plugin callback) and rework the emitted format so post-processing stays cheap: - Emit a single shared "counters" array (deduped by counter number, per-tile "col" dropped) plus a compact per-microcontroller "uc" map (col_start/ col_end) instead of duplicating per-tile counter blocks. - Write counter_metadata once at the top level of the coalesced dump rather than into every inference's begin block (all inferences share the config). - Shorten counter variable names to c<col>_n<ctr> and shorten probe keys to uc<N>:<line>, reducing CT file size and dtrace runtime/output overhead. buildBandwidthMetadataJson remains the single source of truth for both the python CT comment and the injected JSON metadata. Co-authored-by: Cursor <cursoragent@cursor.com>
This reverts commit b987bba.
… plugin" This reverts commit 3908f2d.
The dtrace JSON dump keys each counter by the read_reg result variable name.
The CT writer used "_" for every counter read, which collapses all counters
into a single "_" JSON key. Assign a sequential result variable (_0, _1, _2,
...) per counter instead, so each counter appears as its own key ("_0", "_1",
...) in probe order. Counter semantics remain described by the COUNTER_METADATA
block. Applied to both writeCTFile and writeBandwidthCTFile.
Co-authored-by: Cursor <cursoragent@cursor.com>
jvillarre
approved these changes
Aug 7, 2026
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.
Summary
Improves the aie_dtrace plugin's JSON dump output for AIE bandwidth/counter profiling on VE2.
Enable coalesced JSON dtrace_dump output by default. The plugin now turns on JSON-format output and in-memory result coalescing, so each hw-context teardown produces a single dtrace_dump_ctx__.json instead of many per-inference files.
Emit sequential per-counter keys in the CT file. Each counter read is now assigned a sequential result variable (_0, _1, _2, …) instead of a shared _ throwaway. Since the dtrace engine keys each JSON entry by the read_reg result variable name, this makes every counter show up as its own key ("_0", "_1", …) in probe order, rather than collapsing into a single _ entry. Counter semantics (row/counter/channel/direction/event) remain described in the COUNTER_METADATA comment block. Applied to both writeCTFile and writeBandwidthCTFile.
Example JSON output
"jprobe:aie_runtime_control.asm:uc0:line8": { "ts_0": 182936, "_0": 123, "_1": 245, "...": "...", "_15": 0 }Testing done