WIP: allow use of modification times to speed up equals function in merkletrie diff #1694
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.
For my application i rely heavily on the speed of git status, I noticed that go-git does not use modification times where upstream git would do so for a git status. I noticed a large performance discrepancy between the mentioned application using -go-git, and a roughly 30 line bash script using upstream
gitwhich should be doing the functional equivalent.Depending on the size of the files in a worktree, the use of modtimes instead of rehashing everything results in substantial time savings.
The existing benchmark for git status, with a rather trivial size for a repo, already shows a ~6x performance increase. I expect this performance increase to be larger with larger repo's.
With this change applied:
Basically this change first checks if modification time is the same between the index and the worktree, if not proceed as usual by rehashing, if the same, mark as equal.
This could well be very naive and some expert review is needed. Note that this 'fasthpath' would become the default when doing a
worktree.Status(). Another option would be to introduce anOptionforStatus(...).