Skip to content

Object walk painting#1973

Merged
pjbgf merged 1 commit into
go-git:mainfrom
stiak:object-walk-painting
Apr 14, 2026
Merged

Object walk painting#1973
pjbgf merged 1 commit into
go-git:mainfrom
stiak:object-walk-painting

Conversation

@stiak

@stiak stiak commented Apr 9, 2026

Copy link
Copy Markdown
Contributor

After some of the changes to #1947, the performance gains weren't realised.

This PR restores the performance gains while still maintaining correctness (mainly the commit time ordering issue).

  • TestRevListObjects_SkewedCommitTimesDoNotResendCommonBase Maintained. The painting commits approach deals with out of order commit times.

Two other tests were changed to match git rev-list behaviour:

  • TestRevListObjects_ReintroducedBlobInHaveAncestorIsExcluded became TestRevListObjects_ReintroducedBlobInHaveAncestor and verified behaviour against a call to git rev-list.
  • TestRevListObjects_MissingHaveAncestorReturnsError became TestRevListObjects_MissingHaveAncestorIsTolerated, verified with a call to git rev-list.

Performance summary (Objects is this PR):

  ┌───────────┬───────────────┬───────────────┬───────────────┐                                                                                                                                                                  
  │   Case    │  ObjectsOld   │    Objects    │  ObjectsTopo  │                                                                                                                                                                  
  ├───────────┼───────────────┼───────────────┼───────────────┤                                                                                                                                                                  
  │ Full walk │ 553ms / 169MB │ 381ms / 136MB │ 561ms / 198MB │                                                                                                                                                                  
  ├───────────┼───────────────┼───────────────┼───────────────┤                                                                                                                                                                  
  │ Diff walk │ 390ms / 145MB │ 75ms / 30MB   │ 51ms / 18MB   │                                                                                                                                                                  
  └───────────┴───────────────┴───────────────┴───────────────┘   

Copilot AI review requested due to automatic review settings April 9, 2026 01:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the revlist.Objects() traversal to restore previously achieved performance improvements while maintaining correctness in the presence of out-of-order commit times, and aligns a couple of edge-case tests with git rev-list --objects behavior.

Changes:

  • Reworks the object walk commit traversal to use a “painted” (want/have flags) priority-queue style walk with early stopping.
  • Updates/renames regression tests to compare object sets directly against git rev-list --objects for specific edge cases.
  • Refactors some test helpers for building commits/trees across different storers (in-memory vs on-disk fixtures).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.

File Description
plumbing/revlist/object_walk.go Replaces the interleaved want/have walk with a painted, time-prioritized traversal and adds helpers for sorted insertion / stale detection.
plumbing/revlist/revlist_test.go Updates regression tests (including comparisons to git rev-list --objects) and refactors commit/tree construction helpers.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread plumbing/revlist/revlist_test.go Outdated
Comment thread plumbing/revlist/revlist_test.go Outdated
Comment thread plumbing/revlist/object_walk.go
Comment thread plumbing/revlist/object_walk.go
Comment thread plumbing/revlist/object_walk.go
Comment thread plumbing/revlist/object_walk.go
@stiak stiak force-pushed the object-walk-painting branch 3 times, most recently from 5601c61 to 83d1695 Compare April 9, 2026 01:27
Comment thread plumbing/revlist/revlist_test.go
Comment thread plumbing/revlist/object_walk.go
{Name: "have", Mode: filemode.Regular, Hash: s.makeBlob("have")},
// gitRevListObjects runs git rev-list --objects want ^have against the
// given git directory and returns the set of object hashes.
func gitRevListObjects(t *testing.T, gitDir string, want, have plumbing.Hash) map[plumbing.Hash]bool {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this is brilliant, for this package we are probably better off:

  • Making a single table driven test with all current scenarios
  • Match execution failure with expected errors from Objects()
  • Match the actual objects

This way we have a few different repos with a given set of scenarios, and we can match implementation conformance more easily.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Should we tackle that in this PR or a separate one?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

On a separate one is fine. 👍

@stiak stiak force-pushed the object-walk-painting branch from d4d01e6 to 10d5287 Compare April 13, 2026 23:51
Also updates and expands tests to capture more git rev-list behaviour

Assisted-by: Claude Opus 4.6 (1M context) <[email protected]>
@stiak stiak force-pushed the object-walk-painting branch from 10d5287 to fe32f7a Compare April 13, 2026 23:52

@pjbgf pjbgf left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@stiak thanks for working on this. 🙇

@pjbgf pjbgf merged commit cddbbe4 into go-git:main Apr 14, 2026
16 checks passed
@stiak stiak deleted the object-walk-painting branch April 14, 2026 23:00
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.

3 participants