Skip to content

Let carriers hand parse-only header values as transient views - #13618

Draft
dougqh wants to merge 2 commits into
dougqh/header-schemafrom
dougqh/transient-values
Draft

dougqh wants to merge 2 commits into
dougqh/header-schemafrom
dougqh/transient-values

Conversation

@dougqh

@dougqh dougqh commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

What Does This Do

Adds the propagation contract for parsing header values in place: a carrier may hand a parse-only header's value as a transient view, valid only during the extraction, instead of decoding it into a String. No carrier produces views yet, so nothing changes at runtime.

Stacked on #13613. Part 3 of the value-views series (#13616, #13617).

Motivation

The header value Strings are the largest tracer allocation site in a Kafka consumer profile. Three of them (x-datadog-trace-id, x-datadog-parent-id, x-datadog-sampling-priority) are parsed into numbers and never kept, so a byte carrier could hand them as views (#13617) and the Datadog extractor parse them in place (#13616's parsers). This PR is the contract between the two, kept separate so it can be reviewed on its own.

Additional Notes

  • HeaderSchema.isParseOnly(): true for those three headers. A propagator that starts keeping such a value must copy it, or the flag must change; the Javadoc says so.
  • TransientValueConsumer (components/context): acceptTransient(header, key, CharSequence value), how a carrier hands a parse-only value as a view valid only during the call. A carrier may use it only if the visitor implements it.
  • The composite propagator's cache implements it: it keeps the view for the extraction (the cache lives exactly that long), in the same pairs array as String values (an Object[], so a view costs no extra allocation), and copies it once if anything reads it as a String (value(i) and forEachKeyValue always return Strings).
  • IndexedCarrier.valueView(i): the value, possibly a view; defaults to value(i).
  • KeyClassifier.acceptTransient(header, key, value) (internal-api): the default copies the view and calls accept(header, key, value), so every existing classifier sees Strings as before. Extraction (HttpCodec.acceptIndexed, used by ExtractionCache and the single-extractor path) hands views to acceptTransient and Strings to accept.
  • Retention: views are @NoEscape (see AsciiSequence, Add AsciiSequence, a CharSequence view of ASCII bytes #13617). Nothing in this PR keeps one past the extraction; the classifiers that will parse them (part 4) parse or copy within the call.
  • Tests: CarrierCacheTest (views kept as given, copied once and the copy kept, constants from the caller, growth, Strings from forEachKeyValue, null values); HeaderSchemaTest (exactly those three are parse-only); ExtractorKeysForkedTest's carrier now hands parse-only values as non-String views, so its per-style and compound equivalence checks cover the transient path (through the default copy, until part 4).

🤖 Generated with Claude Code

@dougqh dougqh added comp: core Tracer core tag: performance Performance related changes tag: no release notes Changes to exclude from release notes type: refactoring tag: ai generated Largely based on code generated by an AI or LLM labels Nov 21, 2026
@datadog-official

datadog-official Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

🎯 Code Coverage (details)
• Patch Coverage: 90.00%
• Overall Coverage: 59.61% (+0.01%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 14e69c0 | Docs | Give us feedback!

@dd-octo-sts

dd-octo-sts Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

🟢 Java Benchmark SLOs — All performance SLOs passed

Suite Status
Startup 🟢 pass

SLO thresholds are defined here based on automatically generated metrics. A warning is raised when results are within 5% of the threshold.

PR vs. master results
Scenario Candidate master Δ (95% CI of mean)
startup:insecure-bank:iast:Agent 14.05 s 13.96 s [+0.0%; +1.4%] (maybe worse)
startup:insecure-bank:tracing:Agent 12.98 s 13.03 s [-1.0%; +0.2%] (no difference)
startup:petclinic:appsec:Agent 17.26 s 17.19 s [-0.4%; +1.3%] (no difference)
startup:petclinic:iast:Agent 17.17 s 17.21 s [-1.1%; +0.5%] (no difference)
startup:petclinic:profiling:Agent 16.95 s 16.99 s [-1.4%; +1.0%] (no difference)
startup:petclinic:sca:Agent 17.33 s 17.05 s [+0.8%; +2.5%] (maybe worse)
startup:petclinic:tracing:Agent 16.32 s 16.42 s [-1.6%; +0.4%] (no difference)

Commit: 14e69c05 · CI Pipeline · Benchmarking Platform UI


Load and DaCapo benchmarks can be triggered manually in the GitLab pipeline. Results will appear in the Benchmarking Platform UI after completion.

@pr-commenter

pr-commenter Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

Kafka / producer-benchmark

Parameters

Baseline Candidate
baseline_or_candidate baseline candidate
git_branch dougqh/header-schema dougqh/transient-values
git_commit_date 1795289464 1795289482
git_commit_sha 93a92d8 14e69c0
See matching parameters
Baseline Candidate
ci_job_date 1795290875 1795290875
ci_job_id 2286653464 2286653464
ci_pipeline_id 155480155 155480155
cpu_model Intel(R) Xeon(R) Platinum 8175M CPU @ 2.50GHz Intel(R) Xeon(R) Platinum 8175M CPU @ 2.50GHz
jdkVersion 11.0.31 11.0.31
jmhVersion 1.36 1.36
jvm /usr/lib/jvm/java-11-openjdk-amd64/bin/java /usr/lib/jvm/java-11-openjdk-amd64/bin/java
jvmArgs -Dhttp.proxyHost=127.0.0.1 -Dhttp.proxyPort=15002 -Dhttps.proxyHost=127.0.0.1 -Dhttps.proxyPort=15002 -Dhttp.nonProxyHosts=localhost *.localhost
kernel_version Linux runner-zfyrx7zua-project-304-concurrent-0-1lz3ys5j 6.8.0-1031-aws #33~22.04.1-Ubuntu SMP Thu Jun 26 14:22:30 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux Linux runner-zfyrx7zua-project-304-concurrent-0-1lz3ys5j 6.8.0-1031-aws #33~22.04.1-Ubuntu SMP Thu Jun 26 14:22:30 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux
vmName OpenJDK 64-Bit Server VM OpenJDK 64-Bit Server VM
vmVersion 11.0.31+11-post-1ubuntu1-22.04.2-Ubuntu 11.0.31+11-post-1ubuntu1-22.04.2-Ubuntu

Summary

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

See unchanged results
scenario Δ mean throughput
scenario:not-instrumented/KafkaProduceBenchmark.benchProduce same
scenario:only-tracing-dsm-disabled-benchmarks/KafkaProduceBenchmark.benchProduce same
scenario:only-tracing-dsm-enabled-benchmarks/KafkaProduceBenchmark.benchProduce same

@pr-commenter

pr-commenter Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

Kafka / consumer-benchmark

Parameters

Baseline Candidate
baseline_or_candidate baseline candidate
git_branch dougqh/header-schema dougqh/transient-values
git_commit_date 1795289464 1795289482
git_commit_sha 93a92d8 14e69c0
See matching parameters
Baseline Candidate
ci_job_date 1795291019 1795291019
ci_job_id 2286653469 2286653469
ci_pipeline_id 155480155 155480155
cpu_model Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz
jdkVersion 11.0.31 11.0.31
jmhVersion 1.36 1.36
jvm /usr/lib/jvm/java-11-openjdk-amd64/bin/java /usr/lib/jvm/java-11-openjdk-amd64/bin/java
jvmArgs -Dhttp.proxyHost=127.0.0.1 -Dhttp.proxyPort=15002 -Dhttps.proxyHost=127.0.0.1 -Dhttps.proxyPort=15002 -Dhttp.nonProxyHosts=localhost *.localhost
kernel_version Linux runner-zfyrx7zua-project-304-concurrent-0-2i9m2gew 6.8.0-1031-aws #33~22.04.1-Ubuntu SMP Thu Jun 26 14:22:30 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux Linux runner-zfyrx7zua-project-304-concurrent-0-2i9m2gew 6.8.0-1031-aws #33~22.04.1-Ubuntu SMP Thu Jun 26 14:22:30 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux
vmName OpenJDK 64-Bit Server VM OpenJDK 64-Bit Server VM
vmVersion 11.0.31+11-post-1ubuntu1-22.04.2-Ubuntu 11.0.31+11-post-1ubuntu1-22.04.2-Ubuntu

Summary

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

See unchanged results
scenario Δ mean throughput
scenario:not-instrumented/KafkaConsumerBenchmark.benchConsume same
scenario:only-tracing-dsm-disabled-benchmarks/KafkaConsumerBenchmark.benchConsume same
scenario:only-tracing-dsm-enabled-benchmarks/KafkaConsumerBenchmark.benchConsume same

dougqh and others added 2 commits November 21, 2026 14:31
The propagation contract for parsing header values in place, with no
producer yet, so nothing changes at runtime:

- HeaderSchema.isParseOnly(): the Datadog trace id, parent id and sampling
  priority headers, whose readers only parse their values.
- TransientValueConsumer: how a carrier hands such a value as a view valid
  only during the call. The composite propagator's cache implements it,
  keeps the view for the extraction (allocating its view slots only when
  one arrives), and copies it once if something reads it as a String.
- IndexedCarrier.valueView(i), and KeyClassifier.acceptTransient(header,
  key, value), whose default copies the view and calls accept. Extraction
  hands views to acceptTransient and Strings to accept.

ExtractorKeysForkedTest's carrier now hands parse-only values as views, so
its per-style and compound equivalence checks cover this path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The cache allocated a separate CharSequence[] the first time a view
arrived, which on Kafka is every extraction (about 48 bytes). Values are
now Objects in the one pairs array, a String or a view until read as a
String.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dougqh
dougqh force-pushed the dougqh/header-schema branch from d5708a4 to 93a92d8 Compare November 21, 2026 19:39
@dougqh
dougqh force-pushed the dougqh/transient-values branch from 42b4292 to 14e69c0 Compare November 21, 2026 19:39

This branch has not been deployed

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

Labels

comp: core Tracer core tag: ai generated Largely based on code generated by an AI or LLM tag: no release notes Changes to exclude from release notes tag: performance Performance related changes type: refactoring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant