-
Notifications
You must be signed in to change notification settings - Fork 10
Add Perfetto profiling support to CI workflow #341
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
d62bb90
daf1214
7139789
1d6b328
9721944
5cb38ed
acc2413
66f4542
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -7,6 +7,8 @@ on: | |||||||||||||
| types: [created] | ||||||||||||||
| push: | ||||||||||||||
| branches: [ main, develop ] | ||||||||||||||
| schedule: | ||||||||||||||
| - cron: '0 18 * * 6' | ||||||||||||||
| workflow_dispatch: | ||||||||||||||
| inputs: | ||||||||||||||
| ref: | ||||||||||||||
|
|
@@ -21,9 +23,19 @@ on: | |||||||||||||
| - `all` (run all combinations) | ||||||||||||||
| - `all -clang/none -clang/valgrind` (run all except specified) | ||||||||||||||
| - `+clang/none +clang/valgrind` (run default matrix plus specified) | ||||||||||||||
| Default (if empty): Run all except clang/none and clang/valgrind. | ||||||||||||||
| Default (if empty): Run `gcc/none` | ||||||||||||||
| required: false | ||||||||||||||
| default: '' | ||||||||||||||
| perfetto-heap-profile: | ||||||||||||||
| description: "Enable heap profiling for Perfetto runs" | ||||||||||||||
| required: false | ||||||||||||||
| type: boolean | ||||||||||||||
| default: false | ||||||||||||||
| perfetto-cpu-profile: | ||||||||||||||
| description: "Enable CPU profiling for Perfetto runs" | ||||||||||||||
| required: false | ||||||||||||||
| type: boolean | ||||||||||||||
| default: true | ||||||||||||||
| workflow_call: | ||||||||||||||
| inputs: | ||||||||||||||
| checkout-path: | ||||||||||||||
|
|
@@ -76,6 +88,7 @@ jobs: | |||||||||||||
| github.event_name == 'workflow_dispatch' || | ||||||||||||||
| github.event_name == 'pull_request' || | ||||||||||||||
| github.event_name == 'push' || | ||||||||||||||
| github.event_name == 'schedule' || | ||||||||||||||
| github.event_name == 'workflow_call' || | ||||||||||||||
| ( | ||||||||||||||
| github.event_name == 'issue_comment' && | ||||||||||||||
|
|
@@ -190,6 +203,7 @@ jobs: | |||||||||||||
|
|
||||||||||||||
| container: | ||||||||||||||
| image: ghcr.io/framework-r-d/phlex-ci:latest | ||||||||||||||
| options: --cap-add=SYS_PTRACE --security-opt seccomp=unconfined | ||||||||||||||
|
||||||||||||||
| options: --cap-add=SYS_PTRACE --security-opt seccomp=unconfined | |
| options: --cap-add=SYS_PTRACE |
Copilot
AI
Feb 20, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Perfetto profiling step defaults PERFETTO_CPU_PROFILE to 'true' when inputs are not available (line 286). This creates different defaults for scheduled runs versus manual workflow_dispatch runs - scheduled runs will default to the string 'true', but workflow_dispatch defaults to the boolean true (line 38).
In Bash string comparisons, both will work, but for consistency, consider using consistent types. Either make both boolean true or both the string 'true'. Additionally, for scheduled event triggers, github.event.inputs will be null, so this will always use the fallback defaults. Document this behavior or ensure consistent handling across all event types.
| PERFETTO_HEAP_PROFILE: ${{ github.event.inputs.perfetto-heap-profile || 'false' }} | |
| PERFETTO_CPU_PROFILE: ${{ github.event.inputs.perfetto-cpu-profile || 'true' }} | |
| # For scheduled events, github.event.inputs is null, so these fallbacks | |
| # define the effective defaults (aligned with the workflow_dispatch inputs). | |
| PERFETTO_HEAP_PROFILE: ${{ github.event.inputs.perfetto-heap-profile || 'false' }} | |
| PERFETTO_CPU_PROFILE: ${{ github.event.inputs.perfetto-cpu-profile || true }} |
Copilot
AI
Feb 20, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test result variable TEST_RESULT is used on line 320 but only conditionally set on lines 313 and 316. If neither branch sets it (which shouldn't happen with the current logic, but the code structure suggests defensive programming), the expression ${TEST_RESULT:-0} will correctly default to 0. However, for clarity and to follow shell best practices, consider initializing TEST_RESULT=0 before the conditional block to make the intent explicit.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,7 @@ | |
| /_deps/ | ||
| /build-*/ | ||
| /build/ | ||
| /out/ | ||
| /phlex-build/ | ||
| /phlex-src/ | ||
| CMakeFiles/ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -62,6 +62,7 @@ include(Modules/private/CreateCoverageTargets.cmake) | |
|
|
||
| option(ENABLE_TSAN "Enable Thread Sanitizer" OFF) | ||
| option(ENABLE_ASAN "Enable Address Sanitizer" OFF) | ||
| option(ENABLE_PERFETTO "Enable Perfetto profiling" OFF) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can this option be enabled only for Linux? |
||
| option(PHLEX_USE_FORM "Enable experimental integration with FORM" OFF) | ||
| option(ENABLE_COVERAGE "Enable code coverage instrumentation" OFF) | ||
| option(ENABLE_CLANG_TIDY "Enable clang-tidy checks during build" OFF) | ||
|
|
@@ -145,6 +146,12 @@ if(ENABLE_ASAN) | |
| endif() | ||
| endif() | ||
|
|
||
| # Configure Perfetto profiling if enabled | ||
| if(ENABLE_PERFETTO) | ||
| message(STATUS "Enabling Perfetto profiling") | ||
| find_package(Perfetto REQUIRED) | ||
| endif() | ||
|
|
||
| # Configure code coverage if enabled | ||
| if(ENABLE_COVERAGE) | ||
| # Check if the compiler supports code coverage | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,31 @@ | ||||||||||||||||||||||
| # FindPerfetto.cmake | ||||||||||||||||||||||
| # Finds the Perfetto SDK (single-header implementation) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| include(FindPackageHandleStandardArgs) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| find_path( | ||||||||||||||||||||||
| Perfetto_INCLUDE_DIR | ||||||||||||||||||||||
| NAMES perfetto.h | ||||||||||||||||||||||
| PATHS /opt/perfetto /usr/local/include /usr/include | ||||||||||||||||||||||
| DOC "Perfetto SDK header location" | ||||||||||||||||||||||
| ) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| find_file( | ||||||||||||||||||||||
| Perfetto_SOURCE | ||||||||||||||||||||||
| NAMES perfetto.cc | ||||||||||||||||||||||
| PATHS /opt/perfetto /usr/local/include /usr/include | ||||||||||||||||||||||
| DOC "Perfetto SDK implementation file" | ||||||||||||||||||||||
| ) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| find_package_handle_standard_args(Perfetto REQUIRED_VARS Perfetto_INCLUDE_DIR Perfetto_SOURCE) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| if(Perfetto_FOUND AND NOT TARGET Perfetto::Perfetto) | ||||||||||||||||||||||
| find_package(Threads REQUIRED) | ||||||||||||||||||||||
| add_library(perfetto_impl STATIC "${Perfetto_SOURCE}") | ||||||||||||||||||||||
| target_include_directories(perfetto_impl PUBLIC "${Perfetto_INCLUDE_DIR}") | ||||||||||||||||||||||
| target_compile_definitions(perfetto_impl PUBLIC PERFETTO_ENABLE_TRACING=1) | ||||||||||||||||||||||
greenc-FNAL marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||
| target_link_libraries(perfetto_impl PUBLIC Threads::Threads) | ||||||||||||||||||||||
| add_library(Perfetto::Perfetto ALIAS perfetto_impl) | ||||||||||||||||||||||
|
Comment on lines
+24
to
+28
|
||||||||||||||||||||||
| add_library(perfetto_impl STATIC "${Perfetto_SOURCE}") | |
| target_include_directories(perfetto_impl PUBLIC "${Perfetto_INCLUDE_DIR}") | |
| target_compile_definitions(perfetto_impl PUBLIC PERFETTO_ENABLE_TRACING=1) | |
| target_link_libraries(perfetto_impl PUBLIC Threads::Threads) | |
| add_library(Perfetto::Perfetto ALIAS perfetto_impl) | |
| add_library(Perfetto_impl STATIC "${Perfetto_SOURCE}") | |
| target_include_directories(Perfetto_impl PUBLIC "${Perfetto_INCLUDE_DIR}") | |
| target_compile_definitions(Perfetto_impl PUBLIC PERFETTO_ENABLE_TRACING=1) | |
| target_link_libraries(Perfetto_impl PUBLIC Threads::Threads) | |
| add_library(Perfetto::Perfetto ALIAS Perfetto_impl) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -280,6 +280,32 @@ set -euo pipefail | |
| rm -f /tmp/spack.yaml | ||
| CLEAN_TEMP_FILES | ||
|
|
||
| ######################################################################## | ||
| # Install Perfetto SDK for profiling | ||
|
|
||
| RUN <<'INSTALL_PERFETTO' | ||
| set -euo pipefail | ||
|
|
||
| # Install Perfetto SDK and tools | ||
| apt-get update | ||
| apt-get install -y --no-install-recommends \ | ||
| wget | ||
| apt-get clean | ||
| rm -rf /var/lib/apt/lists/* | ||
|
|
||
| mkdir -p /opt/perfetto | ||
| cd /opt/perfetto | ||
| PERFETTO_VERSION=v51.0 | ||
| wget -O perfetto.h https://raw.githubusercontent.com/google/perfetto/${PERFETTO_VERSION}/sdk/perfetto.h | ||
| wget -O perfetto.cc https://raw.githubusercontent.com/google/perfetto/${PERFETTO_VERSION}/sdk/perfetto.cc | ||
| chmod 644 perfetto.h perfetto.cc | ||
|
|
||
| # Install tracebox for system-wide profiling | ||
| wget -O tracebox https://get.perfetto.dev/tracebox | ||
| chmod +x tracebox | ||
|
Comment on lines
+303
to
+305
|
||
| mv tracebox /usr/local/bin/ | ||
| INSTALL_PERFETTO | ||
|
|
||
| ######################################################################## | ||
| # Finalize CI image stage | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The workflow_dispatch inputs
perfetto-heap-profileandperfetto-cpu-profile(lines 29-38) are not available when this workflow is triggered viaworkflow_call. This means external workflows that call this workflow cannot control Perfetto profiling options.Consider adding corresponding inputs to the
workflow_callsection (starting at line 39) so that calling workflows can pass through these profiling configuration options.