Skip to content

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

Closed
beardthelion wants to merge 1 commit into
mainfrom
devin/1796015646-batch-issue-listing
Closed

beardthelion wants to merge 1 commit into
mainfrom
devin/1796015646-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
    • Improved reliability when reading individual issues and issue lists, including when referenced issues disappear during retrieval.
    • Issue lists now preserve ordering and handle large issue contents correctly.
    • Invalid or incomplete issue data is handled more consistently.

@coderabbitai

coderabbitai Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Issue blob reads now consume and validate records from cat-file --batch. list_issues sends validated refs through one batch process, preserves their order, skips refs that disappeared, and rejects inconsistent or extra output. Tests cover large bodies, invalid JSON, and missing records.

Changes: Issue Batch Reading

Layer / File(s) Summary
Parse batch records
crates/twigpine-node/src/git/issues.rs
A shared parser consumes one batch record, checks its blob type, body length, and separator, and recognizes missing-ref records. Both single-issue readers use it and recheck refs when a record is missing.
Read issue lists in batches
crates/twigpine-node/src/git/issues.rs
list_issues validates refs and reads them through one cat-file --batch process. It preserves listing order, skips refs that disappeared, errors when a missing ref still resolves, and rejects extra output. Tests cover missing records, ordering, and large issue bodies.

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

Change: Refactor

Sequence Diagram(s)

sequenceDiagram
  participant list_issues
  participant Git
  participant cat_file as cat-file --batch
  participant read_batch_record
  list_issues->>Git: Validate and enumerate issue refs
  list_issues->>cat_file: Submit refs
  cat_file-->>list_issues: Return batch output
  loop For each listed ref
    list_issues->>read_batch_record: Parse next record
    read_batch_record-->>list_issues: Return body or missing record
    opt Record is missing
      list_issues->>Git: Recheck ref
      Git-->>list_issues: Return ref resolution
    end
  end
Loading

Possibly related PRs

  • Twigpine/node#437: It defines overlapping missing-ref and unreadable-object behavior for read_issue_blob and list_issues.

Suggested labels: crate:node, kind:perf

Suggested reviewers: kevincodex1, jatmn

Merge Risk: Minimal · up to 5455c

This change makes issue listing much faster by reading all issues through one Git process instead of one process per issue. Output and error handling for missing or malformed issues are meant to stay the same. No concrete defects were found in the reviewed code, and the targeted tests reportedly pass, so merge risk is minimal.

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: list_issues now submits all refs to one git cat-file --batch process instead of one process per issue. It is specific, co…
Description check Passed The description covers the required sections. It has a summary (the performance problem and fix), motivation context (the per-issue fork cost), what changed (only issues.rs, one batch process), and a …
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: list_issues now submits all refs to one git cat-file --batch process instead of one process per issue. It is specific, concise, and matches the summary and objectives. The title is in Conventional Commit-style form with a scope, which is a minor style point and does not affect the verdict.

Full details: Description check

Explanation

The description covers the required sections. It has a summary (the performance problem and fix), motivation context (the per-issue fork cost), what changed (only issues.rs, one batch process), and a verification section with a runnable test command and a benchmark. It also states behavior is unchanged and explains what was not tested. Gaps against the template: no 'Closes #' issue link is given, the 'Kind of change' checkboxes are not ticked (the change is a performance change, so 'Refactor (no behavior change)' or similar is unmarked), the crate name is noted only by path, the 'Before you request review' checklist is not filled in, and the 'Protocol & signing impact' block is absent (it may be deleted if it does not apply). These are non-critical, so the description 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

Usage-based review receipt

Note

This review was completed with usage-based billing: files reviewed beyond your plan's included limits are billed at $0.25/file. View usage-based billing.

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: f42604ed-0379-4bb9-b445-669511f27895
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 deleted the devin/1796015646-batch-issue-listing branch November 30, 2026 06:02
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.

1 participant