diff --git a/.circleci/continue_config.yml b/.circleci/continue_config.yml index 88a456e951..9f47e54404 100644 --- a/.circleci/continue_config.yml +++ b/.circleci/continue_config.yml @@ -529,7 +529,7 @@ commands: type: string steps: - run: - name: Build Profiler + name: Build Profiler NTS command: | if [ -d '/opt/rh/devtoolset-7' ] ; then set +eo pipefail @@ -545,6 +545,24 @@ commands: cargo build --release cd - cp -v "${CARGO_TARGET_DIR}/release/libdatadog_php_profiling.so" "${prefix}/datadog-profiling.so" + - run: + name: Build Profiler ZTS + command: | + if [ -d '/opt/rh/devtoolset-7' ] ; then + set +eo pipefail + source scl_source enable devtoolset-7 + set -eo pipefail + fi + set -u + prefix="<< parameters.prefix >>" + mkdir -vp "${prefix}" + command -v switch-php && switch-php "${PHP_VERSION}-zts" + cd profiling + echo "${CARGO_TARGET_DIR}" + touch build.rs #make sure `build.rs` gets executed after `switch-php` call + cargo build --release + cd - + cp -v "${CARGO_TARGET_DIR}/release/libdatadog_php_profiling.so" "${prefix}/datadog-profiling-zts.so" executors: with_agent: @@ -2749,7 +2767,7 @@ jobs: cd profiling cargo test --release --all-features - run: - name: phpt tests + name: phpt tests NTS command: | set -u command -v switch-php && switch-php "${PHP_VERSION}" @@ -2763,6 +2781,22 @@ jobs: cp -v "${run_tests_php}" . export TEST_PHP_EXECUTABLE=$(which php) 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" + - run: + name: phpt tests ZTS + command: | + set -u + command -v switch-php && switch-php "${PHP_VERSION}-zts" + set -e + libdir="/tmp/datadog-profiling" + cd profiling + touch build.rs #make sure `build.rs` gets executed after `switch-php` call + cargo build --release --all-features + cd tests + # don't anticipate there being more than one + run_tests_php=$(find $(php-config --prefix) -name run-tests.php) + cp -v "${run_tests_php}" . + export TEST_PHP_EXECUTABLE=$(which php) + 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" compile_extension_centos: working_directory: ~/datadog diff --git a/.github/workflows/prof_correctness.yml b/.github/workflows/prof_correctness.yml index 0275e4a436..c823ce2dd3 100644 --- a/.github/workflows/prof_correctness.yml +++ b/.github/workflows/prof_correctness.yml @@ -93,6 +93,7 @@ jobs: done - name: Check profiler correctness for allocations + if: matrix.phpts != 'zts' uses: Datadog/prof-correctness/analyze@main with: expected_json: profiling/tests/correctness/allocations.json diff --git a/profiling/src/allocation.rs b/profiling/src/allocation.rs index e7d60535d5..7adb6d9e4b 100644 --- a/profiling/src/allocation.rs +++ b/profiling/src/allocation.rs @@ -31,10 +31,6 @@ static mut PREV_CUSTOM_MM_FREE: Option = None; /// The heap installed in ZendMM at the time we install our custom handlers static mut HEAP: Option<*mut zend::_zend_mm_heap> = None; -pub fn allocation_profiling_minit() { - unsafe { zend::ddog_php_opcache_init_handle() }; -} - /// take a sample every 4096 KiB pub const ALLOCATION_PROFILING_INTERVAL: f64 = 1024.0 * 4096.0; @@ -109,6 +105,13 @@ lazy_static! { static ref JIT_ENABLED: bool = unsafe { zend::ddog_php_jit_enabled() }; } +pub fn allocation_profiling_minit() { + #[cfg(php_zts)] + return; + + unsafe { zend::ddog_php_opcache_init_handle() }; +} + pub fn first_rinit_should_disable_due_to_jit() -> bool { if NEEDS_RUN_TIME_CHECK_FOR_ENABLED_JIT && allocation_profiling_needs_disabled_for_jit(unsafe { crate::PHP_VERSION_ID }) @@ -122,6 +125,9 @@ pub fn first_rinit_should_disable_due_to_jit() -> bool { } pub fn allocation_profiling_rinit() { + #[cfg(php_zts)] + return; + let allocation_profiling: bool = REQUEST_LOCALS.with(|cell| { match cell.try_borrow() { Ok(locals) => { @@ -192,6 +198,9 @@ pub fn allocation_profiling_rinit() { } pub fn allocation_profiling_rshutdown() { + #[cfg(php_zts)] + return; + let allocation_profiling = REQUEST_LOCALS.with(|cell| { cell.try_borrow() .map(|locals| locals.system_settings().profiling_allocation_enabled) @@ -258,6 +267,9 @@ pub fn allocation_profiling_rshutdown() { } pub fn allocation_profiling_startup() { + #[cfg(php_zts)] + return; + unsafe { let handle = datadog_php_zif_handler::new( CStr::from_bytes_with_nul_unchecked(b"gc_mem_caches\0"), diff --git a/profiling/src/profiling/mod.rs b/profiling/src/profiling/mod.rs index 2015d3719d..2069d05929 100644 --- a/profiling/src/profiling/mod.rs +++ b/profiling/src/profiling/mod.rs @@ -1001,8 +1001,8 @@ impl Profiler { &self, frames: Vec, samples: SampleValues, - #[cfg(php_has_fibers)] mut labels: Vec