Skip to content

perf(serialization): bench the actual path used by the trace exporter - #2512

Open
paullegranddc wants to merge 1 commit into
mainfrom
paullgdc/serialization/improve_msgpack_perf
Open

perf(serialization): bench the actual path used by the trace exporter#2512
paullegranddc wants to merge 1 commit into
mainfrom
paullgdc/serialization/improve_msgpack_perf

Conversation

@paullegranddc

Copy link
Copy Markdown
Collaborator

What does this PR do?

The existing serialization benchmarks use write_to_slice_from_v04 which goes through the blanket impl of RmpWrite for io::Write.
The trace exporter uses to_vec_with_capacity_from_v04 which through a more specialized dispatch, which is more efficient, and gives different perf characteristics when trying to optimize the rmp crate.

This PR adds a benchmarks exercising the function used in the trace exporter for more realistic numbers

Motivation

What inspired you to submit this pull request?

Additional Notes

Anything else we should know when reviewing?

How to test the change?

Describe here in detail how the change can be validated.

@paullegranddc
paullegranddc requested review from a team as code owners September 11, 2026 12:51
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 11, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-11T12:57:03.956437Z aa65200 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

Copy link
Copy Markdown
Contributor

📚 Documentation Check Results

⚠️ 775 documentation warning(s) found

📦 libdd-trace-utils - 775 warning(s)


Updated: 2026-09-11 12:53:24 UTC | Commit: 32a7b66 | missing-docs job results

@github-actions

Copy link
Copy Markdown
Contributor

🔒 Cargo Deny Results

No issues found!

📦 libdd-trace-utils - ✅ No issues


Updated: 2026-09-11 12:55:20 UTC | Commit: 32a7b66 | dependency-check job results

@datadog-official

datadog-official Bot commented Sep 11, 2026

Copy link
Copy Markdown

Pipelines  Tests

⚠️ Warnings

Your PR has failed checks. Please review the issues below and take necessary action before merging.

🚦 2 Pipeline jobs failed

Lint | rustfmt — 🔧 Needs a code fix, caused by this PR

View more details · View in GitHub Actions

Required checks pass | allchecks

View more details · View in GitHub Actions

ℹ️ Info

No other issues found (see more)

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 77.75% (-0.03%)

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: aa65200 | Docs | View more details | Give us feedback!

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: aa652005bd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

|| vec![0u8; 12_000_000],
|| {},
|()| msgpack_encoder::v04::to_vec_with_capacity_from_v04(&data, 1_000_000),
criterion::BatchSize::SmallInput,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Use a batch size suitable for the large returned vectors

When Criterion performs warm-up or samples with many iterations, SmallInput retains the outputs from roughly one-tenth of those iterations until the batch completes. Every output here has at least 1,000,000 bytes of capacity, so a single batch can retain hundreds of megabytes or more, potentially causing memory pressure or OOMs that invalidate the benchmark. Use LargeInput or PerIteration for this large returned value.

Useful? React with 👍 / 👎.

// Generate roughly 10mb of data. This is the upper bound of payload size before a tracer
// flushes
let data = rmp_serde::to_vec(&generate_trace_chunks(20, 2_075))
let data = rmp_serde::to_vec(&generate_trace_chunks(100, 20))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve the advertised upper-bound payload size

The benchmark still says it generates roughly 10 MB, but this change reduces the payload from 41,500 spans (20 * 2,075) to only 2,000 (100 * 20). Because each span has the same fixed fields, the resulting payload is approximately one-twentieth of the previous size, so both benchmarks stop exercising the documented upper-bound flush workload and their results are no longer comparable to the prior benchmark. Retain enough spans to approach 10 MB, or explicitly redefine the benchmark and its description if the smaller workload is intentional.

Useful? React with 👍 / 👎.

@dd-octo-sts

dd-octo-sts Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Artifact Size Benchmark Report

aarch64-alpine-linux-musl
Artifact Baseline Commit Change
/aarch64-alpine-linux-musl/lib/libdatadog_profiling.so 9.02 MB 9.02 MB 0% (0 B) 👌
/aarch64-alpine-linux-musl/lib/libdatadog_profiling.a 95.91 MB 95.91 MB 0% (0 B) 👌
aarch64-unknown-linux-gnu
Artifact Baseline Commit Change
/aarch64-unknown-linux-gnu/lib/libdatadog_profiling.a 107.26 MB 107.26 MB 0% (0 B) 👌
/aarch64-unknown-linux-gnu/lib/libdatadog_profiling.so 12.18 MB 12.18 MB 0% (0 B) 👌
libdatadog-x64-windows
Artifact Baseline Commit Change
libdatadog-x86-windows
Artifact Baseline Commit Change
x86_64-alpine-linux-musl
Artifact Baseline Commit Change
/x86_64-alpine-linux-musl/lib/libdatadog_profiling.a 85.88 MB 85.88 MB 0% (0 B) 👌
/x86_64-alpine-linux-musl/lib/libdatadog_profiling.so 10.02 MB 10.02 MB 0% (0 B) 👌
x86_64-unknown-linux-gnu
Artifact Baseline Commit Change
/x86_64-unknown-linux-gnu/lib/libdatadog_profiling.a 101.82 MB 101.82 MB 0% (0 B) 👌
/x86_64-unknown-linux-gnu/lib/libdatadog_profiling.so 12.25 MB 12.25 MB 0% (0 B) 👌

@pr-commenter

pr-commenter Bot commented Sep 11, 2026

Copy link
Copy Markdown

Benchmarks

Comparison

Benchmark execution time: 2026-09-11 13:14:49

Comparing candidate commit aa65200 in PR branch paullgdc/serialization/improve_msgpack_perf with baseline commit 132842f in branch ``.

📊 Benchmarking dashboard

Found 10 performance improvements and 10 performance regressions! Performance is the same for 107 metrics, 0 unstable metrics.

Explanation

This is an A/B test comparing a candidate commit's performance against that of a baseline commit. Performance changes are noted in the tables below as:

  • 🟩 = significantly better candidate vs. baseline
  • 🟥 = significantly worse candidate vs. baseline

We compute a confidence interval (CI) over the relative difference of means between metrics from the candidate and baseline commits, considering the baseline as the reference.

If the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD), the change is considered significant.

Feel free to reach out to #apm-benchmarking-platform on Slack if you have any questions.

More details about the CI and significant changes

You can imagine this CI as a range of values that is likely to contain the true difference of means between the candidate and baseline commits.

CIs of the difference of means are often centered around 0%, because often changes are not that big:

---------------------------------(------|---^--------)-------------------------------->
                              -0.6%    0%  0.3%     +1.2%
                                 |          |        |
         lower bound of the CI --'          |        |
sample mean (center of the CI) -------------'        |
         upper bound of the CI ----------------------'

As described above, a change is considered significant if the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD).

For instance, for an execution time metric, this confidence interval indicates a significantly worse performance:

----------------------------------------|---------|---(---------^---------)---------->
                                       0%        1%  1.3%      2.2%      3.1%
                                                  |   |         |         |
       significant impact threshold --------------'   |         |         |
                      lower bound of CI --------------'         |         |
       sample mean (center of the CI) --------------------------'         |
                      upper bound of CI ----------------------------------'

scenario:agentless_encoding/common_http/20x5

  • 🟥 execution_time [+43.535µs; +43.593µs] or [+42.277%; +42.333%]
  • 🟥 throughput [-288926.171op/s; -288465.392op/s] or [-29.752%; -29.705%]

scenario:agentless_encoding/http_with_span_links/20x5

  • 🟥 execution_time [+45.935µs; +45.998µs] or [+39.273%; +39.326%]
  • 🟥 throughput [-241371.673op/s; -241038.409op/s] or [-28.232%; -28.193%]

scenario:otlp/e2e_json/1x1000

  • 🟩 execution_time [-237.376µs; -235.556µs] or [-5.449%; -5.407%]

scenario:otlp/encode_json/1x1000

  • 🟩 execution_time [-345.709µs; -345.049µs] or [-17.277%; -17.244%]

scenario:otlp/encode_protobuf/1x1000

  • 🟥 execution_time [+46.901µs; +47.774µs] or [+4.492%; +4.576%]

scenario:vec_map/as_deduped_map/already_deduped/16

  • 🟥 execution_time [+0.962ns; +0.994ns] or [+4.084%; +4.218%]

scenario:vec_map/as_deduped_map/already_deduped/8

  • 🟥 execution_time [+0.955ns; +0.964ns] or [+6.876%; +6.942%]

scenario:vec_map/as_deduped_map/needs_dedup_1_in_10/8

  • 🟥 execution_time [+15.826ns; +16.018ns] or [+4.457%; +4.511%]

scenario:vec_map/as_deduped_map/needs_dedup_1_in_2/8

  • 🟥 execution_time [+22.342ns; +22.571ns] or [+4.830%; +4.879%]

scenario:vec_map/as_deduped_map/needs_dedup_1_in_4/8

  • 🟥 execution_time [+21.415ns; +21.674ns] or [+5.446%; +5.512%]

scenario:vec_map/get_hit/128

  • 🟩 execution_time [-1.407µs; -1.397µs] or [-10.251%; -10.177%]
  • 🟩 throughput [+1056951.050op/s; +1064394.463op/s] or [+11.336%; +11.415%]

scenario:vec_map/get_hit/16

  • 🟩 execution_time [-21.353ns; -21.116ns] or [-9.115%; -9.014%]
  • 🟩 throughput [+6770002.727op/s; +6848954.204op/s] or [+9.911%; +10.027%]

scenario:vec_map/get_hit/64

  • 🟩 execution_time [-317.680ns; -309.771ns] or [-8.532%; -8.319%]
  • 🟩 throughput [+1561544.605op/s; +1601657.917op/s] or [+9.085%; +9.318%]

scenario:vec_map/get_hit/8

  • 🟩 execution_time [-3.601ns; -3.437ns] or [-5.553%; -5.301%]
  • 🟩 throughput [+6917906.518op/s; +7259401.393op/s] or [+5.608%; +5.884%]

Benchmark execution time: 2026-09-11 13:14:57

Comparing candidate commit aa65200 in PR branch paullgdc/serialization/improve_msgpack_perf with baseline commit 132842f in branch main.

📊 Benchmarking dashboard

Found 3 performance improvements and 19 performance regressions! Performance is the same for 86 metrics, 10 unstable metrics.

Explanation

This is an A/B test comparing a candidate commit's performance against that of a baseline commit. Performance changes are noted in the tables below as:

  • 🟩 = significantly better candidate vs. baseline
  • 🟥 = significantly worse candidate vs. baseline

We compute a confidence interval (CI) over the relative difference of means between metrics from the candidate and baseline commits, considering the baseline as the reference.

If the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD), the change is considered significant.

Feel free to reach out to #apm-benchmarking-platform on Slack if you have any questions.

More details about the CI and significant changes

You can imagine this CI as a range of values that is likely to contain the true difference of means between the candidate and baseline commits.

CIs of the difference of means are often centered around 0%, because often changes are not that big:

---------------------------------(------|---^--------)-------------------------------->
                              -0.6%    0%  0.3%     +1.2%
                                 |          |        |
         lower bound of the CI --'          |        |
sample mean (center of the CI) -------------'        |
         upper bound of the CI ----------------------'

As described above, a change is considered significant if the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD).

For instance, for an execution time metric, this confidence interval indicates a significantly worse performance:

----------------------------------------|---------|---(---------^---------)---------->
                                       0%        1%  1.3%      2.2%      3.1%
                                                  |   |         |         |
       significant impact threshold --------------'   |         |         |
                      lower bound of CI --------------'         |         |
       sample mean (center of the CI) --------------------------'         |
                      upper bound of CI ----------------------------------'

scenario:credit_card/is_card_number/ 3782-8224-6310-005

  • 🟥 execution_time [+5.833µs; +5.982µs] or [+7.803%; +8.003%]
  • 🟥 throughput [-992979.115op/s; -967459.415op/s] or [-7.423%; -7.232%]

scenario:credit_card/is_card_number/ 378282246310005

  • 🟥 execution_time [+5.512µs; +5.577µs] or [+8.099%; +8.194%]
  • 🟥 throughput [-1112722.628op/s; -1100530.335op/s] or [-7.573%; -7.490%]

scenario:credit_card/is_card_number/378282246310005

  • 🟥 execution_time [+5.569µs; +5.632µs] or [+8.589%; +8.687%]
  • 🟥 throughput [-1232785.043op/s; -1219833.497op/s] or [-7.993%; -7.909%]

scenario:credit_card/is_card_number/37828224631000521389798

  • 🟥 execution_time [+8.156µs; +8.195µs] or [+18.112%; +18.199%]
  • 🟥 throughput [-3421456.477op/s; -3403464.620op/s] or [-15.407%; -15.326%]

scenario:credit_card/is_card_number/x371413321323331

  • 🟥 execution_time [+399.357ns; +401.925ns] or [+6.601%; +6.643%]
  • 🟥 throughput [-10298158.497op/s; -10232451.573op/s] or [-6.231%; -6.191%]

scenario:credit_card/is_card_number_no_luhn/ 378282246310005

  • 🟥 execution_time [+4.852µs; +4.882µs] or [+9.063%; +9.118%]
  • 🟥 throughput [-1560836.249op/s; -1551730.961op/s] or [-8.357%; -8.308%]

scenario:credit_card/is_card_number_no_luhn/378282246310005

  • 🟥 execution_time [+5.025µs; +5.068µs] or [+9.984%; +10.071%]
  • 🟥 throughput [-1818065.262op/s; -1803457.955op/s] or [-9.150%; -9.076%]

scenario:credit_card/is_card_number_no_luhn/37828224631000521389798

  • 🟥 execution_time [+8.187µs; +8.223µs] or [+18.179%; +18.259%]
  • 🟥 throughput [-3430765.112op/s; -3413733.094op/s] or [-15.450%; -15.374%]

scenario:credit_card/is_card_number_no_luhn/x371413321323331

  • 🟥 execution_time [+398.383ns; +400.714ns] or [+6.584%; +6.623%]
  • 🟥 throughput [-10267075.557op/s; -10207282.499op/s] or [-6.212%; -6.176%]

scenario:sql/obfuscate_sql_string

  • 🟥 execution_time [+18.423µs; +18.656µs] or [+6.328%; +6.408%]

scenario:tags/replace_trace_tags

  • 🟩 execution_time [-119.648ns; -112.008ns] or [-4.438%; -4.154%]

scenario:trace_buffer/2_senders/no_delay

  • 🟩 execution_time [-133.357µs; -118.790µs] or [-7.847%; -6.990%]
  • 🟩 throughput [+79740.628op/s; +89354.895op/s] or [+7.524%; +8.431%]

Unstable benchmarks

These benchmarks have a confidence interval too wide to call a change; treat them as noise rather than signal.

scenario:datadog_sample_span/parent_not_sampled_short_circuit/allocated_bytes

  • unstable execution_time [-0.000ns; +0.000ns] or [+543.409%; -549.973%]

scenario:datadog_sample_span/parent_sampled_short_circuit/allocated_bytes

  • unstable execution_time [-0.000ns; +0.000ns] or [+554.577%; -555.190%]

scenario:glob_matcher/ascii_case_insensitive_match/allocated_bytes

  • unstable execution_time [-0.000ns; +0.000ns] or [+555.735%; -555.735%]

scenario:glob_matcher/ascii_exact_match/allocated_bytes

  • unstable execution_time [-0.000ns; +0.000ns] or [+554.543%; -555.174%]

scenario:glob_matcher/ascii_exact_miss/allocated_bytes

  • unstable execution_time [-0.000ns; +0.000ns] or [+538.434%; -547.671%]

scenario:glob_matcher/ascii_wildcard_backtrack_match/allocated_bytes

  • unstable execution_time [-0.000ns; +0.000ns] or [+554.967%; -555.373%]

scenario:glob_matcher/ascii_wildcard_heavy_backtrack/allocated_bytes

  • unstable execution_time [-0.000ns; +0.000ns] or [+558.308%; -556.948%]

scenario:glob_matcher/ascii_wildcard_question_match/allocated_bytes

  • unstable execution_time [-0.000ns; +0.000ns] or [+554.194%; -555.010%]

scenario:glob_matcher/ascii_wildcard_star_match/allocated_bytes

  • unstable execution_time [-0.000ns; +0.000ns] or [+555.735%; -555.735%]

scenario:glob_matcher/star_short_circuit/allocated_bytes

  • unstable execution_time [-0.000ns; +0.000ns] or [+555.903%; -555.814%]

Candidate

Omitted due to size.

Baseline

Omitted due to size.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant