Skip to content

Test#3697

Draft
realFlowControl wants to merge 1 commit intomasterfrom
florian/buf-writter
Draft

Test#3697
realFlowControl wants to merge 1 commit intomasterfrom
florian/buf-writter

Conversation

@realFlowControl
Copy link
Member

Description

Reviewer checklist

  • Test coverage seems ok.
  • Appropriate labels assigned.

@datadog-official
Copy link

datadog-official bot commented Mar 10, 2026

⚠️ Tests

Fix all issues with BitsAI or with Cursor

⚠️ Warnings

🧪 1028 Tests failed

testSearchPhpBinaries from integration.DDTrace\Tests\Integration\PHPInstallerTest (Datadog) (Fix with Cursor)
DDTrace\Tests\Integration\PHPInstallerTest::testSearchPhpBinaries
Test code or tested code printed unexpected output: Searching for available php binaries, this operation might take a while.
testSimplePushAndProcess from laravel-58-test.DDTrace\Tests\Integrations\Laravel\V5_8\QueueTest (Datadog) (Fix with Cursor)
Risky Test
phpvfscomposer://tests/vendor/phpunit/phpunit/phpunit:97
testSimplePushAndProcess from laravel-8x-test.DDTrace\Tests\Integrations\Laravel\V8_x\QueueTest (Datadog) (Fix with Cursor)
DDTrace\Tests\Integrations\Laravel\V8_x\QueueTest::testSimplePushAndProcess
Test code or tested code printed unexpected output: spanLinksTraceId: 69aff5520000000097ad80d18b556913
tid: 69aff55200000000
hexProcessTraceId: 97ad80d18b556913
hexProcessSpanId: eadc4187b6141c77
processTraceId: 10929533508172212499
processSpanId: 16923473550882643063
View all

ℹ️ Info

❄️ No new flaky tests detected

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 9117900 | Docs | Datadog PR Page | Was this helpful? React with 👍/👎 or give us feedback!

@pr-commenter
Copy link

pr-commenter bot commented Mar 10, 2026

Benchmarks [ profiler ]

Benchmark execution time: 2026-03-10 10:46:23

Comparing candidate commit 9117900 in PR branch florian/buf-writter with baseline commit 41b371e in branch master.

Found 0 performance improvements and 3 performance regressions! Performance is the same for 25 metrics, 8 unstable metrics.

scenario:php-profiler-timeline-memory-control

  • 🟥 cpu_user_time [+32.604ms; +39.000ms] or [+5.379%; +6.435%]
  • 🟥 execution_time [+35.821ms; +40.481ms] or [+5.666%; +6.403%]

scenario:php-profiler-timeline-memory-with-profiler

  • 🟥 execution_time [+26.844ms; +43.476ms] or [+2.694%; +4.364%]

gh-worker-dd-mergequeue-cf854d bot pushed a commit to DataDog/libdatadog that referenced this pull request Mar 16, 2026
…sStream` (#1696)

# What does this PR do?

This PR wraps the zstd streaming encoder in `TimestampedObservations` with a `BufWriter` sized to `ZSTD_CStreamInSize()` (128 KiB). Each `add_sample` call makes several small writes (4-44 bytes) without buffering. Each one triggers a `ZSTD_compressStream` call. The `BufWriter` batches these into fewer, optimally sized calls to the compressor, reducing per-call FFI overhead. A new benchmark (`profile_add_sample_timestamped_x1000`) is included to measure the impact.      

# Motivation

Lower overhead in profiling.

I found this when checking the `dd-trace-rb` full host profiles, that for every `add_sample` call we spend quite an amount in `ZSTD_compressStream` and wondered why that is the case. A bit of searching made me land at https://github.com/facebook/zstd/blob/d7ee3207cc0db53f78fc6a69babc80747b1b7658/lib/zstd.h#L829-L843 with the TLDR being that it is adviced to call `ZSTD_compressStream*()` with the recommended buffers sizes and limit calls over FFI.

And that is what this PR does.

# Additional Notes

I added a second `Label` to the bench, making the numbers a bit more realistic, in PHP we send at least 5 labels with every sample, IDK about other consumers of libdatadog, so I guess doubling the amount of labels is most likely fine with everyone.

The PR has two commits, the first brings the benchmark, the second the code changes.

# How to test the change?

```bash
$ git checkout HEAD~1
...
$ cargo bench -p libdd-profiling -- profile_add_sample_timestamped_x1000
...
profile_add_sample_timestamped_x1000
                        time:   [747.84 µs 749.31 µs 751.03 µs]
...
$ git checkout florian/buf_writer
...
$ cargo bench -p libdd-profiling -- profile_add_sample_timestamped_x1000
...
profile_add_sample_timestamped_x1000
                        time:   [680.57 µs 681.52 µs 682.50 µs]
                        change: [-9.5874% -9.3376% -9.0913%] (p = 0.00 < 0.05)
                        Performance has improved.
```

Or with `dd-trace-php` at DataDog/dd-trace-php#3697

Co-authored-by: florian.engelhardt <florian.engelhardt@datadoghq.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant