Skip to content

Require trace IDs to increase in creation order during calibration - #885

Merged
rkennke merged 1 commit into
mainfrom
fix/trace-id-calibration-order
Oct 22, 2026
Merged

rkennke merged 1 commit into
mainfrom
fix/trace-id-calibration-order

Conversation

@rkennke

@rkennke rkennke commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

What

KlassTraceId calibration (fjmethodid=lazy, from #868) now only accepts an offset at which the fresh probe klasses' values increase strictly in creation order, with at least half the steps exactly +1. Before, it accepted any distinct values within the slack window. calibrate() also makes up to six attempts instead of four.

Why

On test-linux-glibc-aarch64 (17, debug, regular), seen on #883, calibration found two candidate offsets, refused both, and lazy mode stayed off for the whole JVM. All four lazy tests then failed. The probe dump showed (values >> 16):

Offset Values
24 f5e11aef f5e11afb f5e11ad7 f5e11b11 f5e11b13 f5e11ae3 pointers, distinct and within 60 of each other
168 4173 4174 4175 4176 4177 4178 the real trace ID

JFR hands out trace IDs from one global counter as each klass is created. The probes are created one after another (array dimensions 1 to 6 of a fresh class), so their IDs strictly increase and mostly step by exactly one; other threads creating classes meanwhile only add gaps. Pointers neither follow creation order nor step by one. Offset 24 above already goes down at its third probe.

Why not a per-version offset table

The offset isn't a function of the JDK version alone. On mainline it depends on the CDS Java heap build option, and vendor builds may add fields. A table would still need a runtime check, and couldn't cover builds it doesn't know. The stronger check is that runtime check.

Cost

The first attempt in a JVM regularly sees steps of 2 to 4. It's now rejected, and the second attempt succeeds. Observed on JDK 17, 21 and 25 on macOS; I don't know what takes those IDs. That's why the attempt budget goes from four to six, leaving the same margin for interference from other threads. An attempt costs microseconds plus a tiny probe class loader that GC can unload.

Tests

  • klassTraceId_ut:
    • RejectsPointersThatLookLikeCloseIds uses the CI values above and must pick 168;
    • RejectsIdsOutOfCreationOrder and RejectsIdsThatRarelyStepByOne;
    • ToleratesIdsTakenByOtherThreads replaces the old any-order test, which was only needed while the probes weren't stored in creation order.
  • With the old check, the three new rejection tests fail.
  • All debug gtests pass.
  • The lazy Java tests pass on JDK 25, 21 and 17 (macOS), calibrating to 192, 184 and 168.

🤖 Generated with Claude Code

KlassTraceId::findOffset() accepted any offset at which the probes held
distinct values within ID_SLACK of each other after >> 16. On aarch64 17u a
pointer field at offset 24 passed that next to the real trace ID at 168, so
calibration found two candidates, refused both, and fjmethodid=lazy stayed
off for the JVM (CI: glibc-17-debug-aarch64).

JFR assigns trace IDs from one global counter as each klass is created, and
the probes are created one after another, so their IDs strictly increase,
mostly by exactly one. plausibleIds() now requires both: values in creation
order, and at least half the steps +1. Pointers neither follow creation
order nor step by exactly one.

The first attempt in a JVM regularly sees steps of 2 to 4 and is now
rejected, so calibrate() makes up to six attempts instead of four.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@rkennke
rkennke requested a review from a team as a code owner October 22, 2026 12:54
@chatgpt-codex-connector

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 🔄 Running since 2026-10-22T12:54:36.923834Z 32476eb 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.

@datadog-official datadog-official 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.

Bits Code Review: PASS

More details

The calibration checks reject the reported pointer lookalike while accepting ordered trace IDs with limited gaps. The completed static review identified no reportable defect.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Bits Code Review · Commit 32476eb

@dd-octo-sts

dd-octo-sts Bot commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

CI Test Results

Run: #39782248041 | Commit: 6f09aea | Duration: 19m 2s (longest job)

✅ All 32 test jobs passed

Status Overview

JDK glibc-aarch64/debug glibc-amd64/debug musl-aarch64/debug musl-amd64/debug
8 - ✅ - -
8-ibm - ✅ - -
8-j9 ✅ ✅ - -
8-librca - - ✅ ✅
8-orcl - ✅ - -
11 - ✅ - -
11-j9 ✅ ✅ - -
11-librca - - ✅ ✅
17 ✅ ✅ - -
17-graal ✅ ❔ - -
17-j9 ✅ ✅ - -
17-librca - - ✅ ✅
21 ✅ ✅ - -
21-graal ✅ ✅ - -
21-librca - - ✅ ✅
25 ✅ ✅ - -
25-graal ✅ ✅ - -
25-librca - - ✅ ✅

Legend: ✅ passed | ❌ failed | ⚪ skipped | 🚫 cancelled

Summary: Total: 32 | Passed: 31 | Failed: 0


Updated: 2026-10-22 13:18:55 UTC

@dd-octo-sts

dd-octo-sts Bot commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

✅ All 40 integration tests passed

📊 Dashboard · 👷 Pipeline · 📦 32476eb6

@rkennke
rkennke merged commit 144f858 into main Oct 22, 2026
117 checks passed
@rkennke
rkennke deleted the fix/trace-id-calibration-order branch October 22, 2026 13:38
@github-actions github-actions Bot added this to the 1.52.0 milestone Oct 22, 2026
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