Skip to content

[Misc] Avoid recomputing merges already resolved when checking file change conflicts - #185

Open
surli wants to merge 1 commit into
mainfrom
perf/dedupe-conflict-merge-computation
Open

[Misc] Avoid recomputing merges already resolved when checking file change conflicts#185
surli wants to merge 1 commit into
mainfrom
perf/dedupe-conflict-merge-computation

Conversation

@surli

@surli surli commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Jira URL

N/A ([Misc] change, no dedicated issue)

Changes

Description

hasConflict(FileChange) in DefaultChangeRequestMergeManager re-ran an independent 3-way merge (editionHasConflict) to determine whether a file change conflicts, even though getMergeDocumentResult(FileChange) already computes the exact same conflict status and exposes it via ChangeRequestMergeDocumentResult#hasConflicts().

When viewing a change request, the UI computes getMergeDocumentResult for every modified file (to render diffs) and then separately calls hasConflict(ChangeRequest) (which loops hasConflict(FileChange)) for the "checks" tab. For a conflicting EDITION file change this meant the same document merge was performed multiple times per page view.

This PR makes hasConflict(FileChange) simply delegate to getMergeDocumentResult(fileChange).hasConflicts(), reusing the already-cached result instead of recomputing it.

Clarifications

  • editionHasConflict is now dead code and has been removed. deletionHasConflict/creationHasConflict are kept since getMergeDocumentResult still calls them directly.
  • The now-unused hasConflictCache (a separate 1000-entry LRU cache) and its associated listener/bookkeeping in MergeCacheManager have been removed, since conflict status is now served from the existing crMergeDocumentResultCache.
  • No public API signature changes; ChangeRequestMergeManager#hasConflict(FileChange) and #hasConflict(ChangeRequest) behave identically, just cheaper on a cache miss.

Screenshots & Video

N/A (internal performance change, no UI/behavior difference).

Executed Tests

  • xmvn -B -ntp -pl application-changerequest-default -am test — 210 tests, all passing.
  • xmvn -B -ntp -pl application-changerequest-default -am verify -DskipTests — checkstyle, license headers, Revapi (no API break), Spoon: all clean.

Expected merging strategy

Prefers squash: Yes


Generated with Claude Code

…hange conflicts

ChangeRequestMergeDocumentResult#hasConflicts() already carries the exact
conflict status computed by getMergeDocumentResult(FileChange). Reuse it
in hasConflict(FileChange) instead of re-running an independent 3-way
merge, which previously duplicated the merge cost for every conflicting
file change checked when displaying a change request (once per merge
result computation, once more per conflict check). The now-dead
hasConflictCache and its bookkeeping in MergeCacheManager are removed.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@surli surli self-assigned this Jul 31, 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