Skip to content

dynamic tracing compiler result buffer#295

Open
AdvaitNaik wants to merge 3 commits into
Xilinx:main-gefrom
AdvaitNaik:dtrace_result_buffer
Open

dynamic tracing compiler result buffer#295
AdvaitNaik wants to merge 3 commits into
Xilinx:main-gefrom
AdvaitNaik:dtrace_result_buffer

Conversation

@AdvaitNaik
Copy link
Copy Markdown
Collaborator

Problem solved by the commit

Every XRT run.dump_dtrace_buffer() performs file I/O to dump dtrace results — once per iteration. In multi-run scenarios (runlists or latency benchmarks with 100+ iterations on the same run), this creates N files with N file system round-trips.
Enhanced compiler to accept both bare filenames and full paths in probe declarations

Bug / issue (if any) fixed, which PR introduced the bug, how it was discovered

This is a performance enhancement with dtrace JSON output support; eliminating per-run file I/O when opted in.

Mode		     | Latency
---------------------------------
JSON file I/O	 | 3,042-3,391 us
JSON buffered	 | 1,394-1,415 us

Dtrace probe declarations now support both file names and file paths, fixing conflicts when multiple files with the same basename are included from different directories

How problem was solved, alternative solutions (if any) and why they were rejected

Accumulate dtrace JSON results in an in-memory nlohmann::ordered_json buffer. Each run.dump_dtrace_buffer() appends to this buffer. A single file is dumped when the hw context is destroyed. Only applies for Debug.dtrace_output_json_format = true (JSON mode). Python output path is unchanged.

Risks (if any) associated the changes in the commit

NA

What has been tested and how, request additional testing if necessary

Tested on windows medusa board and the feature works as expected

Documentation impact (if any)

https://amd.atlassian.net/wiki/spaces/AIE/pages/779183759/cert+dynamic+tracing+dtrace+compiler+APIs

Signed-off-by: advanaik <AdvaitHemant.Naik@amd.com>
Signed-off-by: advanaik <AdvaitHemant.Naik@amd.com>
Copilot AI review requested due to automatic review settings June 2, 2026 17:45
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 2, 2026

clang-tidy review says "All clean, LGTM! 👍"

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 enhances the dynamic tracing (dtrace) compiler/runtime to (1) support probe declarations by either basename or full path, and (2) enable buffered JSON result collection to reduce per-iteration filesystem I/O in multi-run scenarios.

Changes:

  • Emit and accept jprobe: keys for both basename and full file path variants (line + annotation probes).
  • Add a new public API update_dtrace_result_buffer(...) to serialize results into an in-memory nlohmann::ordered_json object (JSON mode) instead of writing a file per iteration.
  • Refactor result serialization ordering by precomputing the action execution order once (m_result_actions) and reusing it for file and buffer outputs.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
test/dtrace_test/dtrace_test.cpp Switches test include to dtrace/dtrace.h to match new include-root usage.
test/dtrace_test/CMakeLists.txt Updates include directory to ${AIEBU_SOURCE_DIR}/src/cpp to support dtrace/... includes.
src/cpp/tools/trace_probe.cpp Emits both basename and full-path jprobe: probe lines.
src/cpp/dtrace/parser/parser.cpp Populates map entries for both basename and full-path probe keys.
src/cpp/dtrace/dtrace.h Exposes new buffered JSON result API and includes nlohmann JSON in the public header.
src/cpp/dtrace/dtrace.cpp Implements update_dtrace_result_buffer(...) to generate results without file I/O.
src/cpp/dtrace/control/control.h Adds create_result_buffer(...) and stores precomputed result-action ordering.
src/cpp/dtrace/control/control.cpp Refactors result generation to reuse m_result_actions and adds JSON buffer serialization.
Comments suppressed due to low confidence (1)

src/cpp/dtrace/control/control.h:20

  • This header now uses std::shared_ptr and std::pair in the new m_result_actions member but doesn’t include <memory> / <utility> directly. It currently compiles only via transitive includes, which is brittle for a public header.
#include "json/nlohmann/json.hpp"

#include <cstdint> 
#include <string>
#include <unordered_map>
#include <vector>


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/cpp/dtrace/parser/parser.cpp
Comment thread src/cpp/tools/trace_probe.cpp
Comment thread src/cpp/dtrace/dtrace.h
Comment thread src/cpp/dtrace/dtrace.cpp
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

clang-tidy made some suggestions

Comment thread src/cpp/dtrace/parser/parser.cpp Outdated
Signed-off-by: Advait Hemant Naik <advanaik@amd.com>
@AdvaitNaik AdvaitNaik force-pushed the dtrace_result_buffer branch from 690404c to 40d864d Compare June 2, 2026 18:39
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 2, 2026

clang-tidy review says "All clean, LGTM! 👍"

@AdvaitNaik AdvaitNaik requested review from sonals and xuhz June 2, 2026 19:47
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