Repository navigation
SWF(perf): walk visibility history with one git log pass - #646
Conversation
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
jatmn
left a comment
There was a problem hiding this comment.
I reviewed the change for merge readiness. The performance refactor looks sound on inspection; workspace CI is still blocked until unrelated compile fixes land.
Merge readiness
Required CI before merge. fmt + clippy, test (stable|beta), build --release, and MSRV are failing because twigpine-node does not compile on current main (e.g. missing trusted_peers on IpRateLimiter in server.rs, read_caller_key in api/repos.rs). The author notes dependency on PR #643. After that lands, re-run the full PR check suite on this branch and confirm the visibility tests pass, especially:
cargo test --locked -p twigpine-node --lib raw_history_matches_ls_tree_snapshots
Update the blob-walk module comment (~visibility_pack.rs lines 626–667). It still documents phase-1 git rev-list --all + per-commit ls-tree for blob_paths, but production now uses object_paths (git log --raw) plus unchanged phase-2 non_commit_ref_sets. Align that comment with the new walk so security review does not rely on the old algorithm description.
Branch is current with main. Merge-base matches live origin/main (6168c559); no rebase drift observed.
Intentional behavior change (acceptable). Cyclic graft/replace histories now error in object_paths instead of returning a partial withhold set — fail-closed per PR description.
Findings
No findings.
|
Merged main for the compile fix from #643 and updated the blob_paths doc comment to describe the The rerun also exposed 22 lib tests failing on this branch (7 in api::ipfs::tests, 15 in api::repos::tests). Their git shims and walk counters were keyed on Checked at this head: the 22 tests pass alone, the ipfs and repos test modules pass (80 and 249 tests), the full workspace test run is 3833 passed and 0 failed, and fmt and clippy are clean. With the new shim arms disabled, the 22 tests fail on their own assertions again, so they do bind to the walk. Four converted repos tests assert that no walk or scan ran; they stay green with the arms disabled, so they only show the counter still matches the new command. |
Clones and fetches on repos with hidden paths start a lot faster. Listing the blobs to withhold on this repo's history went from 7.9 s to 67 ms.
The old walk ran
git ls-treeonce per commit to collect every (oid, path) pair the node has to hide. That's one process per commit, so cost grew with history length. The new walk gets the same pairs from a singlegit log --raw -zpass invisibility_pack.rs.How it works
git log --rawprints each file a commit added or changed against its parent. The walk follows every parent and diffs each merge against its first parent, so a file that only shows up in a merge resolution still gets caught. Subtree and root-tree pairs stay in for the object walk. Output is NUL-delimited, so paths with spaces, newlines, quotes or leading dashes parse as-is.Behavior change: a cyclic graft or replace history now errors out. The old walk returned a partial list there, which could leak. Non-commit refs and the windowed sweep didn't change.
Correctness
If the walk misses a pair, a hidden file leaks.
raw_history_matches_ls_tree_snapshotsbuilds fixture repos and checks that the new set matches the oldls-treeset exactly. Fixtures cover merge-only resolutions, side branches, renames, deletes, gitlinks, nested and empty trees, odd paths, detached HEAD and shallow boundaries.Benchmark
Method: a Rust test harness timed the old and new code on the Gitlawb/node checkout (1,759 reachable commits, 196 merges). Each variant got one warm-up and five measured runs on an 8-vCPU Xeon (Ubuntu, Git 2.56.0, Rust 1.99.1, unoptimized test profile). This times visibility enumeration only. Pack generation and network transfer aren't included.
Try it
cargo test --locked -p twigpine-node --lib raw_history_matches_ls_tree_snapshotsNot tested
The tests on
maindon't compile until #643 lands, so CI here will be red until then. There are five unrelated errors, for examplecannot find function 'read_caller_key' in this scopeandmissing field 'trusted_peers' in initializer of 'IpRateLimiter'. The 71 tests above ran with this patch on91c24ae, the parent ofmain. Clippy and the full workspace suite haven't run for the same reason.Summary by CodeRabbit