Rename detection misses renames in large commits; adopt C git's algorithm
還沒有人認領這個 Issue。
評估
- 難度
- 5/5
- 預估耗時
- 一週以上
- 新手友好度
- 38/100
- Issue 類型
- 功能
- 描述清晰度
- 描述清楚
- 活躍度
- 活躍
- 技術堆疊
- git, java
- 領域
- performance, tooling
研究方向
Start with RenameDetector, DiffConfig, and the existing rename-detection tests and benchmarks; the issue also names diffcore-rename.c as the behavioral reference. Trace parsing of diff.renameAlgorithm, diff.renameLimit, and diff.renames, then add coverage for basename matching, C Git-compatible scores, limits, and copy detection. Done means the opt-in basename algorithm matches the expected C Git pairings and scores, the copy case works, and benchmark results demonstrate improved runtime and allocation without changing matrix defaults.
由索引模型根據 Issue 內容生成。
描述
Description
Problem
When a commit moves many slightly edited files (e.g. a directory or package move that also touches each file), JGit either finds no renames or becomes very expensive:
- With the default
diff.renameLimit(400), inexact detection is skipped as soon as more than 400 files are added or deleted: every rename is reported as a deletion plus an addition. - Raising the limit makes the matrix algorithm quadratic: about 8 s and 3.1 GB allocated per diff for 1000 files.
- C git reports all renames of the same commit with its default settings.
Scenario
- N files of 50 lines in
old/dir0..dir9/, moved tonew/dir0..dir9/. - One line out of ten is edited in every file, so no rename is exact (C git scores them 85-86%).
- MOVE keeps the basename (
File1.java); RENAME also changes it (Renamed1.java), so matching by name cannot help.
Renames reported with default settings:
| Files | JGit (matrix, limit 400) | C git 2.54 | Proposed (basename, limit 1000) |
|---|---|---|---|
| 100 | 100 | 100 | 100 |
| 1000 | 0 (over limit) | 1000 | 1000 |
Cost with the limit disabled (JMH, JDK 25, rename score 60 for both; both find all renames):
| Case | Files | matrix | basename | Allocated per op |
|---|---|---|---|---|
| MOVE | 100 | 33 ms | 0.9 ms | 30.9 MB → 1.3 MB |
| MOVE | 1000 | 7992 ms | 27 ms | 3.1 GB → 12.8 MB |
| RENAME | 100 | 32 ms | 1.8 ms | 30.9 MB → 1.3 MB |
| RENAME | 1000 | 8415 ms | 128 ms | 3.1 GB → 12.8 MB |
Proposal
Add an opt-in algorithm following C git's diffcore-rename.c, selected with diff.renameAlgorithm = basename (default stays matrix):
- Pair identical content first, preferring the same basename.
- Then compare files whose basename is unique among the remaining sources and destinations.
- Then score content, keeping the 4 best sources per destination. Similarity is computed like C git, so scores match
git diff -M. - Honor
diff.renames = copieslikegit diff -C;log --followand blame keep following renames only. - Use C git's defaults (score 50, limit 1000) when the algorithm is configured; an explicit
diff.renameLimitstill wins.
Planned changes, as one review chain:
- Similarity index compatible with C git
- Basename algorithm in
RenameDetector, with a benchmark diff.renameAlgorithmconfiguration- Copy detection
Motivation
- Tools built on JGit (code review, hosting, IDEs) show large refactorings as unrelated deletions and additions, while
gitshows renames. - Results should be consistent with the
gitCLI, in pairings and scores. diff.renames = copiesis parsed (DiffConfig#getRenameDetectionType()returnsCOPY) but never used: modified files are never considered as sources, so a file copied from one that still exists shows up as an addition, unlike withgit diff -C.
Alternatives considered
- Raising
diff.renameLimit: works, but costs 8 s and 3.1 GB per diff for 1000 files. - Optimizing the matrix algorithm in place: it would still score every pair, and changing its scoring would change results for all users. Hence opt-in.
- Making the new algorithm the default: could be discussed once it has been used for a while.
Additional context
- I have an implementation with tests (expected results taken from C git) and the benchmark. I will push it to Gerrit and link the changes here.
- Feedback welcome on: the option name and values, and whether the defaults should depend on the configured algorithm.
- Related: #110.
RenameDetectorstill defaults to a score of 60; this proposal leaves the matrix defaults unchanged. - The implementation was developed with AI assistance. I have reviewed and tested it and will answer for it in review. Commits carry
Assisted-bytrailers, and largely generated files the AI disclosure header described in the Eclipse handbook.
- 主要語言
- Java
- 星號
- 427
- 分支
- 116
- PR 合併指標
- 30 天內沒有已合併 PR
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
eclipse-jgit/jgit 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 83/100
eclipse-jgit/jgit#329 ·
-
難度 2/5 1-3 小時 新手友好度 77/100
eclipse-jgit/jgit#327 ·
-
Repository.create(boolean bare) should provide a no-arg overload that uses isBare()可能重新可做 @hardikyadav12 於 77 天前認領,目前沒有進行中的 PR。 未關閉
難度 2/5 1-3 小時 新手友好度 74/100
eclipse-jgit/jgit#297 · 1 則留言 ·
-
難度 2/5 1-3 小時 新手友好度 83/100
eclipse-jgit/jgit#293 · 2 則留言 ·
-
難度 2/5 1-3 小時 新手友好度 72/100
eclipse-jgit/jgit#288 ·
查看 eclipse-jgit/jgit 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 67/100
constellation-app/constellation#2613 ·
維護者通常 2 天內回覆
-
難度 2/5 1-3 小時 新手友好度 69/100
Vakore/ZappierGames#334 ·
-
難度 2/5 1-3 小時 新手友好度 74/100
IETF-Hackathon/pqc-certificates#369 ·
維護者通常 1 天內回覆
-
? - Needs Triage bot_watch bug
難度 2/5 1-3 小時 新手友好度 78/100
NVIDIA/cudf-spark-jni#5594 ·
維護者通常 1 天內回覆
-
難度 1/5 1 小時以內 新手友好度 92/100