Skip to content

YTDB-630: Skip path construction#867

Open
sandrawar wants to merge 2 commits intocons-list-pathfrom
skip-path-construction
Open

YTDB-630: Skip path construction#867
sandrawar wants to merge 2 commits intocons-list-pathfrom
skip-path-construction

Conversation

@sandrawar
Copy link
Copy Markdown
Collaborator

PR Title:

YTDB-630: skip path construction

Motivation:

The IS2 query does not declare a pathAlias. The pathToHere parameter is only needed when the user requests $matchPath metadata. When no pathAlias exists, pass null and skip all path construction

Expected impact: For IS2, this eliminates all path ArrayList allocations and copies. Combined with R4a, this is the most impactful allocation reduction.

Risk: Low — controlled by a simple null check. The pathToHere is already nullable.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a significant performance optimization by conditionally skipping the construction of path-related data structures and metadata when a pathAlias is not specified in a query. This change primarily targets queries like IS2, which do not declare a pathAlias, leading to a substantial reduction in ArrayList allocations and copies. The modification is controlled by a simple null check, ensuring low risk while delivering high impact on memory efficiency.

Highlights

  • Conditional PathNode Construction: PathNode objects are now only constructed if a pathAlias is explicitly declared, preventing unnecessary allocations for queries that do not require path metadata.
  • Conditional $matchPath Metadata Setting: The $matchPath metadata is now only set if a pathAlias is present, further reducing overhead when path information is not requested.
  • Refactored Path Alias Check: Introduced a hasPathAlias boolean variable to centralize the check for pathAlias existence, improving readability and consistency in the MatchEdgeTraverser.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces performance optimizations to the MatchEdgeTraverser by conditionally creating path-related objects and metadata only when a path alias is explicitly declared in the query. This change aims to reduce memory allocation and processing for queries that do not require path information. A new test case, testWhileWithoutPathAliasSkipsPathConstruction, has been added to validate this optimization, ensuring that traversals without path aliases still correctly identify reachable vertices and depths while confirming that path construction is skipped. There is no feedback to provide.

@sandrawar sandrawar changed the title Skip path construction YTDB-630: Skip path construction Mar 26, 2026
@github-actions
Copy link
Copy Markdown

Coverage Gate Results

Thresholds: 85% line, 70% branch

Line Coverage: ✅ 100.0% (6/6 lines)

File Coverage Uncovered Lines
core/src/main/java/com/jetbrains/youtrackdb/internal/core/sql/executor/match/MatchEdgeTraverser.java ✅ 100.0% (6/6) -

Branch Coverage: ✅ 100.0% (10/10 branches)

File Coverage Lines with Uncovered Branches
core/src/main/java/com/jetbrains/youtrackdb/internal/core/sql/executor/match/MatchEdgeTraverser.java ✅ 100.0% (10/10) -

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 26, 2026

Test Count Gate Results

✅ No baseline available yet — gate skipped (first run).

@sandrawar sandrawar requested review from andrii0lomakin and removed request for andrii0lomakin March 26, 2026 15:29
@sandrawar sandrawar force-pushed the skip-path-construction branch from edac01d to 5453cb1 Compare March 30, 2026 06:37
@sandrawar sandrawar force-pushed the skip-path-construction branch from 5453cb1 to 6a61953 Compare April 2, 2026 06:54
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 2, 2026

JMH LDBC Benchmark Comparison

Base: 244d8c7275 (fork-point with develop) | Head: f1f81cc418
Summary: 🟢 28 improvement(s) (>±5% threshold)

Single-Thread Results

Benchmark Base ops/s Base err Head ops/s Head err Δ%
ic10_friendRecommendation 0.137 ±5.2% 0.145 ±5.9% +6.1% 🟢
ic11_jobReferral 36.0 ±5.8% 40.1 ±1.6% +11.3% 🟢
ic12_expertSearch 22.2 ±5.6% 25.0 ±0.6% +12.4% 🟢
ic13_shortestPath 4,169 ±1.3% 4,471 ±1.5% +7.2% 🟢
ic1_transitiveFriends 39.4 ±5.9% 46.1 ±0.9% +16.8% 🟢
ic2_recentFriendMessages 205.2 ±9.5% 237.7 ±1.5% +15.8% 🟢
ic3_friendsInCountries 0.162 ±5.5% 0.177 ±5.6% +9.5% 🟢
ic4_newTopics 2.7 ±6.9% 3.4 ±1.7% +27.6% 🟢
ic5_newGroups 0.095 ±24.2% 0.096 ±24.1% +1.2%
ic6_tagCoOccurrence 3.7 ±5.1% 3.9 ±2.9% +5.2% 🟢
ic7_recentLikers 56.4 ±4.9% 64.2 ±2.5% +14.0% 🟢
ic8_recentReplies 971.0 ±0.8% 971.2 ±0.5% +0.0%
ic9_recentFofMessages 1.3 ±4.6% 1.3 ±1.6% +3.9%
is1_personProfile 56,631 ±1.0% 57,261 ±1.5% +1.1%
is2_personPosts 566.4 ±1.1% 580.8 ±1.1% +2.5%
is3_personFriends 16,328 ±3.0% 16,581 ±3.2% +1.6%
is4_messageContent 79,602 ±0.6% 79,540 ±0.8% -0.1%
is5_messageCreator 71,704 ±0.8% 71,322 ±2.3% -0.5%
is6_messageForum 49,362 ±1.6% 48,940 ±1.7% -0.9%
is7_messageReplies 2,870 ±0.6% 3,466 ±0.6% +20.7% 🟢

Multi-Thread Results

Benchmark Base ops/s Base err Head ops/s Head err Δ%
ic10_friendRecommendation 0.589 ±1.8% 0.616 ±3.3% +4.6%
ic11_jobReferral 160.5 ±3.5% 177.5 ±3.2% +10.6% 🟢
ic12_expertSearch 113.6 ±2.0% 126.6 ±3.0% +11.4% 🟢
ic13_shortestPath 16,369 ±4.0% 19,724 ±3.8% +20.5% 🟢
ic1_transitiveFriends 185.9 ±3.5% 211.1 ±1.9% +13.6% 🟢
ic2_recentFriendMessages 882.8 ±2.2% 1,036 ±2.6% +17.4% 🟢
ic3_friendsInCountries 0.630 ±7.4% 0.704 ±2.2% +11.7% 🟢
ic4_newTopics 9.3 ±6.9% 13.8 ±3.2% +48.4% 🟢
ic5_newGroups 0.331 ±8.3% 0.409 ±7.8% +23.7% 🟢
ic6_tagCoOccurrence 15.7 ±2.1% 17.7 ±2.6% +12.8% 🟢
ic7_recentLikers 241.7 ±6.9% 277.2 ±2.5% +14.7% 🟢
ic8_recentReplies 4,342 ±1.2% 4,730 ±1.7% +8.9% 🟢
ic9_recentFofMessages 5.8 ±4.8% 6.3 ±3.6% +8.6% 🟢
is1_personProfile 223,078 ±2.6% 232,992 ±2.4% +4.4%
is2_personPosts 2,652 ±1.2% 2,844 ±2.6% +7.3% 🟢
is3_personFriends 66,613 ±3.8% 71,147 ±4.2% +6.8% 🟢
is4_messageContent 291,725 ±2.0% 312,971 ±1.5% +7.3% 🟢
is5_messageCreator 267,660 ±1.8% 287,262 ±1.0% +7.3% 🟢
is6_messageForum 190,005 ±1.9% 199,160 ±5.1% +4.8%
is7_messageReplies 11,735 ±2.1% 14,931 ±2.7% +27.2% 🟢

Scalability (MT/ST ratio)

Benchmark Base ratio Head ratio Δ%
ic10_friendRecommendation 4.32x 4.25x -1.4%
ic11_jobReferral 4.46x 4.43x -0.7%
ic12_expertSearch 5.11x 5.06x -1.0%
ic13_shortestPath 3.93x 4.41x +12.4%
ic1_transitiveFriends 4.71x 4.58x -2.8%
ic2_recentFriendMessages 4.30x 4.36x +1.4%
ic3_friendsInCountries 3.90x 3.97x +2.0%
ic4_newTopics 3.47x 4.03x +16.3%
ic5_newGroups 3.50x 4.27x +22.2%
ic6_tagCoOccurrence 4.28x 4.59x +7.3%
ic7_recentLikers 4.29x 4.32x +0.6%
ic8_recentReplies 4.47x 4.87x +8.9%
ic9_recentFofMessages 4.57x 4.78x +4.6%
is1_personProfile 3.94x 4.07x +3.3%
is2_personPosts 4.68x 4.90x +4.6%
is3_personFriends 4.08x 4.29x +5.2%
is4_messageContent 3.66x 3.93x +7.4%
is5_messageCreator 3.73x 4.03x +7.9%
is6_messageForum 3.85x 4.07x +5.7%
is7_messageReplies 4.09x 4.31x +5.4%

@andrii0lomakin
Copy link
Copy Markdown
Collaborator

Hi @sandrawar, please profile regressions using asyncprofiler on Hetzner CCX 33 node and find out what caused the regressions. It should be quite the opposite as I see it.

@sandrawar sandrawar force-pushed the skip-path-construction branch from 6a61953 to f1f81cc Compare April 3, 2026 11:54
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.

2 participants