Skip to content

SWF(perf): batch git reads in issue listing - #647

Merged
beardthelion merged 2 commits into
mainfrom
perf/batch-issue-listing
Dec 1, 2026
Merged

beardthelion merged 2 commits into
mainfrom
perf/batch-issue-listing

Conversation

@beardthelion

@beardthelion beardthelion commented Nov 30, 2026 •

Copy link
Copy Markdown
Collaborator

Listing 1,000 issues took 1.28 s. Now it's 58 ms.

list_issues spawned one git cat-file --batch process per issue. That's a fork and exec for every row, so the list endpoint got slower with every issue a repo collected. Now it spawns one cat-file --batch, writes every blob id to it, and reads the replies back in ref order. Ref enumeration is still a single git for-each-ref. Only crates/twigpine-node/src/git/issues.rs changes.

Behavior doesn't change. A missing object is still skipped, and so is a ref deleted between enumeration and the read. A blob that isn't valid issue JSON is still filtered out.

Benchmark

Issue refs Before (ms) After (ms) Speedup
0 1.058 1.088 0.97x
10 18.712 4.924 3.80x
100 163.871 9.730 16.84x
500 637.970 30.289 21.06x
1,000 1,279.264 57.968 22.07x
2,500 5,047.318 194.439 25.96x

Method: median of 9 alternating release-mode runs, calling the old and new list_issues in-process against the same warm bare repos. Fixture setup and JSON serialization aren't timed. Ubuntu x86-64 Intel Xeon VM, pinned to one logical CPU, Git 2.56.0. The 0-ref row is noise.

Process count at 1,000 refs, from strace:

before: for-each-ref=1 cat-file=1000
after: for-each-ref=1 cat-file=1

Same output

Raw listings and the HTTP JSON were byte-identical before and after at every count above. SHA-256 of the 1,000-ref JSON:

before: e4b033372d5124c9803382a856baf65c706f6a34a2faa1dc8daef915946090be
after:  e4b033372d5124c9803382a856baf65c706f6a34a2faa1dc8daef915946090be

Separate fixtures with a non-blob ref, a corrupt blob, and a ref deleted mid-listing also matched. New unit tests pin exact output for multiline, large, and malformed blobs.

test result: ok. 16 passed; 0 failed; 0 ignored; 0 measured; 8 filtered out

Try it

cargo test -p twigpine-node --lib git::issues

Not tested

Workspace clippy and cargo test --workspace don't compile on current main until #643 lands, so CI here will be red until then. An untouched main checkout fails the same way:

error: could not compile `twigpine-node` (lib) due to 5 previous errors

So the full node suite and the live HTTP endpoint haven't run against this change.

Summary by CodeRabbit

  • Bug Fixes
    • Issue lists now preserve large and non-JSON content instead of losing or misreading it.
    • Listings handle issues whose refs disappear during retrieval, and correctly continue reading subsequent issue records.
    • Invalid or inconsistent issue data is reported as an error rather than silently returned as a valid issue.

@coderabbitai

coderabbitai Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

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: df474519-8313-40b9-990d-cf4aa320a7ae
Commits

Reviewing files that changed from the base of the PR and between 5455c8a and a3b6d9a.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

Issue blob reading now uses a stateful parser for cat-file --batch records. list_issues sends validated ref names through one batch process, handles missing refs, and rejects unconsumed output.

Changes: Issue blob reading

Layer / File(s) Summary
Record parsing and missing-ref checks
crates/twigpine-node/src/git/issues.rs
read_batch_record consumes one batch record, validates its type, size, and trailing separator, and preserves remaining output. Both individual issue readers use it and check whether a ref still resolves when its record is missing.
Batched issue listing and coverage
crates/twigpine-node/src/git/issues.rs
list_issues validates enumerated refs and reads them in order through one cat-file --batch process. It skips refs that disappeared, errors if a missing record still resolves, and rejects extra output. Tests cover large and non-JSON contents, plus parsing a record after a missing record.

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

Change: Refactor

Sequence Diagram(s)

sequenceDiagram
  participant list_issues
  participant Git_for_each_ref
  participant Git_cat_file_batch
  participant read_batch_record
  list_issues->>Git_for_each_ref: enumerate issue refs
  Git_for_each_ref-->>list_issues: return ref names
  list_issues->>Git_cat_file_batch: send validated ref names
  Git_cat_file_batch-->>list_issues: return batch records
  list_issues->>read_batch_record: parse each record in order
  read_batch_record-->>list_issues: return body and remaining output
Loading

Possibly related PRs

Suggested labels: crate:node

Suggested reviewers: kevincodex1, jatmn

Merge Risk: Minimal · previous review 5455c

Issue listing now reads blobs through a single git cat-file --batch process while keeping the same output behavior, and the added tests pin exact output for large and non-JSON blobs. No defect was found in the changed file. The red CI jobs trace to compile errors in files this PR does not touch, which should clear once the separate fix (PR #643) lands.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "SWF(perf): batch git reads in issue listing" names the main change. The PR replaces one git cat-file --batch process per issue with a single batched process in list_issues, which the ti…
Description check Passed The description covers the core content of the template. The Summary and Motivation are present, with a clear problem statement and a benchmark. It describes the change, lists the touched file, and gi…
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 "SWF(perf): batch git reads in issue listing" names the main change. The PR replaces one git cat-file --batch process per issue with a single batched process in list_issues, which the title describes. The title is short and specific, uses a Conventional Commits-style scope, and does not list files.

Full details: Description check

Explanation

The description covers the core content of the template. The Summary and Motivation are present, with a clear problem statement and a benchmark. It describes the change, lists the touched file, and gives verification commands. It also explains the blocked workspace tests. Several template items are missing or unresolved: the Summary is merged into the opening paragraph, the "Closes #" issue link is empty, the Kind of change checkboxes are not ticked, the "What changed" section is a single prose paragraph rather than bullets with crate names, and the "Before you request review" checklist is not marked. The Protocol & signing block is not addressed, and the author does not say whether the cargo fmt and clippy checks pass. These gaps are non-critical, so the description is mostly complete.

Resolution

Optional improvements: fill in the "Closes #" issue reference or state that none exists, tick the Kind of change box (likely Refactor or Performance-related, though the template has no perf option), name the crate touched (twigpine-node) in the What changed section, and state whether cargo fmt and clippy pass for this change.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
Fix failing CI checks

  • 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: d6204a11-9a59-44c8-a5ff-4e617d52700b
Commits

Reviewing files that changed from the base of the PR and between 6168c55 and 5455c8a.

Files selected for processing: 1

  • crates/twigpine-node/src/git/issues.rs

Limit details: You’ve used the included review currently available.

@beardthelion
beardthelion requested a review from jatmn November 30, 2026 06:15

@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

Required Rust CI jobs (fmt + clippy, test (stable), build --release, MSRV) are failing on this head. The author attributes failures to workspace compile errors on current main (see #643), not to crates/twigpine-node/src/git/issues.rs. Merge remains BLOCKED until the workspace builds and required checks pass; treat failures as likely unrelated to this diff until PR 643 (or equivalent) lands and CI is green on a rebased head.

Closed duplicate PR 645 proposed the same batched listing change; 647 is the active line.

Auto-generated CodeRabbit release notes in the PR body contradict implementation (they claim JSON validation behavior this PR does not change). Safe to ignore for merge; avoid treating them as release truth.

@beardthelion
beardthelion added this pull request to the merge queue Dec 1, 2026
Merged via the queue into main with commit 732459f Dec 1, 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