Add Perfetto profiling support to CI workflow#341
Conversation
There was a problem hiding this comment.
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 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
Flags with carried forward coverage won't be shown. Click here to find out more. Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
|
@phlexbot format |
|
No automatic markdownlint fixes were necessary. |
|
No automatic cmake-format fixes were necessary. |
|
No automatic jsonnetfmt fixes were necessary. |
|
No automatic clang-format fixes were necessary. |
|
@phlexbot python-fix |
|
Automatic ruff fixes pushed (commit 5566be8). |
|
@phlexbot cmake-fix |
|
Automatic cmake-format fixes pushed (commit 234e0c0). |
234e0c0 to
bd89c43
Compare
|
@phlexbot cmake-fix |
|
No automatic cmake-format fixes were necessary. |
6744794 to
66f4542
Compare
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.
66f4542 to
8fb8e63
Compare
|
@phlexbot yaml-fix |
|
Review the full CodeQL report for details. |
|
@phlexbot yaml-fix |
3 similar comments
|
@phlexbot yaml-fix |
|
@phlexbot yaml-fix |
|
@phlexbot yaml-fix |
|
Automatic YAML formatter fixes pushed (commit 35c5b03). |
- 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>
|
@phlexbot cmake-fix |
|
Automatic cmake-format fixes pushed (commit da4358a). |
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>
da4358a to
62f6c6c
Compare
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.