Skip to content

SWF(perf): Bucket ref-update visibility by repo name - #660

Merged
beardthelion merged 3 commits into
mainfrom
perf/bucket-ref-update-visibility
Dec 2, 2026
Merged

beardthelion merged 3 commits into
mainfrom
perf/bucket-ref-update-visibility

Conversation

@beardthelion

@beardthelion beardthelion commented Dec 1, 2026 •

Copy link
Copy Markdown
Collaborator

Build one exact-name repo index per request for the REST and GraphQL ref-update feeds, and check only same-name candidates.

Quarantine still vetoes a matching row even for the owner. Owner-prefix matching, keyset paging, and output order are unchanged.

Gate Matcher calls/window Mean thread CPU/window p95 wall/window
Main (d4cbdb3), full scan 33,481,536 368.735 ms 382.961 ms
Exact-name buckets 3,840 5.368 ms 6.067 ms

The Rust harness runs main's full-scan gate and the production indexed gate on the same preloaded window: 30,000 active repos, 2,000 quarantined repos, and 2,048 newest-first rows (1,792 private, 128 quarantined, 128 visible). It checks ordered output equality, then alternates the two paths for 40 timed windows each. The indexed timing includes building and dropping the index. Matcher calls come from fixture positions and short-circuit points, not counters in the timed loops. CPU is Linux thread CPU time; p95 is nearest-rank wall time. Optimized Rust 1.99.1, LTO off, Ubuntu x86_64 VM with four Xeon vCPUs, single test thread with affinity to CPUs 2 and 3. This measures the in-memory gate, not SQL, owner resolution, or HTTP latency.

A separate seeded test compares ordered row IDs and slugs against the full scan for all 2,048 events on a 12,288-repo catalog, for anonymous, owner, and rule-reader callers. The Postgres-backed workspace suite passed, including the REST and GraphQL feed tests. Strict Clippy hits the same clippy::double_must_use errors on main at blockstore/mod.rs:114 under this toolchain; it passes on the branch with only that lint allowed.

CARGO_PROFILE_RELEASE_LTO=false cargo test --locked --release -p twigpine-node --lib bench_ref_update_visibility -- --ignored --nocapture

Summary by CodeRabbit

  • Refactor
    • Ref-update feeds continue to apply repository visibility rules, including to quarantined repositories and repositories that share a name. Visibility checks have been reorganized, while feed results, pagination, and limits remain unchanged. No user-facing behavior changes are expected.

@coderabbitai

coderabbitai Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The ref-update visibility gate now uses a request-local index of active and quarantined repositories. The event collector applies the index to each row. Tests compare indexed filtering with a full-scan reference.

Changes: Ref-update visibility

Layer / File(s) Summary
Indexed visibility gate
crates/twigpine-node/src/visibility.rs
RefUpdateRepoIndex checks matching active and quarantined records. Tests cover candidate matching, visibility decisions, and equivalence with a full-scan reference.
Event feed integration
crates/twigpine-node/src/api/events.rs, crates/twigpine-node/src/api/tasks.rs
The event collector uses the index to filter rows. The task_visible documentation now describes the ref-update feed gate without naming the removed function.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Refactor

Possibly related PRs

  • Twigpine/node#143: PR #143 adds visibility gating to the ref-update feeds. This change updates the visibility gate used by the event collector.

Suggested labels: crate:node, subsystem:visibility, subsystem:api, kind:refactor

Suggested reviewers: kevincodex1

Merge Risk: Minimal · up to 9ff33

This change speeds up ref-update visibility filtering for the REST and GraphQL feeds without changing which rows are visible. No actionable merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: ref-update visibility checks are bucketed by exact repo name, which is the core of the performance refactor in visibility.rs and the collector. It matches the PR objec…
Description check Passed The description covers the summary, the motivation for the performance change, and a verification section with a benchmark command and test results. It also gives a Clippy note. It does not fill the t…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: ref-update visibility checks are bucketed by exact repo name, which is the core of the performance refactor in visibility.rs and the collector. It matches the PR objectives. The title uses the SWF(perf) prefix, which is a scope label, not vague wording.

Full details: Description check

Explanation

The description covers the summary, the motivation for the performance change, and a verification section with a benchmark command and test results. It also gives a Clippy note. It does not fill the template's 'Closes #' issue link, the 'Kind of change' checklist, or the 'Before you request review' checklist. It does not state the crate touched in 'What changed', and it has no protocol and signing impact section, which the template says to delete when the change does not touch the protocol. Those gaps are minor and the PR is mostly complete.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f6638dea-eb6d-4bd4-943c-00054212fb73
Commits

Reviewing files that changed from the base of the PR and between 89cb24a and 9ff33ac.

Files selected for processing: 1

  • crates/twigpine-node/src/api/events.rs

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@jatmn jatmn left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Thanks for the contribution. I do not see any actionable issues from my review.

Merge readiness

  • Review policy: Required checks were green at review time; branch protection may still require this approval before merge.
  • Base freshness: PR base matched live main at review time (617e87630ea9cbb6056afea369693aae80436dac); no rebase needed for target drift.
  • Optional follow-up: collect_visible_ref_updates_inner comments still describe a separate quarantine pass in the loop; the loop now uses unified RefUpdateRepoIndex::row_visible. Updating that comment is cosmetic, not merge-blocking.

Findings

(none)

Review method: full merge-gate campaign (primary + 2×2 blind searches). Indexed gate is equivalent to the prior full scan because ref_update_row_names_repo still requires exact repo name equality before owner-prefix matching; quarantine veto remains before listable_at_root.

@beardthelion

Copy link
Copy Markdown
Collaborator Author

Updated the comment in collect_visible_ref_updates_inner to say the loop vetoes quarantined rows through RefUpdateRepoIndex::row_visible, and merged current main (clean, no overlap with this PR's files). No code changed. fmt, clippy and the full workspace tests pass at the new head.

@beardthelion
beardthelion added this pull request to the merge queue Dec 2, 2026
Merged via the queue into main with commit 4b9be4d Dec 2, 2026
21 checks passed
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.

2 participants