Skip to content

Commit 0046ee3

Browse files
feat(prof): switch panics to abort (#3474)
Co-authored-by: Levi Morrison <[email protected]>
1 parent c3be656 commit 0046ee3

File tree

8 files changed

+41
-34
lines changed

8 files changed

+41
-34
lines changed

.github/workflows/prof_asan.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
~/.cargo/registry/index/
3030
~/.cargo/registry/cache/
3131
~/.cargo/git/db/
32-
target/
32+
/tmp/build-cargo/
3333
key: ${{ runner.os }}-cargo-asan-${{ hashFiles('**/Cargo.lock') }}
3434

3535
- name: Build and install profiler
@@ -45,8 +45,8 @@ jobs:
4545
triplet=$(uname -m)-unknown-linux-gnu
4646
RUST_NIGHTLY_VERSION="-2025-01-03"
4747
rustup component add rust-src --toolchain nightly${RUST_NIGHTLY_VERSION}
48-
RUSTFLAGS='-Zsanitizer=address' cargo +nightly${RUST_NIGHTLY_VERSION} build -Zbuild-std --target $triplet --release
49-
cp -v "$CARGO_TARGET_DIR/$triplet/release/libdatadog_php_profiling.so" "$(php-config --extension-dir)/datadog-profiling.so"
48+
RUSTFLAGS='-Zsanitizer=address' cargo +nightly${RUST_NIGHTLY_VERSION} build -Zbuild-std=std,panic_abort --target $triplet --profile profiler-release
49+
cp -v "$CARGO_TARGET_DIR/$triplet/profiler-release/libdatadog_php_profiling.so" "$(php-config --extension-dir)/datadog-profiling.so"
5050
5151
- name: Cache build dependencies
5252
uses: actions/cache/save@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0

.github/workflows/prof_correctness.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ jobs:
5555
cd profiling
5656
version_number=$(awk -F' = ' '$1 == "channel" { gsub(/"/, "", $2); print $2 }' rust-toolchain.toml)
5757
curl https://sh.rustup.rs -sSf | sh -s -- --profile minimal -y --default-toolchain "$version_number"
58-
cargo rustc --features="trigger_time_sample" --release --crate-type=cdylib
58+
cargo rustc --features="trigger_time_sample" --profile profiler-release --crate-type=cdylib
5959
6060
- name: Cache build dependencies
6161
uses: actions/cache/save@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
@@ -74,13 +74,13 @@ jobs:
7474
export DD_PROFILING_EXPERIMENTAL_FEATURES_ENABLED=1
7575
export DD_PROFILING_EXCEPTION_MESSAGE_ENABLED=1
7676
php -v
77-
php -d extension=target/release/libdatadog_php_profiling.so --ri datadog-profiling
77+
php -d extension=target/profiler-release/libdatadog_php_profiling.so --ri datadog-profiling
7878
for test_case in "allocations" "time" "strange_frames" "timeline" "exceptions"; do
7979
mkdir -p profiling/tests/correctness/"$test_case"/
8080
export DD_PROFILING_OUTPUT_PPROF=$PWD/profiling/tests/correctness/"$test_case"/test.pprof
81-
php -d extension=$PWD/target/release/libdatadog_php_profiling.so profiling/tests/correctness/"$test_case".php
82-
if [ -f "$DD_PROFILING_OUTPUT_PPROF".1.zst ]; then
83-
echo "File $DD_PROFILING_OUTPUT_PPROF.1.zst should not exist!"
81+
php -d extension="${PWD}/target/profiler-release/libdatadog_php_profiling.so" "profiling/tests/correctness/${test_case}.php"
82+
if [ -f "$DD_PROFILING_OUTPUT_PPROF".1.lz4 ]; then
83+
echo "File $DD_PROFILING_OUTPUT_PPROF.1.lz4 should not exist!"
8484
exit 1;
8585
fi
8686
done
@@ -92,16 +92,16 @@ jobs:
9292
export DD_PROFILING_EXPERIMENTAL_EXCEPTION_SAMPLING_DISTANCE=1
9393
export DD_PROFILING_EXCEPTION_MESSAGE_ENABLED=1
9494
php -v
95-
php -d extension=target/release/libdatadog_php_profiling.so --ri datadog-profiling
95+
php -d extension=target/profiler-release/libdatadog_php_profiling.so --ri datadog-profiling
9696
for test_case in "allocations" "time" "strange_frames" "timeline" "exceptions"; do
9797
mkdir -p profiling/tests/correctness/"$test_case"/
9898
export DD_PROFILING_OUTPUT_PPROF=$PWD/profiling/tests/correctness/"$test_case"/test.pprof
99-
php -d extension=$PWD/target/release/libdatadog_php_profiling.so profiling/tests/correctness/"$test_case".php
99+
php -d extension=$PWD/target/profiler-release/libdatadog_php_profiling.so profiling/tests/correctness/"$test_case".php
100100
done
101101
mkdir -p profiling/tests/correctness/allocations_1byte/
102102
export DD_PROFILING_OUTPUT_PPROF=$PWD/profiling/tests/correctness/allocations_1byte/test.pprof
103103
export DD_PROFILING_ALLOCATION_SAMPLING_DISTANCE=1
104-
php -d extension=$PWD/target/release/libdatadog_php_profiling.so profiling/tests/correctness/allocations.php
104+
php -d extension=$PWD/target/profiler-release/libdatadog_php_profiling.so profiling/tests/correctness/allocations.php
105105
unset DD_PROFILING_ALLOCATION_SAMPLING_DISTANCE
106106
107107
- name: Run ZTS tests
@@ -112,11 +112,11 @@ jobs:
112112
export DD_PROFILING_EXPERIMENTAL_EXCEPTION_SAMPLING_DISTANCE=1
113113
export DD_PROFILING_EXCEPTION_MESSAGE_ENABLED=1
114114
php -v
115-
php -d extension=target/release/libdatadog_php_profiling.so --ri datadog-profiling
115+
php -d extension=target/profiler-release/libdatadog_php_profiling.so --ri datadog-profiling
116116
for test_case in "exceptions_zts"; do
117117
mkdir -p profiling/tests/correctness/"$test_case"/
118118
export DD_PROFILING_OUTPUT_PPROF=$PWD/profiling/tests/correctness/"$test_case"/test.pprof
119-
php -d extension=$PWD/target/release/libdatadog_php_profiling.so profiling/tests/correctness/"$test_case".php
119+
php -d extension=$PWD/target/profiler-release/libdatadog_php_profiling.so profiling/tests/correctness/"$test_case".php
120120
done
121121
122122
- name: Check profiler correctness for allocations

.gitlab/build-profiler.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ echo "${CARGO_TARGET_DIR}"
4343
if [ "$thread_safety" = "zts" ]; then
4444
touch build.rs # Ensure build.rs executes after switch-php for ZTS
4545
fi
46-
cargo build --release
46+
cargo build --profile profiler-release
4747
cd -
4848

49-
cp -v "${CARGO_TARGET_DIR}/release/libdatadog_php_profiling.so" "${output_file}"
49+
cp -v "${CARGO_TARGET_DIR}/profiler-release/libdatadog_php_profiling.so" "${output_file}"
5050
objcopy --compress-debug-sections "${output_file}"

.gitlab/generate-profiler.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,15 @@
4545

4646
- '# NTS'
4747
- command -v switch-php && switch-php "${PHP_MAJOR_MINOR}"
48-
- cargo build --release --all-features
49-
- (cd tests; php run-tests.php -d "extension=/mnt/ramdisk/cargo/release/libdatadog_php_profiling.so" --show-diff -g "FAIL,XFAIL,BORK,WARN,LEAK,XLEAK,SKIP" "phpt")
48+
- cargo build --profile profiler-release --all-features
49+
- (cd tests; php run-tests.php -d "extension=/mnt/ramdisk/cargo/profiler-release/libdatadog_php_profiling.so" --show-diff -g "FAIL,XFAIL,BORK,WARN,LEAK,XLEAK,SKIP" "phpt")
5050

5151
- touch build.rs #make sure `build.rs` gets executed after `switch-php` call
5252

5353
- '# ZTS'
5454
- command -v switch-php && switch-php "${PHP_MAJOR_MINOR}-zts"
55-
- cargo build --release --all-features
56-
- (cd tests; php run-tests.php -d "extension=/mnt/ramdisk/cargo/release/libdatadog_php_profiling.so" --show-diff -g "FAIL,XFAIL,BORK,WARN,LEAK,XLEAK,SKIP" "phpt")
55+
- cargo build --profile profiler-release --all-features
56+
- (cd tests; php run-tests.php -d "extension=/mnt/ramdisk/cargo/profiler-release/libdatadog_php_profiling.so" --show-diff -g "FAIL,XFAIL,BORK,WARN,LEAK,XLEAK,SKIP" "phpt")
5757

5858
"clippy NTS":
5959
stage: test

Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ codegen-units = 1
2525
panic = "abort"
2626
inherits = "release"
2727

28+
[profile.profiler-release]
29+
panic = "abort"
30+
inherits = "release"
31+
2832
# These are to satistfy the build with libdatadog as a path dependency inside
2933
# components-rs. There may be a better way to fix this, but I'm alreday two
3034
# tasks removed from what I'm trying to do, so pushing forward.

docker-compose.yml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -73,19 +73,19 @@ services:
7373
# --- Alpine ---
7474
'8.0-alpine': { <<: *linux_php_service, image: 'datadog/dd-trace-ci:php-8.0_alpine' }
7575
# --- Bookworm ---
76-
'7.0-bookworm': { <<: *linux_php_service, image: 'datadog/dd-trace-ci:php-7.0_bookworm-5' }
77-
'7.1-bookworm': { <<: *linux_php_service, image: 'datadog/dd-trace-ci:php-7.1_bookworm-5' }
78-
'7.2-bookworm': { <<: *linux_php_service, image: 'datadog/dd-trace-ci:php-7.2_bookworm-5' }
79-
'7.3-bookworm': { <<: *linux_php_service, image: 'datadog/dd-trace-ci:php-7.3_bookworm-5' }
80-
'7.4-bookworm': { <<: *linux_php_service, image: 'datadog/dd-trace-ci:php-7.4_bookworm-5' }
81-
'7.4-bookworm-shared-ext': { <<: *linux_php_service, image: 'datadog/dd-trace-ci:php-7.4-shared-ext-5' }
82-
'8.0-bookworm': { <<: *linux_php_service, image: 'datadog/dd-trace-ci:php-8.0_bookworm-5' }
83-
'8.0-bookworm-shared-ext': { <<: *linux_php_service, image: 'datadog/dd-trace-ci:php-8.0-shared-ext-5' }
84-
'8.1-bookworm': { <<: *linux_php_service, image: 'datadog/dd-trace-ci:php-8.1_bookworm-5' }
85-
'8.2-bookworm': { <<: *linux_php_service, image: 'datadog/dd-trace-ci:php-8.2_bookworm-5' }
86-
'8.3-bookworm': { <<: *linux_php_service, image: 'datadog/dd-trace-ci:php-8.3_bookworm-5' }
87-
'8.4-bookworm': { <<: *linux_php_service, image: 'datadog/dd-trace-ci:php-8.4_bookworm-5' }
88-
'8.5-bookworm': { <<: *linux_php_service, image: 'datadog/dd-trace-ci:php-8.5_bookworm-5' }
76+
'7.0-bookworm': { <<: *linux_php_service, image: 'datadog/dd-trace-ci:php-7.0_bookworm-6' }
77+
'7.1-bookworm': { <<: *linux_php_service, image: 'datadog/dd-trace-ci:php-7.1_bookworm-6' }
78+
'7.2-bookworm': { <<: *linux_php_service, image: 'datadog/dd-trace-ci:php-7.2_bookworm-6' }
79+
'7.3-bookworm': { <<: *linux_php_service, image: 'datadog/dd-trace-ci:php-7.3_bookworm-6' }
80+
'7.4-bookworm': { <<: *linux_php_service, image: 'datadog/dd-trace-ci:php-7.4_bookworm-6' }
81+
'7.4-bookworm-shared-ext': { <<: *linux_php_service, image: 'datadog/dd-trace-ci:php-7.4-shared-ext-6' }
82+
'8.0-bookworm': { <<: *linux_php_service, image: 'datadog/dd-trace-ci:php-8.0_bookworm-6' }
83+
'8.0-bookworm-shared-ext': { <<: *linux_php_service, image: 'datadog/dd-trace-ci:php-8.0-shared-ext-6' }
84+
'8.1-bookworm': { <<: *linux_php_service, image: 'datadog/dd-trace-ci:php-8.1_bookworm-6' }
85+
'8.2-bookworm': { <<: *linux_php_service, image: 'datadog/dd-trace-ci:php-8.2_bookworm-6' }
86+
'8.3-bookworm': { <<: *linux_php_service, image: 'datadog/dd-trace-ci:php-8.3_bookworm-6' }
87+
'8.4-bookworm': { <<: *linux_php_service, image: 'datadog/dd-trace-ci:php-8.4_bookworm-6' }
88+
'8.5-bookworm': { <<: *linux_php_service, image: 'datadog/dd-trace-ci:php-8.5_bookworm-6' }
8989
'php-master-buster': { <<: *linux_php_service, image: 'datadog/dd-trace-ci:php-master_buster' }
9090
# --- CentOS 6 ---
9191
'7.0-centos7': { <<: *linux_php_service, image: 'datadog/dd-trace-ci:php-7.0_centos-7' }

dockerfiles/ci/bookworm/.env

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
BOOKWORM_CURRENT_VERSION=5
2-
BOOKWORM_NEXT_VERSION=6
1+
BOOKWORM_CURRENT_VERSION=6
2+
BOOKWORM_NEXT_VERSION=7

profiling/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ edition = "2021"
55
license = "Apache-2.0"
66
rust-version = "1.84.1"
77

8+
[profile.release]
9+
panic = "abort"
10+
811
[lib]
912
crate-type = ["cdylib"]
1013
bench = false # disables cargo build in libtest bench

0 commit comments

Comments
 (0)