Skip to content

Widen @NoEscape to method returns (AI perf review) (quick fix) - #12515

Open
dougqh wants to merge 1 commit into
masterfrom
feat/no-escape-method-target
Open

dougqh wants to merge 1 commit into
masterfrom
feat/no-escape-method-target

Conversation

@dougqh

@dougqh dougqh commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

What Does This Do

Widens datadog.trace.api.function.NoEscape (added in #12368) from @Target(TYPE) to @Target({TYPE, METHOD}), and extends its Javadoc "Checker contract" with a matching method-form trigger.

Motivation

The type form only works when the returned value's concrete type can itself carry the annotation (e.g. SubSequence, Maybe). It can't when the return type is a lambda or anonymous instance of a JDK interface — Iterable, Iterator, Runnable, etc — which we can't annotate. That's exactly the shape of ConcurrentHashtable.hashIterable/hashIterator (in a companion branch), which return () -> hashIterator(...)-style lambdas that should never be retained past the scan that consumes them.

The two forms compose: annotate the type when you can, fall back to the method when you can't.

Additional Notes

  • No behavior change — @NoEscape stays CLASS-retention, no runtime semantics.
  • No new wearers of the method form in this PR; it's a prerequisite for a follow-up applying it to ConcurrentHashtable.hashIterable/hashIterator.
  • Also updated the perf-review skill's checks.md entry to describe both trigger shapes.

Contributor Checklist

  • Format the title according to the contribution guidelines
  • Assign the type: and comp: labels in addition to any other useful labels
  • Avoid using close/fix/linking keywords when referencing an issue
  • Update the CODEOWNERS file on source file addition, migration, or deletion (n/a — no new module/ownership boundary)
  • Update public documentation with any new configuration flags or behaviors (n/a — internal-only marker annotation)
  • Once approved, use merge queue to merge the PR

🤖 Generated with Claude Code

The type form only works when the returned value's concrete type can
carry the annotation. It can't for a lambda/anonymous instance of a
JDK interface (Iterable, Iterator, ...), which is exactly the shape
ConcurrentHashtable's hashIterable/hashIterator return. Add METHOD to
@target so the constraint can be documented on the factory method
itself, and extend the checker contract (and its perf-review checks.md
entry) with the matching field-initialized-from-call trigger shape.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@dougqh dougqh added tag: ai generated Largely based on code generated by an AI or LLM tag: no release notes Changes to exclude from release notes labels Sep 15, 2026
@dougqh
dougqh marked this pull request as ready for review September 15, 2026 20:31
@dougqh
dougqh requested a review from a team as a code owner September 15, 2026 20:31
@dougqh
dougqh requested review from amarziali and removed request for a team September 15, 2026 20:31
@dougqh dougqh changed the title Widen @NoEscape to method returns Widen @NoEscape to method returns (AI perf review) (quick fix) Sep 15, 2026

@datadog-prod-us1-3 datadog-prod-us1-3 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.

Datadog Autotest: PASS

More details

The method target matches the documented checker contract. CLASS retention keeps the change outside runtime behavior.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Datadog Autotest · Commit 6543b2f · What is Autotest? · @DataDog review to ask questions · Any feedback? Reach out in #autotest

@datadog-prod-us1-3

This comment has been minimized.

@dd-octo-sts

dd-octo-sts Bot commented Sep 15, 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.83 s 14.73 s [-0.3%; +1.6%] (no difference)
startup:insecure-bank:tracing:Agent 13.65 s 13.72 s [-1.2%; +0.3%] (no difference)
startup:petclinic:appsec:Agent 17.09 s 17.55 s [-6.9%; +1.8%] (no difference)
startup:petclinic:iast:Agent 17.49 s 17.61 s [-1.6%; +0.2%] (no difference)
startup:petclinic:profiling:Agent 17.38 s 17.31 s [-0.8%; +1.5%] (no difference)
startup:petclinic:sca:Agent 17.57 s 17.37 s [+0.1%; +2.1%] (maybe worse)
startup:petclinic:tracing:Agent 16.49 s 16.64 s [-1.9%; +0.1%] (no difference)

Commit: 6543b2f7 · 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.

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

Labels

tag: ai generated Largely based on code generated by an AI or LLM tag: no release notes Changes to exclude from release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants