git-for-windows / git

A fork of Git containing Windows-specific patches.
http://gitforwindows.org/
Other
8.38k stars 2.54k forks source link

git.exe and many other apps do not have the Terminal Server aware flag set #3935

Closed ElemenTP closed 2 years ago

ElemenTP commented 2 years ago

Setup

$ git --version --build-options

git version 2.37.0.windows.1
cpu: x86_64
built from commit: 989c3a6832b035f6124b0a23da9c0f8f18afa550
sizeof-long: 4
sizeof-size_t: 8
shell-path: /bin/sh
feature: fsmonitor--daemon
$ cmd.exe /c ver

Microsoft Windows [Version 10.0.22621.105]
Editor Option: VisualStudioCode
Custom Editor Path:
Default Branch Option:
Path Option: Cmd
SSH Option: ExternalOpenSSH
Tortoise Option: false
CURL Option: WinSSL
CRLF Option: CRLFAlways
Bash Terminal Option: ConHost
Git Pull Behavior Option: Merge
Use Credential Manager: Enabled
Performance Tweaks FSCache: Enabled
Enable Symlinks: Disabled
Enable Pseudo Console Support: Enabled
Enable FSMonitor: Disabled

none

Details

Terminal Server aware is an optional flag in the PE header.

According to the doc by Microsoft Create Terminal Server aware application, when loading an application with no Terminal Server aware flag, Terminal Server will do extra work(makes loading slower). This behavior is for compatibility with very old applications. Microsoft 's toolchain has made this flag set for every app by default for a long time.

I use a script and MSVC dumpbin util to check every .exe file in git for windows folder, finding git.exe and many bundled applications do not have Terminal Server aware flag set. They are in the list below. (By the way, the little program here https://github.com/git-for-windows/git/issues/644 is also a good choice to check this flag)

D:\Program Files\Git\git-bash.exe
D:\Program Files\Git\git-cmd.exe
D:\Program Files\Git\bin\bash.exe
D:\Program Files\Git\bin\git.exe
D:\Program Files\Git\bin\sh.exe
D:\Program Files\Git\cmd\git-gui.exe
D:\Program Files\Git\cmd\git-lfs.exe
D:\Program Files\Git\cmd\git.exe
D:\Program Files\Git\cmd\gitk.exe
D:\Program Files\Git\mingw64\bin\acountry.exe
D:\Program Files\Git\mingw64\bin\adig.exe
D:\Program Files\Git\mingw64\bin\ahost.exe
D:\Program Files\Git\mingw64\bin\antiword.exe
D:\Program Files\Git\mingw64\bin\blocked-file-util.exe
D:\Program Files\Git\mingw64\bin\brotli.exe
D:\Program Files\Git\mingw64\bin\bunzip2.exe
D:\Program Files\Git\mingw64\bin\bzcat.exe
D:\Program Files\Git\mingw64\bin\bzip2.exe
D:\Program Files\Git\mingw64\bin\bzip2recover.exe
D:\Program Files\Git\mingw64\bin\connect.exe
D:\Program Files\Git\mingw64\bin\create-shortcut.exe
D:\Program Files\Git\mingw64\bin\curl.exe
D:\Program Files\Git\mingw64\bin\edit_test.exe
D:\Program Files\Git\mingw64\bin\edit_test_dll.exe
D:\Program Files\Git\mingw64\bin\envsubst.exe
D:\Program Files\Git\mingw64\bin\gettext.exe
D:\Program Files\Git\mingw64\bin\git-askpass.exe
D:\Program Files\Git\mingw64\bin\git-askyesno.exe
D:\Program Files\Git\mingw64\bin\git-credential-helper-selector.exe
D:\Program Files\Git\mingw64\bin\git-receive-pack.exe
D:\Program Files\Git\mingw64\bin\git-upload-archive.exe
D:\Program Files\Git\mingw64\bin\git-upload-pack.exe
D:\Program Files\Git\mingw64\bin\git.exe
D:\Program Files\Git\mingw64\bin\lzmadec.exe
D:\Program Files\Git\mingw64\bin\lzmainfo.exe
D:\Program Files\Git\mingw64\bin\odt2txt.exe
D:\Program Files\Git\mingw64\bin\openssl.exe
D:\Program Files\Git\mingw64\bin\p11-kit.exe
D:\Program Files\Git\mingw64\bin\pdftotext.exe
D:\Program Files\Git\mingw64\bin\pkcs1-conv.exe
D:\Program Files\Git\mingw64\bin\proxy-lookup.exe
D:\Program Files\Git\mingw64\bin\sexp-conv.exe
D:\Program Files\Git\mingw64\bin\tclsh.exe
D:\Program Files\Git\mingw64\bin\tclsh86.exe
D:\Program Files\Git\mingw64\bin\trust.exe
D:\Program Files\Git\mingw64\bin\unxz.exe
D:\Program Files\Git\mingw64\bin\WhoUses.exe
D:\Program Files\Git\mingw64\bin\wish.exe
D:\Program Files\Git\mingw64\bin\wish86.exe
D:\Program Files\Git\mingw64\bin\x86_64-w64-mingw32-agrep.exe
D:\Program Files\Git\mingw64\bin\x86_64-w64-mingw32-deflatehd.exe
D:\Program Files\Git\mingw64\bin\x86_64-w64-mingw32-inflatehd.exe
D:\Program Files\Git\mingw64\bin\xmlcatalog.exe
D:\Program Files\Git\mingw64\bin\xmllint.exe
D:\Program Files\Git\mingw64\bin\xmlwf.exe
D:\Program Files\Git\mingw64\bin\xz.exe
D:\Program Files\Git\mingw64\bin\xzcat.exe
D:\Program Files\Git\mingw64\bin\xzdec.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-add.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-am.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-annotate.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-apply.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-archive.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-bisect--helper.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-blame.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-branch.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-bugreport.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-bundle.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-cat-file.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-check-attr.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-check-ignore.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-check-mailmap.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-check-ref-format.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-checkout--worker.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-checkout-index.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-checkout.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-cherry-pick.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-cherry.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-clean.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-clone.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-column.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-commit-graph.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-commit-tree.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-commit.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-config.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-count-objects.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-credential-cache--daemon.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-credential-cache.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-credential-store.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-credential-wincred.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-credential.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-daemon.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-describe.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-diff-files.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-diff-index.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-diff-tree.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-diff.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-difftool.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-env--helper.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-fast-export.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-fast-import.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-fetch-pack.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-fetch.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-fmt-merge-msg.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-for-each-ref.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-for-each-repo.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-format-patch.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-fsck-objects.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-fsck.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-fsmonitor--daemon.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-gc.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-get-tar-commit-id.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-grep.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-hash-object.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-help.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-hook.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-http-backend.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-http-fetch.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-http-push.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-imap-send.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-index-pack.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-init-db.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-init.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-interpret-trailers.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-log.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-ls-files.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-ls-remote.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-ls-tree.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-mailinfo.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-mailsplit.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-maintenance.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-merge-base.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-merge-file.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-merge-index.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-merge-ours.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-merge-recursive.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-merge-subtree.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-merge-tree.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-merge.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-mktag.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-mktree.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-multi-pack-index.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-mv.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-name-rev.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-notes.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-pack-objects.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-pack-redundant.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-pack-refs.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-patch-id.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-prune-packed.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-prune.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-pull.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-push.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-range-diff.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-read-tree.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-rebase.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-receive-pack.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-reflog.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-remote-ext.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-remote-fd.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-remote-ftp.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-remote-ftps.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-remote-http.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-remote-https.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-remote.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-repack.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-replace.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-rerere.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-reset.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-restore.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-rev-list.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-rev-parse.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-revert.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-rm.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-send-pack.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-sh-i18n--envsubst.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-shortlog.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-show-branch.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-show-index.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-show-ref.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-show.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-sparse-checkout.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-stage.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-stash.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-status.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-stripspace.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-submodule--helper.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-switch.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-symbolic-ref.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-tag.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-unpack-file.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-unpack-objects.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-update-index.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-update-ref.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-update-server-info.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-upload-archive.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-upload-pack.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-var.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-verify-commit.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-verify-pack.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-verify-tag.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-whatchanged.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-worktree.exe
D:\Program Files\Git\mingw64\libexec\git-core\git-write-tree.exe
D:\Program Files\Git\mingw64\libexec\git-core\git.exe
D:\Program Files\Git\mingw64\libexec\git-core\headless-git.exe
D:\Program Files\Git\mingw64\libexec\p11-kit\p11-kit-remote.exe
D:\Program Files\Git\mingw64\libexec\p11-kit\p11-kit-server.exe
D:\Program Files\Git\mingw64\share\git\compat-bash.exe
D:\Program Files\Git\mingw64\share\git\edit-git-bash.exe
D:\Program Files\Git\mingw64\share\git\git-wrapper.exe
D:\Program Files\Git\usr\bin\cygcheck.exe
D:\Program Files\Git\usr\bin\cygwin-console-helper.exe
D:\Program Files\Git\usr\bin\ldh.exe
D:\Program Files\Git\usr\bin\strace.exe
D:\Program Files\Git\usr\bin\winpty-agent.exe
D:\Program Files\Git\usr\bin\winpty-debugserver.exe
D:\Program Files\Git\usr\libexec\getprocaddr32.exe
D:\Program Files\Git\usr\libexec\getprocaddr64.exe

Some most used applications(git.exe, sh.exe, curl.exe, etc) do not have Terminal Server aware flag set, I think it will improve the performance of git for windows if we can set that flag of those apps.

For a mingw linker like git for windows is using, specifing --tsaware to the linker(-Wl,--tsaware) will get the work done. I have tested this with building aria2, but I havn't tried with git for windows yet.

PhilipOakley commented 2 years ago

Aside: Many of the .exe files are just hard links back to the core git.exe, so task might not be as large as may be thought. See the Git-for-Windows FAQ

dscho commented 2 years ago

I plan on merging this today, after building a new perl package (and all the dependent packages).

rimrul commented 2 years ago

Please note that my two PRs should significantly shorten the long list above, but won't fix all entries.

I haven't gotten around to starting on PRs for MINGW-Pacakges, MSYS2-Packages and Git LFS.

dscho commented 2 years ago

Please note that my two PRs should significantly shorten the long list above, but won't fix all entries.

In the context of Git for Windows, I think it should be good enough to focus on the git-* executables.