Skip to content

perf(#10013): VertexIteratorFilter.next() hands out the record hasNext() already looked up - #10014

Merged
robfrank merged 1 commit into
ArcadeData:mainfrom
tae898:perf/vertex-iterator-single-lookup
Oct 15, 2026
Merged

robfrank merged 1 commit into
ArcadeData:mainfrom
tae898:perf/vertex-iterator-single-lookup

Conversation

@tae898

@tae898 tae898 commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #10013.

IteratorFilterBase.hasNext loads the neighbour's record only to validate the RID, and VertexIteratorFilter.next loaded it again. The record from hasNext is now kept and handed out when it is a Vertex with the same RID; otherwise next does the old lookup. The answers do not change.

Measured on the undirected openCypher graph queries of the benchmark (LDBC SF1 persons and KNOWS): top degree 0.888 [0.872, 0.901] on JDK 25 (10 clean pairs) and 0.897 [0.878, 0.916] on JDK 21 (15 pairs), degree distribution 0.887 and 0.893, the two other queries 0.94 to 0.96; the plain scan control and an A against A run show no difference. Tables and the program are in #10013.

Tests: VertexIteratorSingleLookupTest fails on the base and passes with the change, and the 133 tests of the ten graph test classes that exercise the iterators pass.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Q8bTVHrrsuZDoTAQgQbLBS

Summary by CodeRabbit

  • Performance
    • Reduced redundant vertex lookups during graph iteration.
  • Tests
    • Added coverage for vertex identity, uniqueness, edge filtering, traversal behavior, and iteration limits.

@mergify

mergify Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again.

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity

Metric Results
Complexity 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@coderabbitai

coderabbitai Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ef5aac3f-0b5f-4931-8f90-c1d2f50fc768
📥 Commits

Reviewing files that changed from the base of the PR and between 29c3adb and c925541.

📒 Files selected for processing: 3
  • engine/src/main/java/com/arcadedb/graph/IteratorFilterBase.java
  • engine/src/main/java/com/arcadedb/graph/VertexIteratorFilter.java
  • engine/src/test/java/com/arcadedb/graph/VertexIteratorSingleLookupTest.java

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

📝 Walkthrough

Vertex iteration now retains the record loaded during RID validation and reuses it in next() when its identity matches. Added tests cover lookup counts, edge-type filtering, repeated hasNext(), direct next(), vertex uniqueness, and exhaustion.

Changes: Vertex iteration lookup

Layer / File(s) Summary
Cache validated records and verify traversal
engine/src/main/java/com/arcadedb/graph/IteratorFilterBase.java, engine/src/main/java/com/arcadedb/graph/VertexIteratorFilter.java, engine/src/test/java/com/arcadedb/graph/VertexIteratorSingleLookupTest.java
IteratorFilterBase stores the record returned during RID validation. VertexIteratorFilter.next() reuses it when it is a Vertex with the expected identity, and otherwise uses the existing RID lookup. Tests check lookup counts, filtering, iteration behavior, uniqueness, and exhaustion.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Refactor · Severity of issue fixed: Medium

Suggested reviewers: lvca

Merge Risk: ⚪ Minimal · up to c9255

The change is mergeable after normal checks; no unresolved behavior or traversal risk was identified.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main performance change: reusing the record loaded by hasNext() in VertexIteratorFilter.next().
Description check Passed The description explains the change, motivation, related issue, benchmark results, and test results. It does not use every template heading and does not explicitly complete the checklist, but it conta…
Linked Issues check Passed Issue #10013 requires reuse of the record loaded by IteratorFilterBase.hasNext during a type-filtered vertex walk, with a RID check and fallback lookup. IteratorFilterBase now stores the validatio…
Out of Scope Changes check Passed The reviewed changes are limited to the iterator record reuse in IteratorFilterBase, the corresponding VertexIteratorFilter.next path, and focused automated tests. These changes directly support i…
  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 1
🛠️ Fix failing CI checks: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@robfrank

Copy link
Copy Markdown
Collaborator

@claude review

@claude

claude Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Claude finished @robfrank's task in 17s —— View job


Review of #10014

I read the two main-code changes and checked them against the rest of the iterator code. I didn't compile or run the tests, and I didn't read the new test file in detail.

Verdict: looks good, no blocking issues.

Correctness

  • validatedVertex is set only on the vertex branch of IteratorFilterBase.hasNext. VertexIteratorFilter.next() reads it, clears it, and reuses it only when it is a Vertex whose identity equals next. Otherwise it falls back to the old lookupByRID. That guard also covers any stale value, for example after reset() or after a corrupt entry was skipped.
  • It is cleared on every next() call, so the iterator doesn't keep a vertex alive for longer than before.
  • The edge path (edge == true) is untouched.
  • lookupByRID(rid, false) is the same call in both places, so the object next() returns should be what it returned before. In a transaction, that lookup should already return the same cached record.

Minor, non-blocking

  • IteratorFilterBase.validatedVertex is protected and typed Record. A private field with a small accessor would be tighter, but the other fields in this class are protected too, so this matches the style.
  • Calling hasNext() without next() leaves the record held until the next next() call. That is a single reference and harmless.
  • The CodeRabbit docstring-coverage warning isn't relevant here. The surrounding code uses short inline comments.

Tests
The PR says VertexIteratorSingleLookupTest fails on the base and passes with the change, and that 133 tests from 10 related graph test classes pass. That covers what I'd want here: lookup count, type filtering, repeated hasNext(), direct next(), and exhaustion.

Approve from my side. I can't submit a formal approval.

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.

Graph: a type-filtered vertex walk looks every neighbour up twice (about 10 percent of the undirected top-degree and degree-distribution queries)

2 participants