Skip to content

Unify APEX tracing backend under hpx::tracing API#7293

Open
v4xsh wants to merge 36 commits into
TheHPXProject:masterfrom
v4xsh:tracing-apex-unification
Open

Unify APEX tracing backend under hpx::tracing API#7293
v4xsh wants to merge 36 commits into
TheHPXProject:masterfrom
v4xsh:tracing-apex-unification

Conversation

@v4xsh
Copy link
Copy Markdown
Contributor

@v4xsh v4xsh commented May 23, 2026

Proposed Changes

  • Integrate the APEX tracing backend into the unified hpx::tracing layer, replacing scattered HPX_HAVE_APEX handling across runtime call sites.
  • Wire the tracing module into the core futures and runtime_local targets, and clean up the Tracy setup path so tracing target usage stays consistent.
  • Break the tracing / threading_base dependency cycle by keeping the APEX-specific timer implementation safely within external_timer.cpp.
  • Migrate key execution paths to the unified tracing API, including thread scheduling, task execution, runtime startup/finalization, parcel send/receive handling, distributed action posting, and performance counter sampling.
  • Replace older APEX annotation plumbing with task_timer_data and no-op fallback paths so tracing stays strictly lightweight when the backend is disabled.

Any background context you want to provide?

This PR completes the APEX side of the tracing unification by moving APEX runtime instrumentation behind the common hpx::tracing interface. Before this, APEX-specific hooks and HPX_HAVE_APEX conditionals were heavily spread across threading, parcelset, actions, counters, and runtime initialization code.

With this change, those call sites use the shared tracing API instead, while the APEX-specific implementation is kept delegated to the threading_base external timer implementation. This makes the instrumentation significantly easier to maintain, reduces direct coupling between modules, and keeps disabled tracing paths as lightweight zero-overhead fallbacks.

Checklist

Not all points below apply to all pull requests.

  • I have added a new feature and have added tests to go along with it.
  • I have fixed a bug and have added a regression test.
  • I have added a test using random numbers; I have made sure it uses a seed, and that random numbers generated are valid inputs for the tests.

@v4xsh v4xsh requested a review from hkaiser as a code owner May 23, 2026 20:00
Copilot AI review requested due to automatic review settings May 23, 2026 20:00
@StellarBot
Copy link
Copy Markdown
Collaborator

Can one of the admins verify this patch?

@codacy-production
Copy link
Copy Markdown

codacy-production Bot commented May 23, 2026

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@v4xsh v4xsh force-pushed the tracing-apex-unification branch from 48d0980 to 3d3cc5f Compare May 23, 2026 20:05
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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@hkaiser
Copy link
Copy Markdown
Contributor

hkaiser commented May 23, 2026

@v4xsh inspect reports:

/libs/core/threading_base/src/external_timer.cpp: *I* missing #include (string) for symbol std::string on line 155

#if defined(HPX_HAVE_APEX)
std::shared_ptr<util::external_timer::task_wrapper> get_timer_data()
const noexcept
hpx::tracing::task_timer_data get_timer_data() const noexcept
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.

Can we make these functions 100% no-ops if APEX is disabled?

Comment thread libs/core/tracing/include/hpx/tracing/tracing.hpp
@v4xsh v4xsh force-pushed the tracing-apex-unification branch from e495f6a to c5d8084 Compare May 24, 2026 01:23
@v4xsh
Copy link
Copy Markdown
Contributor Author

v4xsh commented May 24, 2026

@hkaiser Kindly have a look!

Comment thread libs/core/futures/src/detail/execute_thread.cpp Outdated
Comment thread libs/core/thread_pools/include/hpx/thread_pools/scheduling_loop.hpp Outdated
Comment thread libs/core/threading_base/include/hpx/threading_base/scoped_annotation.hpp Outdated
Comment thread libs/core/threading_base/include/hpx/threading_base/scoped_annotation.hpp Outdated
Comment thread libs/core/tracing/include/hpx/tracing/backends/empty.hpp Outdated
Comment thread libs/core/tracing/include/hpx/tracing/tracing.hpp
Comment thread libs/core/tracing/src/tracing.cpp Outdated
Comment thread libs/full/actions/include/hpx/actions/transfer_action.hpp Outdated
Copilot AI review requested due to automatic review settings May 24, 2026 21:06
@v4xsh v4xsh force-pushed the tracing-apex-unification branch from b67c64f to f962b7b Compare May 25, 2026 13:30
@v4xsh
Copy link
Copy Markdown
Contributor Author

v4xsh commented May 25, 2026

Kindly let me know if any further changes are required!

Comment thread libs/core/threading_base/include/hpx/threading_base/thread_data.hpp Outdated
Comment thread libs/core/threading_base/include/hpx/threading_base/thread_data.hpp Outdated
Copilot AI review requested due to automatic review settings May 25, 2026 14:07
@v4xsh v4xsh force-pushed the tracing-apex-unification branch from 77be55f to 9f4918c Compare May 25, 2026 14:07
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

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

Comments suppressed due to low confidence (2)

libs/full/performance_counters/src/query_counters.cpp:1

  • The counter short name is recomputed on every sample via remove_counter_prefix, even for backends that ignore short_name (e.g., ITTNotify here ignores the second parameter). This adds avoidable per-sample string work on a potentially hot path; consider caching full_name -> short_name once (e.g., at create_counter time) or moving the mapping inside hpx::tracing so sample_counter only needs (full_name, value) for all backends.
    libs/full/performance_counters/src/query_counters.cpp:1
  • The previous suppression of console output when ITTNotify/Tracy backends were active was removed (the destination_is_cout checks). This changes runtime behavior by potentially producing duplicated output (console + tracing backend) or console noise in profiling runs; if the old behavior is still desired, reintroduce a backend-aware no_output adjustment (ideally via a single hpx::tracing query rather than backend-specific #ifs).

Comment thread libs/core/tracing/CMakeLists.txt
Comment thread libs/core/tracing/src/backends/ittnotify.cpp
Comment thread libs/core/threading_base/include/hpx/threading_base/threading_base_fwd.hpp Outdated
@v4xsh v4xsh force-pushed the tracing-apex-unification branch from f37c2f3 to dd2409c Compare May 25, 2026 18:19
Copilot AI review requested due to automatic review settings May 25, 2026 18:23
@v4xsh v4xsh force-pushed the tracing-apex-unification branch from 1ea1c38 to 4ee7137 Compare May 25, 2026 18:23
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

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

Comments suppressed due to low confidence (1)

libs/full/performance_counters/src/query_counters.cpp:1

  • This PR removes the prior behavior that suppressed console output when ITTNotify or Tracy backends were active (previously no_output was forced for cout destinations). With the new hpx::tracing routing, users may now get unexpected/duplicate output while also emitting tracing counter samples. If the suppression is still desired, reintroduce it behind the relevant compile-time backend macros or provide a hpx::tracing query (e.g. 'is_counter_backend_external') to keep the behavior consistent.

Comment thread libs/core/tracing/CMakeLists.txt
Comment thread libs/core/tracing/CMakeLists.txt
Comment thread libs/core/tracing/include/hpx/tracing/tracing.hpp Outdated
@hkaiser
Copy link
Copy Markdown
Contributor

hkaiser commented May 25, 2026

@v4xsh things start to look reasonable. Could you please have a look at the Copilot comments to see if those are applicable/sensible?

@v4xsh v4xsh force-pushed the tracing-apex-unification branch from 4ba3699 to 2449051 Compare May 25, 2026 22:07
@v4xsh
Copy link
Copy Markdown
Contributor Author

v4xsh commented May 25, 2026

@v4xsh things start to look reasonable. Could you please have a look at the Copilot comments to see if those are applicable/sensible?

Done!

Copilot AI review requested due to automatic review settings May 26, 2026 17:01
@v4xsh v4xsh force-pushed the tracing-apex-unification branch from 5a028a5 to a0e25eb Compare May 26, 2026 17:01
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

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

Comments suppressed due to low confidence (1)

libs/full/performance_counters/src/query_counters.cpp:1

  • The PR removes the previous behavior that suppressed console output (destination_is_cout) when using ITTNotify/Tracy counter backends. This is an observable behavior change: runs that previously only reported counters via the tracing backend may now also print periodically to stdout, which can be noisy and affect jobs that parse stdout. If the suppression is still desired with the unified tracing API, consider adding a hpx::tracing query (e.g., 'is_counter_backend_active' / 'wants_console_output_suppressed') and restoring the conditional suppression here.

Comment thread libs/core/tracy/cmake/HPX_SetupTracy.cmake
Comment thread libs/core/tracing/CMakeLists.txt
Comment thread libs/core/tracing/src/backends/ittnotify.cpp
@v4xsh v4xsh force-pushed the tracing-apex-unification branch from 643f8f4 to 92994cd Compare May 26, 2026 23:13
Copilot AI review requested due to automatic review settings May 26, 2026 23:36
@v4xsh v4xsh force-pushed the tracing-apex-unification branch from f26cb88 to 466326f Compare May 26, 2026 23:36
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

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

Comments suppressed due to low confidence (1)

libs/full/performance_counters/src/query_counters.cpp:1

  • remove_counter_prefix is now executed unconditionally for all tracing backends, even though some backends (e.g., ITTNotify and APEX in this PR) ignore short_name in sample_counter. This introduces avoidable string processing on every sample. Consider caching the short_name at create_counter time inside the tracing backend (keyed by full_name), or only computing real_name when the selected backend requires it.

Comment on lines +137 to +140
HPX_CXX_CORE_EXPORT HPX_CORE_EXPORT task_timer_data create_task_timer(
threads::thread_description const& description,
std::uint32_t parent_locality_id,
threads::thread_id const& parent_task);
Comment thread libs/core/tracing/src/backends/ittnotify.cpp
Comment on lines +84 to +87
itt_counters_.insert(std::make_pair(full_name,
util::itt::counter(short_name.c_str(),
hpx::detail::thread_name().c_str(),
__itt_metadata_double)));
Comment thread libs/core/tracing/CMakeLists.txt
@v4xsh v4xsh force-pushed the tracing-apex-unification branch from c83153a to d108ffa Compare May 27, 2026 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants