Skip to content

mingw: improve performance of mingw_unlink()#2589

Merged
jeffhostetler merged 1 commit into
git-for-windows:masterfrom
jeffhostetler:unlink-perf-gfw
Apr 20, 2020
Merged

mingw: improve performance of mingw_unlink()#2589
jeffhostetler merged 1 commit into
git-for-windows:masterfrom
jeffhostetler:unlink-perf-gfw

Conversation

@jeffhostetler
Copy link
Copy Markdown

@jeffhostetler jeffhostetler commented Apr 17, 2020

Update mingw_unlink() to first try to delete the file with existing
permissions before trying to force it.

Windows throws an error when trying to delete a read-only file. The
mingw_unlink() compatibility wrapper always tries to _wchmod(666) the
file before calling _wunlink() to avoid that error. However, since
most files in the worktree are already writable, this is usually
wasted effort.

Update mingw_unlink() to just call DeleteFileW() directly and if that
succeeds return. If that fails, fall back into the existing code path
to update the permissions and use _wunlink() to get the existing
error code mapping.

Signed-off-by: Jeff Hostetler jeffhost@microsoft.com

Update mingw_unlink() to first try to delete the file with existing
permissions before trying to force it.

Windows throws an error when trying to delete a read-only file.  The
mingw_unlink() compatibility wrapper always tries to _wchmod(666) the
file before calling _wunlink() to avoid that error.  However, since
most files in the worktree are already writable, this is usually
wasted effort.

Update mingw_unlink() to just call DeleteFileW() directly and if that
succeeds return.  If that fails, fall back into the existing code path
to update the permissions and use _wunlink() to get the existing
error code mapping.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
Copy link
Copy Markdown
Member

@dscho dscho left a comment

Choose a reason for hiding this comment

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

I like it! :shipit:

@dscho
Copy link
Copy Markdown
Member

dscho commented Apr 18, 2020

I'd like to submit this directly upstream via GGG after we've had a
chance to review it and avoid the technical debt.

@jeffhostetler I think we should do both. Are you totally opposed to having it in Git for Windows early? It's such a trivial patch, it will be simply skipped from the rebase once it arrives in any official Git version.

@jeffhostetler
Copy link
Copy Markdown
Author

@dscho I’m ok with including in both. i was just trying to not cause you more work later. i’ll update and merge this and send one to GGG and the list on monday. thanks.

@dscho
Copy link
Copy Markdown
Member

dscho commented Apr 18, 2020

Excellent!

@derrickstolee
Copy link
Copy Markdown

@jeffhostetler any reason you didn't create a PR against vfs-2.26.1 in microsoft/git? I could generate an installer and run it through some perf tests that way.

@jeffhostetler jeffhostetler changed the title [DO NOT MERGE] mingw: improve performance of mingw_unlink() mingw: improve performance of mingw_unlink() Apr 20, 2020
@jeffhostetler
Copy link
Copy Markdown
Author

@derrickstolee I'll merge this into GFW as is. Then cherry-pick it into vfs so we can test it there. And then send a patch to the mailing list via GGG.

@jeffhostetler jeffhostetler merged commit 06995d4 into git-for-windows:master Apr 20, 2020
dscho added a commit to git-for-windows/build-extra that referenced this pull request Apr 20, 2020
Worktree updates (e.g. `git checkout`, `git
reset --hard`) [got a performance boost in sparse
checkouts](git-for-windows/git#2589).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
git-for-windows-ci pushed a commit that referenced this pull request Apr 20, 2020
mingw: improve performance of mingw_unlink()
git-for-windows-ci pushed a commit that referenced this pull request Apr 20, 2020
mingw: improve performance of mingw_unlink()
git-for-windows-ci pushed a commit that referenced this pull request Apr 20, 2020
mingw: improve performance of mingw_unlink()
derrickstolee pushed a commit to microsoft/git that referenced this pull request Apr 20, 2020
…f-gfw

mingw: improve performance of mingw_unlink()
git-for-windows-ci pushed a commit that referenced this pull request Apr 21, 2020
mingw: improve performance of mingw_unlink()
dscho pushed a commit that referenced this pull request Apr 21, 2020
mingw: improve performance of mingw_unlink()
git-for-windows-ci pushed a commit that referenced this pull request May 1, 2020
mingw: improve performance of mingw_unlink()
git-for-windows-ci pushed a commit that referenced this pull request May 1, 2020
mingw: improve performance of mingw_unlink()
git-for-windows-ci pushed a commit that referenced this pull request May 1, 2020
mingw: improve performance of mingw_unlink()
git-for-windows-ci pushed a commit that referenced this pull request May 3, 2020
mingw: improve performance of mingw_unlink()
git-for-windows-ci pushed a commit that referenced this pull request May 6, 2020
mingw: improve performance of mingw_unlink()
git-for-windows-ci pushed a commit that referenced this pull request May 7, 2020
mingw: improve performance of mingw_unlink()
git-for-windows-ci pushed a commit that referenced this pull request May 8, 2020
mingw: improve performance of mingw_unlink()
dscho pushed a commit that referenced this pull request May 8, 2020
mingw: improve performance of mingw_unlink()
dscho pushed a commit that referenced this pull request May 8, 2020
mingw: improve performance of mingw_unlink()
git-for-windows-ci pushed a commit that referenced this pull request May 9, 2020
mingw: improve performance of mingw_unlink()
git-for-windows-ci pushed a commit that referenced this pull request May 9, 2020
mingw: improve performance of mingw_unlink()
git-for-windows-ci pushed a commit that referenced this pull request May 9, 2020
mingw: improve performance of mingw_unlink()
git-for-windows-ci pushed a commit that referenced this pull request May 10, 2020
mingw: improve performance of mingw_unlink()
git-for-windows-ci pushed a commit that referenced this pull request May 10, 2020
mingw: improve performance of mingw_unlink()
git-for-windows-ci pushed a commit that referenced this pull request May 11, 2020
mingw: improve performance of mingw_unlink()
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