From 17c139855ebb51c8c9a889427d38557b79afddd4 Mon Sep 17 00:00:00 2001 From: Florian Engelhardt Date: Mon, 16 Feb 2026 16:58:45 +0100 Subject: [PATCH 1/2] test(profiling): adds correctness tests for I/O profiling --- .github/workflows/prof_correctness.yml | 10 +++- profiling/src/profiling/sample_type_filter.rs | 42 ++++++++++++++++ profiling/tests/correctness/io.json | 36 +++++++++++++ profiling/tests/correctness/io.php | 50 +++++++++++++++++++ 4 files changed, 136 insertions(+), 2 deletions(-) create mode 100644 profiling/tests/correctness/io.json create mode 100644 profiling/tests/correctness/io.php diff --git a/.github/workflows/prof_correctness.yml b/.github/workflows/prof_correctness.yml index da49c2bd496..30b6b5da719 100644 --- a/.github/workflows/prof_correctness.yml +++ b/.github/workflows/prof_correctness.yml @@ -77,7 +77,7 @@ jobs: export DD_PROFILING_EXCEPTION_MESSAGE_ENABLED=1 php -v php -d extension=target/profiler-release/libdatadog_php_profiling.so --ri datadog-profiling - for test_case in "allocations" "time" "strange_frames" "timeline" "exceptions"; do + for test_case in "allocations" "time" "strange_frames" "timeline" "exceptions" "io"; do mkdir -p profiling/tests/correctness/"$test_case"/ export DD_PROFILING_OUTPUT_PPROF=$PWD/profiling/tests/correctness/"$test_case"/test.pprof php -d extension="${PWD}/target/profiler-release/libdatadog_php_profiling.so" "profiling/tests/correctness/${test_case}.php" @@ -95,7 +95,7 @@ jobs: export DD_PROFILING_EXCEPTION_MESSAGE_ENABLED=1 php -v php -d extension=target/profiler-release/libdatadog_php_profiling.so --ri datadog-profiling - for test_case in "allocations" "time" "strange_frames" "timeline" "exceptions"; do + for test_case in "allocations" "time" "strange_frames" "timeline" "exceptions" "io"; do mkdir -p profiling/tests/correctness/"$test_case"/ export DD_PROFILING_OUTPUT_PPROF=$PWD/profiling/tests/correctness/"$test_case"/test.pprof php -d extension=$PWD/target/profiler-release/libdatadog_php_profiling.so profiling/tests/correctness/"$test_case".php @@ -188,6 +188,12 @@ jobs: expected_json: profiling/tests/correctness/allocation_time_combined.json pprof_path: profiling/tests/correctness/allocation_time_combined/ + - name: Check profiler correctness for IO + uses: Datadog/prof-correctness/analyze@main + with: + expected_json: profiling/tests/correctness/io.json + pprof_path: profiling/tests/correctness/io/ + - name: Check profiler correctness for exceptions ZTS if: matrix.phpts == 'zts' uses: Datadog/prof-correctness/analyze@main diff --git a/profiling/src/profiling/sample_type_filter.rs b/profiling/src/profiling/sample_type_filter.rs index aadecd7c620..aceb4b7e5a5 100644 --- a/profiling/src/profiling/sample_type_filter.rs +++ b/profiling/src/profiling/sample_type_filter.rs @@ -288,4 +288,46 @@ mod tests { ); assert_eq!(values, vec![10, 20, 30, 70]); } + + #[test] + fn filter_with_io_profiling() { + let mut settings = get_system_settings(); + settings.profiling_enabled = true; + settings.profiling_io_enabled = true; + + let sample_type_filter = SampleTypeFilter::new(&settings); + let values = sample_type_filter.filter(get_samples()); + let types = sample_type_filter.sample_types(); + + assert_eq!( + types, + vec![ + ValueType::new("sample", "count"), + ValueType::new("wall-time", "nanoseconds"), + ValueType::new("socket-read-time", "nanoseconds"), + ValueType::new("socket-read-time-samples", "count"), + ValueType::new("socket-write-time", "nanoseconds"), + ValueType::new("socket-write-time-samples", "count"), + ValueType::new("file-io-read-time", "nanoseconds"), + ValueType::new("file-io-read-time-samples", "count"), + ValueType::new("file-io-write-time", "nanoseconds"), + ValueType::new("file-io-write-time-samples", "count"), + ValueType::new("socket-read-size", "bytes"), + ValueType::new("socket-read-size-samples", "count"), + ValueType::new("socket-write-size", "bytes"), + ValueType::new("socket-write-size-samples", "count"), + ValueType::new("file-io-read-size", "bytes"), + ValueType::new("file-io-read-size-samples", "count"), + ValueType::new("file-io-write-size", "bytes"), + ValueType::new("file-io-write-size-samples", "count"), + ] + ); + assert_eq!( + values, + vec![ + 10, 20, 80, 81, 90, 91, 100, 101, 110, 111, 120, 121, 130, + 131, 140, 141, 150, 151 + ] + ); + } } diff --git a/profiling/tests/correctness/io.json b/profiling/tests/correctness/io.json new file mode 100644 index 00000000000..d3a1deac82e --- /dev/null +++ b/profiling/tests/correctness/io.json @@ -0,0 +1,36 @@ +{ + "scale_by_duration": true, + "test_name": "php_io", + "stacks": [ + { + "profile-type": "file-io-write-size", + "stack-content": [ + { + "regular_expression": " Date: Wed, 18 Feb 2026 16:47:43 +0100 Subject: [PATCH 2/2] tighten error for io samples --- profiling/tests/correctness/io.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/profiling/tests/correctness/io.json b/profiling/tests/correctness/io.json index d3a1deac82e..1cc4b379a49 100644 --- a/profiling/tests/correctness/io.json +++ b/profiling/tests/correctness/io.json @@ -8,12 +8,12 @@ { "regular_expression": "