Skip to content

Refactor: unify profiling/DFX/timeout config naming under SIMPLER_ (incl. strace.h include fix)#1268

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

Refactor: unify profiling/DFX/timeout config naming under SIMPLER_ (incl. strace.h include fix)#1268
ChaoWao wants to merge 2 commits into
hw-native-sys:mainfrom
ChaoWao:fix-strace-profiling-include

Conversation

@ChaoWao

@ChaoWao ChaoWao commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator

Summary

Two changes (the branch now carries both):

1. Fix: strace.h must include profiling_config.h (the original, urgent bugfix)
strace.h gated its macros on #if SIMPLER_HOST_STRACE but never included the header that defines it (profiling_config.h). TUs not pulling in a runtime pto_*.h (notably the platform c_api_shared.cpp wrapping simpler_run) saw the macro undefined → the gate evaluated false → every STRACE silently compiled to a no-op, dropping the simpler_run host-trace markers. Fixed by making strace.h self-contained.

2. Refactor: unify profiling/DFX/timeout config naming under SIMPLER_
Renames the configuration surface (compile macros + runtime env vars + DFX flag bitmask) to a consistent scheme, documented in docs/profiling-config-naming.md.

Naming rules:

  1. Compile macros = bare names; env vars carry a value-shape suffix (_ENABLE/_LEVEL/_TYPE/_US/_MS).
  2. Name reflects what's gated: umbrella DFX (broad), sub-tiers keep PROFILING (they are counters), host-strace gate HOST_STRACE.
  3. Runtime-subsystem knobs carry an owner prefix (HBG_/TMR_); platform knobs do not.
  4. Everything carries the SIMPLER_ project prefix.

Key renames:

  • PTO2_PROFILINGSIMPLER_DFX; PTO2_{ORCH,SCHED,TENSORMAP}_PROFILINGSIMPLER_*_PROFILING
  • SIMPLER_PROFILINGSIMPLER_HOST_STRACE; SIMPLER_DEVICE_PROFILINGSIMPLER_DEVICE_STRACE_ENABLE
  • PTO2_SERIAL_ORCH_SCHEDSIMPLER_TMR_SERIAL_ORCH_SCHED_ENABLE
  • PTO2_{OP_EXECUTE_TIMEOUT_US,STREAM_SYNC_TIMEOUT_MS,SCHEDULER_TIMEOUT_MS}SIMPLER_* (env, via the _ENV constexpr indirection)
  • PROFILING_FLAG_* + GET/SET/CLEAR_PROFILING_FLAGSIMPLER_DFX_FLAG_* + SIMPLER_GET/SET/CLEAR_DFX_FLAG

No behavior change.

Testing

  • All 4 platforms × 2 runtimes build with -Werror.
  • test_simpler_run_emits_strace_markers passes (the [STRACE] fix holds under the renamed SIMPLER_HOST_STRACE).
  • a2a3sim + a5sim hbg scene tests pass.
  • pre-commit (clang-format, check-headers) clean.
  • Onboard (real silicon) validation via CI.

@coderabbitai

coderabbitai Bot commented Jul 3, 2026

Copy link
Copy Markdown

Review Change Stack

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: fb2ee409-ef06-4793-9b43-0351975ed789

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 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
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.
Title check ✅ Passed The title accurately summarizes the naming refactor and the strace.h include fix included in this changeset.
Description check ✅ Passed The description clearly matches the pull request by describing the strace.h fix and the broader SIMPLER_ naming refactor.

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"

@ChaoWao ChaoWao changed the title Fix: strace.h must include profiling_config.h (STRACE silently no-op'd in c_api_shared) Refactor: unify profiling/DFX/timeout config naming under SIMPLER_ (incl. strace.h include fix) Jul 7, 2026
@ChaoWao ChaoWao force-pushed the fix-strace-profiling-include branch 2 times, most recently from 8710b23 to 282319a Compare July 7, 2026 08:39
…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.
@ChaoWao ChaoWao force-pushed the fix-strace-profiling-include branch from 282319a to cd707ed Compare July 8, 2026 09:27
@ChaoWao ChaoWao closed this Jul 8, 2026
@ChaoWao ChaoWao reopened this Jul 8, 2026
@ChaoWao ChaoWao force-pushed the fix-strace-profiling-include branch 2 times, most recently from c24abfd to cf035d6 Compare July 8, 2026 09:46
Renames the configuration surface (compile macros + runtime env vars + DFX
flag bitmask) to a consistent scheme, and documents the rules in
docs/profiling-config-naming.md.

Rules (see the doc):
1. Compile macros are bare names; env vars carry a value-shape suffix
   (_ENABLE / _LEVEL / _TYPE / _US / _MS) — readable as macro-vs-env.
2. Name reflects what's gated: umbrella is DFX (broad instrumentation),
   sub-tiers keep PROFILING (they ARE profiling counters), host strace gate
   is HOST_STRACE (not PROFILING).
3. Runtime-subsystem knobs carry an owner prefix (HBG_ / TMR_); platform
   knobs do not.
4. Everything carries the SIMPLER_ project prefix.

Renames:
- PTO2_PROFILING            -> SIMPLER_DFX            (device DFX umbrella)
- PTO2_ORCH/SCHED/TENSORMAP_PROFILING -> SIMPLER_*_PROFILING (sub-tiers; PROFILING kept — accurate)
- SIMPLER_PROFILING         -> SIMPLER_HOST_STRACE    (host [STRACE] gate)
- SIMPLER_DEVICE_PROFILING  -> SIMPLER_DEVICE_STRACE_ENABLE  (env)
- PTO2_SERIAL_ORCH_SCHED    -> SIMPLER_TMR_SERIAL_ORCH_SCHED_ENABLE (env)
- PTO2_OP_EXECUTE_TIMEOUT_US / STREAM_SYNC_TIMEOUT_MS / SCHEDULER_TIMEOUT_MS
                            -> SIMPLER_* (env; via the _ENV constexpr indirection)
- PROFILING_FLAG_* + GET/SET/CLEAR_PROFILING_FLAG
                            -> SIMPLER_DFX_FLAG_* + SIMPLER_GET/SET/CLEAR_DFX_FLAG

No behavior change. Verified: all 4 platforms x 2 runtimes build with -Werror;
the simpler_run [STRACE] marker test passes (the strace.h self-include fix is
preserved under the renamed SIMPLER_HOST_STRACE); a2a3sim/a5sim hbg scene
tests pass.

Includes docs/profiling-config-naming.md (new) and updates ci.yml + all
in-repo doc/skill references to the new names.
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