GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — diff: speed up rename detection by doing cheaper exact matching first by AHSauge · Pull Request #7471 · libgit2/libgit2

Conversation

@AHSauge

@AHSauge AHSauge commented Nov 7, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

This PR is currently split in two commits, and the TL;DR is that this vastly improves rename detection performance for 'move without change' scenarios.

The first one extracts the code related to the label find_best_matches in git_diff_find_similar to a separate function. This should have zero behavioural changes.

The second commit add a round of cheaper exact matching before doing the existing inexact matching. The exact matching relies on comparing OIDs, and ignores opts->rename_limit since it's really cheap to run. Without having inspected the git CLI code, this seems to be the same behaviour. At the very least, it's able to find more renames than any numeric parameter provided in. Inexact matching still respects the limit though.

However, due to these changes, moving large amounts of files around are now correctly detected as renamed files. A user of Gittyup was pointing to https://codeberg.org/ArkyonVeil/HarkiusWars.Relic.Update/src/branch/GitStresser as a problematic repo demonstrating slow operations. This contains 4k+ files that are unchanged, but moved. Before, only opts->rename_limit number of renames were recognised, with the rest being add+delete pairs. With this fix, all 4k+ renames are recognised as such. On my machine running blame on any of these files has a 1000x performance improvement (~16ms instead of ~16 seconds).

Relates to #3027

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
AHSauge added 2 commits November 5, 2026 23:46
@AHSauge
diff: extract inexact rename matching into a separate function
fa743b5
This removes a backwards goto, and prepares the code to be more readable once
 exact matching is added
@AHSauge
diff: speed up rename detection by doing cheaper exact matching first
3173b7e
This also fixes an issue with large number of renames in a single diff not
being correctly detected as renames due to hitting opts->rename_limit.
Since OID matching can be done far faster, there is no need to limit comparing
in the exact matching loop.

Since there now is an exact match loop, GIT_DIFF_FIND_EXACT_MATCH_ONLY
now bypasses the inexact matching.
@AHSauge AHSauge mentioned this pull request Nov 7, 2026
git blame is slow #3027
Open

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@AHSauge
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.