Skip to content

Fix: strace.h must include profiling_config.h (STRACE silently no-op'd in c_api_shared)#1268

Open
ChaoWao wants to merge 1 commit into
hw-native-sys:mainfrom
ChaoWao:fix-strace-profiling-include
Open

Fix: strace.h must include profiling_config.h (STRACE silently no-op'd in c_api_shared)#1268
ChaoWao wants to merge 1 commit into
hw-native-sys:mainfrom
ChaoWao:fix-strace-profiling-include

Conversation

@ChaoWao

@ChaoWao ChaoWao commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator

Problem

strace.h gates all its macros on #if SIMPLER_PROFILING but never includes profiling_config.h — the header that defines SIMPLER_PROFILING=1. It relied on each TU to pull the definition in transitively.

The runtime's pto_*.h headers include it, but the platform c_api_shared.cpp (which wraps simpler_run and owns the root STRACE("simpler_run") + .bind / .runner_run / .validate spans) does not. There, SIMPLER_PROFILING was undefined → #if SIMPLER_PROFILING evaluated false → every STRACE compiled to a no-op.

Impact

The host-trace markers for each simpler_run were silently dropped on the platform path — the very path the DFX contract relies on (consumers like pypto-serving read per-stage timing of each simpler_run purely from these [STRACE] log lines).

This surfaced as a persistent CI failure (pre-existing on main, unrelated to any recent feature PR):

examples/workers/l2/vector_add/test_run_timing.py::test_simpler_run_emits_strace_markers
  AssertionError: no `[STRACE] ... name=simpler_run` marker found on stderr

Fix

Make strace.h self-contained — include profiling_config.h itself so SIMPLER_PROFILING is always defined for any TU using the macros. One-line include; no behavior change for TUs that already had the definition.

How the root cause was found

Instrumenting simpler_run confirmed it was entered and returned rc=0, yet its STRACE("simpler_run") destructor never emitted — while inner spans from runtime_maker.cpp (a different TU that does transitively include profiling_config.h) emitted fine. That per-TU split pointed straight at the missing transitive include in c_api_shared.cpp.

Verification

  • test_simpler_run_emits_strace_markers now passes on a2a3sim (was failing on main).
  • All 4 platforms × 2 runtimes build clean with -Werror.
  • a2a3sim + a5sim hbg & tensormap scene tests pass (no regression).
  • Onboard (real silicon) validation pending CI.

…d in c_api_shared)

strace.h gated its macros on `#if SIMPLER_PROFILING` but never included
profiling_config.h (the header that defines SIMPLER_PROFILING=1). It relied on
each TU to pull the definition in transitively — which the runtime pto_*.h
headers do, but the platform c_api_shared.cpp (which wraps simpler_run and owns
the root STRACE("simpler_run") / .bind / .runner_run / .validate spans) does
not. There, SIMPLER_PROFILING was undefined, the gate evaluated false, and every
STRACE compiled to a no-op.

Net effect: the host-trace markers for each simpler_run were silently dropped on
the platform path (the very path the DFX contract relies on — pypto-serving
reads per-stage timing of each simpler_run purely from these [STRACE] log
lines). This surfaced as a persistent CI failure in
examples/workers/l2/vector_add/test_run_timing.py::test_simpler_run_emits_strace_markers,
which asserts the markers are present.

Fix: make strace.h self-contained by including profiling_config.h itself, so
SIMPLER_PROFILING is always defined for any TU that uses the macros. One-line
include; no behavior change for TUs that already had it.

Verified: the previously-failing test now passes on a2a3sim; all 4 platforms ×
2 runtimes build clean; a2a3sim/a5sim hbg + tensormap scene tests pass.
@coderabbitai

coderabbitai Bot commented Jul 3, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: eb66bf66-ca22-4e3d-95e3-f067787c8b13

📥 Commits

Reviewing files that changed from the base of the PR and between fb65fe9 and 0f1a95d.

📒 Files selected for processing (1)
  • src/common/log/include/common/strace.h

📝 Walkthrough

Walkthrough

This change makes strace.h self-contained by including profiling_config.h prior to the #if SIMPLER_PROFILING check, ensuring the STRACE macros are defined correctly regardless of whether the including translation unit previously pulled in the profiling configuration.

Changes

Strace Header Fix

Layer / File(s) Summary
Include profiling config before macro guard
src/common/log/include/common/strace.h
Added #include "profiling_config.h" before the #if SIMPLER_PROFILING section to ensure STRACE* macros are not silently compiled as no-ops.

Estimated code review effort: 1 (Trivial) | ~3 minutes

Poem

A tiny include, hopping in place,
So STRACE macros won't lose their trace,
No more silent no-ops in the night,
Just one header pulled in right! 🐇✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the core fix: making strace.h include profiling_config.h to prevent STRACE from no-oping in c_api_shared.
Description check ✅ Passed The description is directly related to the change and accurately explains the bug, impact, and fix.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request includes "profiling_config.h" in the low-level header "strace.h" to ensure it is self-contained and correctly resolves the SIMPLER_PROFILING macro. The reviewer notes that this introduces a layering violation, as low-level logging utilities should not depend on higher-level task interface modules, and suggests relocating the configuration or using structured include paths to prevent compilation issues.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

// `#if SIMPLER_PROFILING` gate below evaluate false and silently compile every
// STRACE to a no-op — dropping the simpler_run host-trace markers that
// consumers (pypto-serving) read from the log.
#include "profiling_config.h"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Including profiling_config.h directly from task_interface inside a low-level header in common/log introduces a layering violation (dependency inversion). Low-level utilities like logging should not depend on higher-level modules like task_interface. This forces any target using common/log to include task_interface in its header search paths, which can break compilation for other targets or modules that do not use task_interface.

Additionally, using a flat include like #include "profiling_config.h" makes the dependency implicit and prone to header name collisions.

Suggested Improvements:

  1. Relocate the configuration: Move profiling_config.h (or at least the SIMPLER_PROFILING definition) to a lower-level common configuration directory (e.g., src/common/log/include/common/ or a dedicated common/config/ directory).
  2. Use structured paths: If the dependency must remain, use a structured include path (e.g., #include "task_interface/profiling_config.h") and ensure that the common/log CMake target publicly propagates this dependency so that all consumers can resolve the include path.
Suggested change
#include "profiling_config.h"
#include "task_interface/profiling_config.h"

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.

1 participant