Skip to content

Speed up root access on the node read and create paths - #12283

Merged
rymsha merged 4 commits into
masterfrom
claude/parent-exists-node-creation-khpwuc
Aug 24, 2026
Merged

Speed up root access on the node read and create paths#12283
rymsha merged 4 commits into
masterfrom
claude/parent-exists-node-creation-khpwuc

Conversation

@rymsha

@rymsha rymsha commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Performance of the two hottest root-node touches, plus a behaviour pin. Four commits:

  1. Pin node create behaviour for missing repository and branchNodeServiceImplTest covered getById against a missing repository and branch but not create, leaving the exception it reports unspecified. The pin comes first so the next commit demonstrably changes nothing observable.
  2. Verify the branch on the node create path only when it fails — every node service method verified branch existence up front, which for create meant a storage lookup of the root node on top of the parent it reads anyway. The lookup now happens only once a parent turns out to be missing, where it tells a missing branch from a missing parent; a missing repository keeps being reported as such rather than as the index error underneath. The guard moves to NodeHelper so the service and the create command share one copy.
  3. Answer the root path from the node id it always has — resolving a path asks the branch index which node holds it, and caches the answer; the root path needs neither, since the root node keeps the one id known without lookup and can be neither moved nor deleted. Previously an uncached root path refreshed the storage index and searched it, and a cached one resolved inside the path cache's atomic block — serializing every concurrent lookup of the busiest path in the repository across a storage round trip.
  4. Drop javadoc from internal node and branch methods — cleanup on the internals the two changes touched.

An earlier revision also fixed resolvePotentialManualOrderValue ignoring a manually ordered root; that fix is deliberately dropped from this PR — legacy manual ordering under root stays as it was, and root ordering is handled by the order-key work in #12285 instead.

🤖 Generated with Claude Code

https://claude.ai/code/session_01ANkY5TN9xn2cFKHk1sfX4B

Copilot AI lite review requested due to automatic review settings August 22, 2026 09:15
@codacy-production

Copy link
Copy Markdown

Codacy's Analysis Summary

0 new issue (≤ 0 issue)
0 new security issue
0 complexity
More details

AI Reviewer: run a review on demand. To trigger the first review automatically, go to your organization or repository integration settings. AI can make mistakes. Always validate suggestions.

Run reviewer

TIP This summary will be updated as you push new changes. Give us feedback

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Updates node creation to assign manual order values under manually ordered roots and centralizes repository/branch validation.

Changes:

  • Removes the root exclusion from manual order resolution.
  • Refactors branch validation and root lookups.
  • Adds regression tests for ordering and invalid contexts.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
modules/itest/itest-core/src/test/java/com/enonic/xp/core/node/NodeServiceImplTest.java Tests missing repository and branch handling.
modules/itest/itest-core/src/test/java/com/enonic/xp/core/node/CreateNodeCommandTest.java Tests manual ordering under a root node.
modules/core/core-repo/src/main/java/com/enonic/xp/repo/impl/node/NodeServiceImpl.java Delegates branch validation.
modules/core/core-repo/src/main/java/com/enonic/xp/repo/impl/node/NodeHelper.java Centralizes branch validation.
modules/core/core-repo/src/main/java/com/enonic/xp/repo/impl/node/CreateNodeCommand.java Resolves manual order values for root children.
modules/core/core-repo/src/main/java/com/enonic/xp/repo/impl/branch/storage/BranchServiceImpl.java Supports root lookups by ID.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

claude added 4 commits August 24, 2026 06:07
NodeServiceImplTest covered getById against a missing repository and a
missing branch, but there was no equivalent for create, leaving the
exception it reports for those cases unspecified.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ANkY5TN9xn2cFKHk1sfX4B
Every node service method verified that the branch exists before doing
its own work, which for create meant a storage lookup of the root node
on top of the parent it reads anyway. The lookup is now made only once a
parent turns out to be missing, where it tells a branch that does not
exist from a parent that does not, and a missing repository keeps being
reported as such rather than as the index error underneath.

The guard itself moves to NodeHelper so the service and the create
command share one copy of it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ANkY5TN9xn2cFKHk1sfX4B
Resolving a path to a node asks the branch index which node holds that
path, and caches the answer. The root path needs neither: the root node
keeps the one node id that is known without looking it up, and it can be
neither moved nor deleted, so its id is answered directly.

A root path that was not cached refreshed the storage index and then
searched it, and a cached one resolved inside the atomic block of the
cache, which serialized every concurrent lookup of the busiest path in
the repository across a storage round trip.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ANkY5TN9xn2cFKHk1sfX4B
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ANkY5TN9xn2cFKHk1sfX4B
@rymsha
rymsha force-pushed the claude/parent-exists-node-creation-khpwuc branch from e6b44c7 to 0193375 Compare August 24, 2026 06:09
@rymsha rymsha changed the title Assign manual order value when creating a node under a manually ordered root Speed up root access on the node read and create paths Aug 24, 2026
@codecov

codecov Bot commented Aug 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.47619% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.02%. Comparing base (b0341bd) to head (0193375).

Files with missing lines Patch % Lines
.../java/com/enonic/xp/repo/impl/node/NodeHelper.java 80.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##             master   #12283   +/-   ##
=========================================
  Coverage     87.01%   87.02%           
- Complexity    20754    20758    +4     
=========================================
  Files          2593     2593           
  Lines         69055    69063    +8     
  Branches       5723     5723           
=========================================
+ Hits          60091    60100    +9     
  Misses         6290     6290           
+ Partials       2674     2673    -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@rymsha rymsha linked an issue Aug 24, 2026 that may be closed by this pull request
@rymsha
rymsha merged commit 1dbd588 into master Aug 24, 2026
12 checks passed
@rymsha
rymsha deleted the claude/parent-exists-node-creation-khpwuc branch August 24, 2026 08:45
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.

Speed up root access on the node read and create paths

4 participants