Repository navigation
Add a Cursor toolbox type and walk FlatHashtable buckets with it - #13451
Conversation
A cursor's next() advances and returns the next element, or null when done, so a traversal needs no look-ahead: an Iterator's implementation has to compute the next element in hasNext() and hold it until next(). FlatHashtable gets cursor() overloads beside iterator(). Both share one traversal core; the look-ahead lives only in the iterator subclasses. Wrapping a cursor in an iterator was tried first: C2 didn't scalar-replace the pair, so each walk allocated 40 bytes. IdStore.Cursor now extends the toolbox type. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@codex review |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Another round soon, please! Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
🟢 Java Benchmark SLOs — All performance SLOs passed
PR vs. master results
Commit: Load and DaCapo benchmarks can be triggered manually in the GitLab pipeline. Results will appear in the Benchmarking Platform UI after completion. |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Hashtable.cursor(buckets), D1.cursor() and D2.cursor() walk every entry as a Cursor: the external form of forEach. The D1 and D2 benchmarks get an iterate_hashtable_cursor arm beside forEach and HashMap. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
More details
The cursor’s runtime behavior and reported allocation and throughput results remain unverified; this assessment is based on static inspection of the cursor and iterator changes.
🤖 Bits Code Review · Commit b7cea4d
AlexeyKuznetsov-DD
left a comment
There was a problem hiding this comment.
LGTM, Codex found couple of very minor issues.
… cursor tests Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
LLM ValidationLLM Validation Gate — java-agent-instructions✅ PASS
6 case(s) · quality 80.9 → 81.7 (+0.8) · win-rate 51% [49%–54%] Details — analysis and per-case resultsAnalysisChanged instruction file(s): No safety or blocking-case regressions across 6 case(s). Overall pairwise win-rate 51% [49%–54%], quality +0.8 — see the verdict above for whether that clears the noise band. Results
Cases
Per-dimension scores, token usage, latency, and estimated cost are in the CI job logs. |
|
/merge |
|
View all feedbacks in Devflow UI.
It will be processed automatically as soon as GitHub reports it as mergeable. View in MergeQueue UI.
The expected merge time in
|
What Does This Do
Adds
datadog.trace.util.Cursor<T>, a toolbox traversal type:next()advances and returns the next element, ornullwhen there are none left.FlatHashtable.cursor(...): general andEntry-specialized overloads beside the existingiterator(...)ones. The cursors and the iterators share one traversal core (HashTraversal). The look-aheadhasNext()needs lives only in the iterator subclasses, so the cursors carry none and need no priming.Hashtable.cursor(buckets),D1.cursor(),D2.cursor(): a whole-table cursor, the external form offorEach, with aniterate_hashtable_cursorvariant inHashtableD1BenchmarkandHashtableD2Benchmark.IdStore.Cursornow extends the toolbox type; its shape was already the same. The nested name is kept, so the dense store's cursor (Add a dense known-tag store behind an experimental flag (dense store - part 8) #13004) needs no change.cursor_generalandcursor_specializedvariants inFlatHashtableIteratorBenchmark.Cursorto a hand-writtenIteratorfor new traversals.Motivation
An
Iteratorhas to compute the next element inhasNext()and hold it untilnext(), so its implementations carry a look-ahead field, an end flag, and priming in the constructor (seeFlatHashtable's old iterator, which deferred priming to the subclass constructors). A cursor keeps only its position, so it is easier to write, and it is at least as fast as the iterator it replaces. AgainstforEachit trades some speed for ease of use: the loop is the caller's, so results can be carried out of it in locals, it can stop early, and two sources can be walked together. This is the first step toward cursor-based iteration forTagMap, replacingIterable<EntryReader>.Results
FlatHashtableIteratorBenchmark, MacBook M1, Zulu 17, 3 forks, poisonedhashOfprofile,-prof gc. The master column is master's iterator on the same machine.All variants are allocation-free.
HashtableD1Benchmark/HashtableD2Benchmarkiteration, same machine, 8 threads, 3 forks, 2 s iterations:forEachentrySet()forEachstays the fastest full walk, 5–12% ahead of the cursor: the whole walk runs inside the table as one nested loop. The cursor is the replacement forIterator, not forforEach;Cursor's Javadoc says when to use which.Additional Notes
nextWithandhashOfincluded) but didn't scalar-replace the cursor, a second object whose fields change in the caller's loop. Typing the adapter's field as the concrete cursor class didn't help. Sharing the traversal by inheritance keeps each walk to one object.Cursor's Javadoc records this: share a base class on hot paths; a wrapper is fine elsewhere.Cursoris not@Confined: an adapter or wrapper has to keep its cursor in a field. Whether a cursor's elements can be kept depends on the element type:TagMap.EntryReadercarries its own confinement (Add @Confined correctness contract for call- and frame-confined types #12997).Hashtable's iterators,HashSupport.BucketWalkerandStrings.SplitIteratorare the next candidates.TagMapgets a public cursor after the dense store (Add a dense known-tag store behind an experimental flag (dense store - part 8) #13004) lands.🤖 Generated with Claude Code