Skip to content

SWF(perf): Move issue-list Git reads off async workers - #663

Merged
beardthelion merged 1 commit into
mainfrom
perf/issue-list-blocking-reads
Dec 2, 2026
Merged

beardthelion merged 1 commit into
mainfrom
perf/issue-list-blocking-reads

Conversation

@beardthelion

@beardthelion beardthelion commented Dec 1, 2026 •

Copy link
Copy Markdown
Collaborator

Run issue-list Git work on a blocking thread with the shared read permits and deadline from #648.

The listing still batches issue blobs. The runner reaps timed-out Git children before releasing the permits. A Git timeout returns 504; exhausted admission returns 503 with Retry-After.

Unrelated-request p99

Route main (ms) branch (ms)
GET /health 12,974.786 894.588
GET /api/v1/repos/{owner}/cheap (repo detail, no Git) 13,523.469 1,528.133

Python 3.10 over loopback, debug builds of main (69f7f36) and this branch, same 4-vCPU Linux VM and PostgreSQL 16. Two Tokio workers. Eight closed-loop issue-list clients (read caps 16 per caller and 128 total), one bare repo with 4,000 loose issue blobs (512-byte bodies, no commits, 33 MiB on disk). No injected Git delay.

Ran main, branch, branch, main. Each run had 3 seconds of warm-up and 20 seconds of measurement. Each probe route was scheduled at 25 requests/s; p99 is nearest rank over 1,000 samples per route per build, measured from scheduled send to full response. It includes client queueing under load (16 shared probe threads). Every probe returned 200. Within the measurement windows, main completed 207 issue lists and the branch completed 323, all 200.

Response identity

Fixture Main and branch Body comparison
Four valid issue blobs and one malformed JSON blob 200, four issues in ref order Byte-identical
Same fixture with one valid blob replaced by unreadable bytes 500 git_error Byte-identical

diff -u exited 0 for both JSON bodies. The timeout regression forces the batch child to hang and checks for a reaped child and 504.

cargo fmt --all -- --check and cargo test --locked --workspace passed. Strict Clippy on Rust 1.99 reports the same four clippy::double_must_use errors on main and this branch at blockstore/mod.rs:114. With that lint alone allowed, workspace Clippy passes.

Try it

With DATABASE_URL set to local PostgreSQL 16+: cargo test -p twigpine-node list_issues

Untested: production traffic, packed or remote-backed fixture repos, non-Unix teardown.

Summary by CodeRabbit

  • Bug Fixes
    • Issue listings now run with bounded execution time, helping prevent requests from hanging. Timed-out requests return a gateway timeout; other Git errors are reported as errors.
    • Listings preserve reference order, include valid issue data, and skip malformed entries or references that disappear during retrieval.

@coderabbitai

coderabbitai Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Issue listing now uses bounded Git reads with deadlines. The API maps timeouts and other Git failures to errors, while valid issue JSON retains ref order and malformed entries are skipped.

Changes: Bounded issue listing

Layer / File(s) Summary
Bound Git issue enumeration
crates/twigpine-node/src/git/issues.rs
list_issues accepts a Git executable and deadline. It uses bounded commands to enumerate refs and read objects, and handles refs that disappear or contain unreadable objects. Tests use the bounded API.
Connect bounded listing to the API
crates/twigpine-node/src/api/repos.rs, crates/twigpine-node/src/api/issues.rs, crates/twigpine-node/src/test_support.rs
The API handler uses the shared bounded repository-read path. It maps timeouts and Git failures, skips malformed JSON, and preserves valid issue order. Tests cover timeout cleanup and updated call sites.

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

Change: Refactor

Possibly related issues

Suggested labels: crate:node, kind:perf

Suggested reviewers: kevincodex1, jatmn

Merge Risk: Minimal · up to 46ddf

Issue listing now runs its Git reads on a blocking thread with the shared read permits and deadline. Timeouts return 504 and other Git failures return errors, instead of an empty result or unbounded work. No concrete merge-blocking defect was identified; production traffic, packed or remote-backed repos, and non-Unix teardown remain untested.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: issue-list Git reads move off async worker threads. It uses the "SWF(perf)" prefix, which is a non-standard but descriptive scope marker. The changeset matches this: l…
Description check Passed The description follows the template's main sections: Summary, Motivation, What changed (partly), How to verify, and Try it. It explains the blocking-thread move, the 504/503 mappings, the benchmark, …
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: issue-list Git reads move off async worker threads. It uses the "SWF(perf)" prefix, which is a non-standard but descriptive scope marker. The changeset matches this: list_issues now runs through the bounded repository-read path on a blocking thread, with the shared permits and deadline.

Full details: Description check

Explanation

The description follows the template's main sections: Summary, Motivation, What changed (partly), How to verify, and Try it. It explains the blocking-thread move, the 504/503 mappings, the benchmark, the byte-identical response checks, and test commands. Gaps: the Motivation section has no linked issue ("Closes #" is blank), the Kind of change checkboxes are unticked, the What changed section does not list concrete bullets or name the crate touched (twigpine-node), and the checklist is not ticked. The protocol section is not addressed, though it is arguably not applicable.

Resolution

Consider these additions: fill in or remove the blank "Closes #" line, tick the Kind of change box (Refactor or Bug fix, depending on intent), add bullets under What changed that name twigpine-node and list the signature and visibility changes, and tick the checklist items that were verified.

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: 2df1d26f-d8f6-4d71-b6ba-4c79b77d76ec
Commits

Reviewing files that changed from the base of the PR and between 03fe9c6 and 46ddf16.

Files selected for processing: 4

  • crates/twigpine-node/src/api/issues.rs
  • crates/twigpine-node/src/api/repos.rs
  • crates/twigpine-node/src/git/issues.rs
  • crates/twigpine-node/src/test_support.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

  • Branch vs main: Head is mergeable with no reported conflicts; PR base matches current origin/main (e4e5f36). No rebase required for stale merge-base drift.
  • Required checks: All required PR checks on head 46ddf165 passed (fmt+clippy, stable/beta tests, release build, MSRV, CodeRabbit).
  • Merge gate status: GitHub reports mergeStateStatus: BLOCKED with no failing checks — likely awaiting human review, not a code defect.
  • Related work: Builds on bounded git read infrastructure from #648; issue git paths beyond list (e.g. #204 family) remain unbounded and are explicitly out of this diff’s scope.
  • Author checklist / description: CodeRabbit notes blank “Closes #” and unticked template checkboxes — hygiene only, not a merge-blocking defect for this behavior change.

Notes (non-blocking)

  • Local cargo test -p twigpine-node list_issues could not run #[sqlx::test] cases without DATABASE_URL; CI already exercised them.
  • Batch-timeout child-reap integration test is #[cfg(unix)]; PR body already calls out non-Unix teardown as untested.

@beardthelion
beardthelion added this pull request to the merge queue Dec 2, 2026
Merged via the queue into main with commit 617e876 Dec 2, 2026
22 checks passed
@coderabbitai coderabbitai Bot mentioned this pull request Dec 2, 2026
8 of 14 tasks
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