Skip to content

Commit

Permalink
ci(profiling): gh action to run native tests with sanitizers (#11623)
Browse files Browse the repository at this point in the history
1. Adds a GitHub action running profiling native tests with {thread,
safety} sanitizers
2. Adds Thread sanitizer suppressions list
3. Updates echion commit to point to `taegyunkim/algorithm-include` from
`taegyunkim/macos-fix`,
taegyunkim/echion@taegyunkim/macos-fix...taegyunkim:echion:taegyunkim/algorithm-include
This change was necessary to compile native tests on the actions ubuntu
runner.


## Checklist
- [x] PR author has checked that all the criteria below are met
- The PR description includes an overview of the change
- The PR description articulates the motivation for the change
- The change includes tests OR the PR description describes a testing
strategy
- The PR description notes risks associated with the change, if any
- Newly-added code is easy to change
- The change follows the [library release note
guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html)
- The change includes or references documentation updates if necessary
- Backport labels are set (if
[applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting))

## Reviewer Checklist
- [x] Reviewer has checked that all the criteria below are met 
- Title is accurate
- All changes are related to the pull request's stated goal
- Avoids breaking
[API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces)
changes
- Testing strategy adequately addresses listed risks
- Newly-added code is easy to change
- Release note makes sense to a user of the library
- If necessary, author has acknowledged and discussed the performance
implications of this PR as reported in the benchmarks PR comment
- Backport labels are set in a manner that is consistent with the
[release branch maintenance
policy](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)

---------

Co-authored-by: Emmett Butler <[email protected]>
  • Loading branch information
taegyunkim and emmettbutler authored Dec 9, 2024
1 parent dcfaed4 commit 3232531
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 2 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/profiling-native.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Profiling Native Tests with Sanitizers

on:
push:
branches:
- main
- "mq-working-branch**"
pull_request:
paths:
- ddtrace/internal/datadog/profiling/**
- ddtrace/profiling/**
workflow_dispatch: {}

jobs:
test:
runs-on: ${{ matrix.os }}
timeout-minutes: 5
strategy:
fail-fast: false
matrix:
os: [ubuntu-24.04]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
sanitizer: ["safety", "thread"]

steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
fetch-depth: 1

- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install llvm 19
run: |
# Ubuntu-24.04 GH actions image has llvm-18, but we use 19 as it's
# the latest one available.
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 19
- name: Run tests with sanitizers
run: |
# DEV: We currently have tests in dd_wrapper and stack_v2, setting
# stack_v2 here will also run tests in dd_wrapper. Revisit this when
# that changes.
./ddtrace/internal/datadog/profiling/build_standalone.sh --${{matrix.sanitizer}} RelWithDebInfo stack_v2_test
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ function(dd_wrapper_add_test name)
target_link_libraries(${name} PRIVATE gmock gtest_main dd_wrapper nlohmann_json::nlohmann_json)
add_ddup_config(${name})

gtest_discover_tests(${name})
gtest_discover_tests(${name}
PROPERTIES
# We start new threads after fork(), and we want to continue
# running the tests after that instead of dying.
ENVIRONMENT "TSAN_OPTIONS=die_after_fork=0:suppressions=${CMAKE_CURRENT_SOURCE_DIR}/TSan.supp"
)

set_target_properties(${name} PROPERTIES INSTALL_RPATH "$ORIGIN/..")

Expand Down
4 changes: 4 additions & 0 deletions ddtrace/internal/datadog/profiling/dd_wrapper/test/TSan.supp
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# libdd is not compiled with sanitizers so probably that's why we get these
# data races from ddog_ArrayQueue and Datadog::Sample operations
race:ddog_ArrayQueue
race:Datadog::Sample::
2 changes: 1 addition & 1 deletion ddtrace/internal/datadog/profiling/stack_v2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ endif()

# Add echion
set(ECHION_COMMIT
"9d5bcc5867d7aefff73c837adcba4ef46eecebc6"
"ed744987f224fae3f93c842b2b5ffb083984ff8b"
CACHE STRING "Commit hash of echion to use")
FetchContent_Declare(
echion
Expand Down

0 comments on commit 3232531

Please sign in to comment.