Repository navigation
SWF(perf): Batch repo-read gate lookups - #661
Conversation
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
jatmn
left a comment
There was a problem hiding this comment.
Merge readiness
-
GitHub reports
mergeable_state: blockedwith required CI green on head8c303f7. That usually means an outstanding approval or branch-protection rule, not a technical merge conflict (mergeable: true). -
The PR branch is one commit behind its configured base ref (
behind_by: 1on69f7f36). Rebasing onto currentmainbefore merge is cheap insurance even though nomaincommits since the merge-base touchcrates/twigpine-node/src/api/mod.rsorcrates/twigpine-node/src/db/mod.rs. -
PR template gaps CodeRabbit flagged (unchecked "Kind of change", empty
Closes #, missing "Before you request review" checklist) are housekeeping for the author, not merge blockers for this perf refactor.
Findings
🟢 Thanks for the contribution. I do not see any actionable issues from my review.
The batched get_repo_read_policy path preserves the security shape that mattered on merge-base: pick canonical before mirror, apply quarantine withhold after LIMIT 1 so a quarantined canonical cannot yield the public mirror, then run the same Rust visibility_check. The new sqlx equivalence test is the right oracle for that contract.
Fetch the canonical repo and its ordered visibility rules in one Postgres statement instead of three. Pick the canonical row before filtering quarantine so a public mirror can't take its place. Rust still decides who can read each path. Missing, withheld, and quarantined repos still return the same 404.
The gate signature stays the same. The separate repo identity check after Git stays in place, including in #648.
Warm repo metadata
Method: PostgreSQL 16.16 in Docker. Same database and public repo with two subtree rules for both binaries. Cargo dev builds with debug info off, before at
d4cbdb3. Loopback HTTP GET/api/v1/repos/zGateBench/read-gate, one request at a time on a reused connection. 60 warm-ups per run, then 500 samples on local TCP or 250 through Toxiproxy (10 ms each direction, zero configured jitter). Timed through the last response byte and took nearest-rank percentiles. Counted executed route statements withpg_stat_statements, excluding the observer and background jobs. The endpoint still does its separate star-count and homepage lookups.Local p95 was 0.066 ms higher in this run. With injected delay, p95 fell by 93.499 ms.
Try it
With
DATABASE_URLpointing at a PostgreSQL 16+ test server:cargo test --locked -p twigpine-node --lib repo_read_gate_matches_sequential_lookupThe test compares the old and new gate on the same rows, including rule order, owner and reader access, and byte-identical 404s. It also proves a quarantined canonical row can't fall back to a public mirror.
Strict Clippy hits
clippy::double_must_useinblockstore/mod.rson both this branch andd4cbdb3with the local Rust 1.99 toolchain.Summary by CodeRabbit