Skip to content

perf(list): batch commit subjects with timestamps pre-skeleton - #2369

Merged
max-sixty merged 1 commit into
mainfrom
batch-commit-details
Apr 22, 2026
Merged

max-sixty merged 1 commit into
mainfrom
batch-commit-details

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

The pre-skeleton git log --no-walk call already fetched timestamps for sorting. It now also fetches subjects (via %H\0%ct\0%s) and primes cache.commit_details, so post-skeleton CommitDetailsTask is a pure cache hit instead of N git log -1 forks (one per unique SHA across worktrees/branches/remotes).

Subject bytes ride along for free — git has to resolve each commit object anyway, and empirical skeleton latency is unchanged (34.1ms vs 33.9ms, σ~1ms across 90+ runs). The single-shot commit_details() path is also canonicalized to the same NUL format so both paths write byte-identical cache entries.

Verified via trace log: a single batched git log --no-walk runs pre-skeleton; zero git log -1 forks appear in the post-skeleton hot path.

This was written by Claude Code on behalf of Maximilian Roos

The pre-skeleton `git log --no-walk` call already fetched timestamps
for sorting. It now also fetches subjects (via `%H\0%ct\0%s`) and
primes `cache.commit_details`, so post-skeleton `CommitDetailsTask`
is a pure cache hit instead of N `git log -1` forks (one per unique
SHA across worktrees/branches/remotes).

Subject bytes ride along for free — git has to resolve each commit
object anyway, and empirical skeleton latency is unchanged (34.1ms
vs 33.9ms, σ~1ms, 90+ runs). Also canonicalizes the single-shot
`commit_details()` path to the same NUL format so both paths write
byte-identical cache entries.

Co-Authored-By: Claude <[email protected]>
@max-sixty
max-sixty merged commit bfeb527 into main Apr 22, 2026
25 checks passed
@max-sixty
max-sixty deleted the batch-commit-details branch April 22, 2026 01:23
max-sixty added a commit that referenced this pull request Apr 22, 2026
…many (#2373)

Fills in two gaps flagged in review of #2369 — tests only, no changes to
`diff.rs`.

- `commit_details_many_preserves_multibyte_utf8_subject` — pins that
`"Add support for 日本語 and émoji 🎉"` round-trips through the
NUL-delimited `splitn(3, '\0')` parser.
- `commit_details_many_deduplicates_repeated_sha` — pins that git's
`--no-walk` dedupe on a repeated input SHA surfaces as one map entry and
one cache entry, so a future git change or refactor can't silently
regress it.

> _This was written by Claude Code on behalf of Maximilian_

Co-authored-by: Claude <[email protected]>
max-sixty added a commit that referenced this pull request Apr 22, 2026
Now that the pre-skeleton `commit_details_many` batch fetches
`(timestamp, subject)` for every item SHA (PR #2369),
`CommitDetailsTask` has been a pure DashMap lookup wrapped in rayon
spawn + channel send + drain match — pure overhead per item. Drop the
task type and populate `ListItem.commit` from the batch map directly in
the post-skeleton phase.

## Scope

- Remove `CommitDetailsTask` / `TaskKind::CommitDetails` /
`TaskResult::CommitDetails` and their drain + dispatch + seeding
plumbing.
- Sort helpers (`sort_by_timestamp_desc_with_cache`,
`sort_worktrees_with_cache`) now accept the full `&HashMap<String, (i64,
String)>` — single canonical source.
- Post-skeleton loop writes `item.commit` from the batch map directly.
`populate_item()` (the statusline single-item entry point) also does its
own one-SHA `commit_details_many` lookup so `wt statusline
--format=json` keeps reporting real `commit.message` /
`commit.timestamp`.
- Drop the old silent fallback: on batch failure, the task used to fork
`git log -1` per-SHA via `Repository::commit_details()`. The `collect()`
path now prints a loud warning on batch failure and renders placeholders
for that run. `populate_item()` is silent on failure — the statusline
has no UI for warnings.
- Dead-code cleanup: `Repository::commit_details()` (singular), the
`RepoCache::commit_details` DashMap field, the cache-priming side effect
inside `commit_details_many`, and the circular
`commit_details_and_many_store_identical_cache_entries` test.

## What stays

- Batch parser tests (spaces, multibyte UTF-8, duplicate SHAs, empty
input, unknown-SHA error propagation) still cover `commit_details_many`
directly.
- Prunable worktrees are still skipped so Age/Message render `·` —
preserves the old task-queue UX for items whose directory is missing
from disk.

## What's unchanged

- Skeleton latency: no pre-skeleton additions.
- `wt list` display: all snapshot tests pass.
- `batch_ahead_behind` / `ahead_behind()` fallback: kept — that's
version-compat for git < 2.36, not error-recovery.

## Codecov

`codecov/patch` reports 90.90% — below the 96.63% target. The ~5
uncovered lines are the "fail loudly" batch-error warning path in
`collect()` and the `bail!` for malformed git output in
`commit_details_many`. Driving those from an integration test would
require a pathological repo setup; the unit-test
`commit_details_many_fails_loudly_on_unknown_sha` pins the contract the
warning path depends on. Merging with explicit approval.

> _This was written by Claude Code on behalf of max-sixty_

---------

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
Co-authored-by: worktrunk-bot <[email protected]>
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