Repository navigation
feat(snapshot-log): add path history index provider - #7505
Conversation
Add SnapshotLog stores and wire filtered snapshot log queries to use the path history index with scan-based fallback.
Propagate SnapshotLog config into the binding setup and preserve deleted descendant history when files replace directories. Reduce backfill and append overhead so indexing work does not add unnecessary object reads or SQL round trips.
Always compile SnapshotLog with the git module and keep provider selection as runtime configuration. Avoid extra tree reads when indexing is disabled and reuse tail-scan results after concurrent head updates.
Route SnapshotLog settings through git.snapshot.log so future snapshot settings can share the git.snapshot section.
SnapshotLog 性能测试场景假设
Mock 数据构造使用单 branch,连续生成 1000 个 commit。文件树固定为 基础文件路径生成规则: 每个 commit 固定修改一个基础文件,保证 1000 commits 和 1000 files 的规模: 每个 commit 再按命中分布规则额外修改固定的 case 文件。表格中的每一行是一个
以 这套数据主要测试单文件 path 查询,同时保留祖先路径索引: 注意:这些 case 文件也属于基础文件树。基础写入可能会让它们额外命中一次。 1000 commits 测试记录
测试口径:
结论SnapshotLog 对 对比本地现状,SnapshotLog 的提升范围为 对比 NAS 现状,SnapshotLog 的提升范围为 性能差异来自旧逻辑需要倒扫 commit 链,并反复读取 tree 做 path 判断。NAS 会 |
qin-ctx
left a comment
There was a problem hiding this comment.
路径历史索引能解决实际的查询延迟问题,本地对照也确认了对象读取次数明显减少,方案有合入价值。
当前建议 REQUEST_CHANGES:合并前需要解决 Windows 默认配置无法启动、独立工作区共用默认索引导致反复扫描历史,以及索引数据库故障阻断服务启动这三个问题。另有一条非阻塞问题:补齐索引后,目录历史会漏掉空目录的删除记录。具体场景和依据见行内评论。
Use a workspace-scoped SQLite default when no explicit path is set. Fall back to Git scanning when a SnapshotLog store is unavailable.
qin-ctx
left a comment
There was a problem hiding this comment.
已重新评审当前完整改动。按路径查询历史的性能收益成立,方案值得合入。上一轮关于 Windows 路径、默认索引库的工作区隔离,以及索引数据库故障阻断启动的三个阻塞问题,当前修改均已解决。
本轮没有发现新的阻塞问题,补充两条非阻塞意见:直接使用原生绑定时的旧配置兼容问题,以及索引落后超过扫描上限时无法由查询触发补齐的问题。具体场景和验证结果见行内评论。
验证包括 196 个 Git 相关 Rust 测试,以及真实 SQLite、MySQL 8.4 和原生绑定的运行对照。文件、目录、多路径查询,以及多客户端写入、并发补齐和快照恢复的结果均与原扫描逻辑一致。
Description
This PR adds SnapshotLog, a path history index for
snapshot/log?paths=....The slow case in #6750 comes from filtered snapshot log queries walking the
branch commit chain and checking the requested path commit by commit. SnapshotLog
keeps a derived
account + branch + path -> commitindex so file, directory,and multi-path history queries can avoid scanning unrelated commits when the
index is current.
The Git object model remains the source of truth. SnapshotLog is only an
acceleration layer: if the index is missing, stale, too far behind, or cannot be
used for a path, the request falls back to the existing scan behavior.
Human Involvement
Related Issue
Closes #6750
Type of Change
Changes Made
snapshot/log?paths=...queries to use SnapshotLog when the index is complete, with scan fallback when it is not.commit()andrestore()changes after branch ref CAS, using best-effort writes that do not fail the main operation.[git.snapshot_log], includingprovider = "none"to disable the acceleration layer.Testing
Commands run:
Checklist
Screenshots (if applicable)
N/A
Additional Notes
snapshot/logwithoutpathsstill uses the existing global commit scan. Thatquery asks for branch history, not path history, so it should use a separate
branch commit index if it needs acceleration later.
Cargo output still contains existing repository warnings. They were not cleaned
up in this PR to keep the change focused.