Draft
Conversation
|
✨ Fix all issues with BitsAI or with Cursor
|
Benchmarks [ profiler ]Benchmark execution time: 2026-03-10 10:46:23 Comparing candidate commit 9117900 in PR branch Found 0 performance improvements and 3 performance regressions! Performance is the same for 25 metrics, 8 unstable metrics. scenario:php-profiler-timeline-memory-control
scenario:php-profiler-timeline-memory-with-profiler
|
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Reviewer checklist