Skip to content

Add Perfetto profiling support to CI workflow#341

Open
greenc-FNAL wants to merge 4 commits intomainfrom
feature/perfetto-profiling
Open

Add Perfetto profiling support to CI workflow#341
greenc-FNAL wants to merge 4 commits intomainfrom
feature/perfetto-profiling

Conversation

@greenc-FNAL
Copy link
Contributor

@greenc-FNAL greenc-FNAL commented Feb 19, 2026

This commit adds Perfetto profiling as a matrix item in the cmake-build
GitHub workflow, enabling performance profiling of the C++ codebase.

Changes:

  • Add FindPerfetto.cmake module that searches standard locations
    (/opt/perfetto, /usr/local/include, /usr/include) and creates a
    Perfetto::Perfetto imported target following CMake best practices

  • Add ENABLE_PERFETTO CMake option and integrate Perfetto SDK linking
    to the phlex executable when profiling is enabled

  • Install Perfetto SDK (perfetto.h and perfetto.cc) in CI Docker image
    at /opt/perfetto for use during CI builds

  • Add gcc/perfetto and clang/perfetto to available build matrix
    combinations in generate_matrix.py

  • Add dedicated workflow step for Perfetto profiling runs that executes
    tests with profiling enabled, following the pattern established by
    the Valgrind step

  • Add weekly scheduled trigger (Saturdays at 18:00 UTC) that runs
    gcc/perfetto by default for regular performance profiling

The implementation follows existing workflow conventions for modularity,
naming, and reusable actions. Users can trigger Perfetto builds via
workflow_dispatch, issue comments (@phlexbot build gcc/perfetto), or
wait for the weekly scheduled run.

Note: this PR adds the infrastructure only: it does not add any instrumentation to the code.

Copy link
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 adds Perfetto profiling infrastructure to the CI workflow, enabling performance profiling of the C++ codebase. It integrates the Perfetto SDK into the build system, adds Perfetto as a build matrix option alongside existing sanitizers, and schedules weekly automated profiling runs.

Changes:

  • Adds Perfetto SDK (perfetto.h and perfetto.cc) installation to the CI Docker image
  • Creates FindPerfetto.cmake module for CMake integration with ENABLE_PERFETTO option
  • Extends build matrix with gcc/perfetto and clang/perfetto combinations and adds weekly scheduled trigger

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
ci/Dockerfile Installs Perfetto SDK files to /opt/perfetto for use during CI builds
Modules/FindPerfetto.cmake CMake Find module that locates Perfetto SDK and creates imported target
CMakeLists.txt Adds ENABLE_PERFETTO option and links Perfetto to phlex executable when enabled
.gitignore Adds /out/ directory to ignore list (presumably for Perfetto trace output)
.github/workflows/cmake-build.yaml Adds schedule trigger, Perfetto test step, and configuration for Perfetto builds
.github/actions/generate-build-matrix/generate_matrix.py Adds Perfetto to available combinations and sets it as default for scheduled runs

@codecov
Copy link

codecov bot commented Feb 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

@@            Coverage Diff             @@
##             main     #341      +/-   ##
==========================================
+ Coverage   84.94%   85.03%   +0.08%     
==========================================
  Files         127      127              
  Lines        3341     3341              
  Branches      574      574              
==========================================
+ Hits         2838     2841       +3     
  Misses        306      306              
+ Partials      197      194       -3     
Flag Coverage Δ
unittests 85.03% <ø> (+0.08%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.
see 2 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update aff8ec0...62f6c6c. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@greenc-FNAL
Copy link
Contributor Author

@phlexbot format

@github-actions
Copy link
Contributor

No automatic markdownlint fixes were necessary.

@github-actions
Copy link
Contributor

No automatic cmake-format fixes were necessary.

@github-actions
Copy link
Contributor

No automatic jsonnetfmt fixes were necessary.

@github-actions
Copy link
Contributor

No automatic clang-format fixes were necessary.

@greenc-FNAL
Copy link
Contributor Author

@phlexbot python-fix

@github-actions
Copy link
Contributor

Automatic ruff fixes pushed (commit 5566be8).
⚠️ Note: Some issues may require manual review and fixing.

@greenc-FNAL
Copy link
Contributor Author

@phlexbot cmake-fix

@github-actions
Copy link
Contributor

Automatic cmake-format fixes pushed (commit 234e0c0).
⚠️ Note: Some issues may require manual review and fixing.

@greenc-FNAL greenc-FNAL force-pushed the feature/perfetto-profiling branch from 234e0c0 to bd89c43 Compare February 20, 2026 14:32
@greenc-FNAL
Copy link
Contributor Author

@phlexbot cmake-fix

@github-actions
Copy link
Contributor

No automatic cmake-format fixes were necessary.

Copy link
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 6 out of 7 changed files in this pull request and generated 6 comments.

@greenc-FNAL greenc-FNAL force-pushed the feature/perfetto-profiling branch 3 times, most recently from 6744794 to 66f4542 Compare February 24, 2026 16:32
This commit adds Perfetto profiling as a matrix item in the cmake-build
GitHub workflow, enabling performance profiling of the C++ codebase.

Changes:

- Add FindPerfetto.cmake module that searches standard locations
  (/opt/perfetto, /usr/local/include, /usr/include) and creates a
  Perfetto::Perfetto imported target following CMake best practices

- Add ENABLE_PERFETTO CMake option and integrate Perfetto SDK linking
  to the phlex executable when profiling is enabled

- Install Perfetto SDK (perfetto.h and perfetto.cc) in CI Docker image
  at /opt/perfetto for use during CI builds

- Add gcc/perfetto and clang/perfetto to available build matrix
  combinations in generate_matrix.py

- Add dedicated workflow step for Perfetto profiling runs that executes
  tests with profiling enabled, following the pattern established by
  the Valgrind step

- Add weekly scheduled trigger (Saturdays at 18:00 UTC) that runs
  gcc/perfetto by default for regular performance profiling

The implementation follows existing workflow conventions for modularity,
naming, and reusable actions. Users can trigger Perfetto builds via
workflow_dispatch, issue comments (@phlexbot build gcc/perfetto), or
wait for the weekly scheduled run.
@greenc-FNAL greenc-FNAL force-pushed the feature/perfetto-profiling branch from 66f4542 to 8fb8e63 Compare March 20, 2026 22:55
@greenc-FNAL greenc-FNAL requested a review from aolivier23 as a code owner March 20, 2026 22:55
@greenc-FNAL
Copy link
Contributor Author

@phlexbot yaml-fix

@greenc-FNAL
Copy link
Contributor Author

Review the full CodeQL report for details.

@greenc-FNAL
Copy link
Contributor Author

@phlexbot yaml-fix

3 similar comments
@greenc-FNAL
Copy link
Contributor Author

@phlexbot yaml-fix

@greenc-FNAL
Copy link
Contributor Author

@phlexbot yaml-fix

@greenc-FNAL
Copy link
Contributor Author

@phlexbot yaml-fix

@github-actions
Copy link
Contributor

Automatic YAML formatter fixes pushed (commit 35c5b03).
⚠️ Note: Some issues may require manual review and fixing.

greenc-FNAL added a commit that referenced this pull request Mar 21, 2026
- Remove --security-opt seccomp=unconfined from container options;
  SYS_PTRACE alone is sufficient and seccomp=unconfined is a broader
  security relaxation than required

- Fix PERFETTO_CPU_PROFILE fallback default from the string 'true' to
  the boolean true, consistent with the workflow_dispatch input default

- Initialize TEST_RESULT=0 before the conditional tracebox block for
  clarity, making the intent explicit rather than relying on :- default

- Rename FindPerfetto.cmake internal target perfetto_impl to
  Perfetto_impl to follow the namespaced capitalization convention and
  reduce risk of collision with user-defined targets

- Make ENABLE_PERFETTO a Linux-only option via cmake_dependent_option,
  since the Perfetto SDK only supports Linux

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@greenc-FNAL
Copy link
Contributor Author

@phlexbot cmake-fix

@github-actions
Copy link
Contributor

Automatic cmake-format fixes pushed (commit da4358a).
⚠️ Note: Some issues may require manual review and fixing.

greenc-FNAL and others added 3 commits March 20, 2026 21:23
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

Upload Perfetto trace files as workflow artifacts

Add artifact upload step to the Perfetto profiling workflow to capture
trace files generated during test execution, enabling offline analysis
via the Perfetto UI.

Changes:

- Add upload-artifact step after Perfetto profiling runs that collects
  all .pftrace files from the build directory

- Name artifacts by compiler (perfetto-traces-gcc, perfetto-traces-clang)
  to distinguish between different compiler runs

- Set 30-day retention period for trace files to allow sufficient time
  for analysis while managing storage costs

- Configure if-no-files-found: warn to alert if profiling did not
  generate expected trace output

Users can download the trace artifacts from the workflow run and analyze
them at https://ui.perfetto.dev/ for detailed performance profiling and
visualization of the test execution.

Add tracebox and advanced profiling support to Perfetto workflow

Enable heap profiling, CPU profiling, and system-wide tracing via
Perfetto's tracebox tool for comprehensive performance analysis.

Changes:

- Install tracebox binary in CI Docker image from get.perfetto.dev for
  system-wide profiling capabilities

- Add workflow_dispatch inputs for perfetto-heap-profile and
  perfetto-cpu-profile to control profiling modes (CPU profiling
  enabled by default, heap profiling opt-in)

- Add SYS_PTRACE capability and disable seccomp in container options
  to enable perf_event access required for CPU profiling

- Configure perf_event_paranoid=-1 at runtime when CPU profiling is
  enabled to allow non-root access to performance counters

- Update Perfetto profiling step to conditionally wrap ctest execution
  with tracebox when heap or CPU profiling is enabled, passing
  appropriate flags (--heapprofd for heap, --cpu-freq/--cpu-idle/
  --cpu-sched for CPU)

- Fall back to SDK-only tracing when no system profiling is requested

Users can now enable heap profiling and CPU counter profiling via
workflow_dispatch inputs to capture detailed memory allocation patterns
and CPU performance metrics alongside application traces.

Minor tweaks, and improvements per Copilot review

- Restrict artifact upload path to build directory only to avoid
  collecting unintended files from source tree
- Use absolute path for tracebox output file to ensure trace is written
  to expected location within build directory
- Move Perfetto linking to phlex/app/CMakeLists.txt immediately after
  cet_make_exec() to localize it to the executable creation
- Use specific Perfetto SDK version (v51.0) instead of main branch for
  reproducible container builds

Apply YAML formatter fixes
- Remove --security-opt seccomp=unconfined from container options;
  SYS_PTRACE alone is sufficient and seccomp=unconfined is a broader
  security relaxation than required

- Fix PERFETTO_CPU_PROFILE fallback default from the string 'true' to
  the boolean true, consistent with the workflow_dispatch input default

- Initialize TEST_RESULT=0 before the conditional tracebox block for
  clarity, making the intent explicit rather than relying on :- default

- Rename FindPerfetto.cmake internal target perfetto_impl to
  Perfetto_impl to follow the namespaced capitalization convention and
  reduce risk of collision with user-defined targets

- Make ENABLE_PERFETTO a Linux-only option via cmake_dependent_option,
  since the Perfetto SDK only supports Linux

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The Perfetto project currently offers no versioned or checksum-verifiable
standalone tracebox binary download. Add a comment noting this known
limitation so it is visible for future remediation.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@greenc-FNAL greenc-FNAL force-pushed the feature/perfetto-profiling branch from da4358a to 62f6c6c Compare March 21, 2026 02:23
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.

3 participants