Git 子模块命令在 Windows 10 上非常慢

Posted

技术标签:

【中文标题】Git 子模块命令在 Windows 10 上非常慢【英文标题】:Git submodule commands are very slow on Windows 10 【发布时间】:2021-02-01 00:26:15 【问题描述】:

Git submodule 命令在当前的 Windows 10 上非常慢(至少在使用 BitBucket 时,没有尝试过任何其他服务器)。

我有一个简单的 repo,其中包含一个包含 2 个小文本文件的子模块(整个子模块 repo 为 20kb)。如果我分别clone 两个 repos,我会在 1-5 秒内得到它们。

git submodule init 需要 ~5-10 秒。git submodule update 需要 ~2 分钟git submodule update --initgit submodule add https://bitbucket.org/... 显示相同的结果。@987654330 @flag 什么都不显示。

我尝试在pwsh(Windows 终端)和普通cmd 中运行它们,结果相同。 我试过 SSH 和 HTTPS。

我读过这个git submodule update is slow. How can I debug why it's slow? 我尝试了这里的命令Git submodule update slow on Windows

cmd /V /C "set GIT_TRACE2_PERF=C:/Users/me/log.perf&& git submodule update"

并得到了这个结果(删除了 2 列:1 列刚刚说 main 和另一列带有 dup 时间):

21:16:29.755412 common-main.c:48             | d0 | version      |     |           |              | 2.28.0.windows.1
21:16:29.756420 common-main.c:49             | d0 | start        |     |  0.035490 |              | git.exe submodule update
21:16:29.770717 ..._win32_process_info.c:118 | d0 | data_json    | r0  |  0.049596 | process      | windows/ancestry:["git.exe","cmd.exe","pwsh.exe","WindowsTerminal.exe","explorer.exe"]
21:16:29.771683 git.c:698                    | d0 | cmd_name     |     |           |              | _run_dashed_ (_run_dashed_)
21:16:29.772683 run-command.c:735            | d0 | child_start  |     |  0.051473 |              | [ch0] class:dashed argv:[git-submodule update]
21:16:44.141790 common-main.c:48             | d1 | version      |     |           |              | 2.28.0.windows.1
21:16:44.142817 common-main.c:49             | d1 | start        |     |  0.036516 |              | 'C:\Program Files\Git\mingw64\libexec\git-core\git.exe' --exec-path
21:16:44.163835 ..._win32_process_info.c:118 | d1 | data_json    | r0  |  0.057664 | process      | windows/ancestry:["sh.exe","sh.exe","sh.exe","git.exe","git.exe","cmd.exe","pwsh.exe","WindowsTerminal.exe","explorer.exe"]
21:16:44.163835 git.c:159                    | d1 | cmd_name     |     |           |              | _query_ (_run_dashed_/_query_)
21:16:44.163835 ..._win32_process_info.c:166 | d1 | data_json    | r0  |  0.058116 | process      | windows/memory:"PageFaultCount":9464,"PeakWorkingSetSize":7643136,"PeakPagefileUsage":3694592
21:16:44.163835 git.c:160                    | d1 | exit         |     |  0.058139 |              | code:0
21:16:44.163835 trace2/tr2_tgt_perf.c:213    | d1 | atexit       |     |  0.058152 |              | code:0
21:17:02.539359 common-main.c:48             | d1 | version      |     |           |              | 2.28.0.windows.1
21:17:02.540357 common-main.c:49             | d1 | start        |     |  0.049746 |              | 'C:\Program Files\Git\mingw64\libexec\git-core\git.exe' sh-i18n--envsubst --variables 'usage: $dashless $USAGE'
21:17:02.568368 ..._win32_process_info.c:118 | d1 | data_json    | r0  |  0.077844 | process      | windows/ancestry:["sh.exe","sh.exe","sh.exe","sh.exe","sh.exe","git.exe","git.exe","cmd.exe","pwsh.exe","WindowsTerminal.exe","(truncated)"]
21:17:02.570378 git.c:698                    | d1 | cmd_name     |     |           |              | _run_dashed_ (_run_dashed_/_run_dashed_)
21:17:02.570378 run-command.c:735            | d1 | child_start  |     |  0.080189 |              | [ch0] class:dashed argv:[git-sh-i18n--envsubst --variables 'usage: $dashless $USAGE']
21:17:02.649337 common-main.c:48             | d2 | version      |     |           |              | 2.28.0.windows.1
21:17:02.651034 common-main.c:49             | d2 | start        |     |  0.046435 |              | git-sh-i18n--envsubst --variables 'usage: $dashless $USAGE'
21:17:02.676042 ..._win32_process_info.c:118 | d2 | data_json    | r0  |  0.072334 | process      | windows/ancestry:["git.exe","sh.exe","sh.exe","sh.exe","sh.exe","sh.exe","git.exe","git.exe","cmd.exe","pwsh.exe","(truncated)"]
21:17:02.677049 sh-i18n--envsubst.c:71       | d2 | cmd_name     |     |           |              | sh-i18n--envsubst (_run_dashed_/_run_dashed_/sh-i18n--envsubst)
21:17:02.677049 ..._win32_process_info.c:166 | d2 | data_json    | r0  |  0.072955 | process      | windows/memory:"PageFaultCount":9935,"PeakWorkingSetSize":7585792,"PeakPagefileUsage":3579904
21:17:02.677049 sh-i18n--envsubst.c:112      | d2 | exit         |     |  0.072989 |              | code:0
21:17:02.677049 trace2/tr2_tgt_perf.c:213    | d2 | atexit       |     |  0.073002 |              | code:0
21:17:02.681054 run-command.c:990            | d1 | child_exit   |     |  0.191162 |              | [ch0] pid:25708 code:0
21:17:02.682046 ..._win32_process_info.c:166 | d1 | data_json    | r0  |  0.191827 | process      | windows/memory:"PageFaultCount":9888,"PeakWorkingSetSize":7647232,"PeakPagefileUsage":3702784
21:17:02.682046 git.c:720                    | d1 | exit         |     |  0.191901 |              | code:0
21:17:02.682046 trace2/tr2_tgt_perf.c:213    | d1 | atexit       |     |  0.191942 |              | code:0
21:17:04.796883 common-main.c:48             | d1 | version      |     |           |              | 2.28.0.windows.1
21:17:04.797907 common-main.c:49             | d1 | start        |     |  0.039257 |              | 'C:\Program Files\Git\mingw64\libexec\git-core\git.exe' sh-i18n--envsubst 'usage: $dashless $USAGE'
21:17:04.819927 ..._win32_process_info.c:118 | d1 | data_json    | r0  |  0.061218 | process      | windows/ancestry:["sh.exe","sh.exe","sh.exe","sh.exe","git.exe","git.exe","cmd.exe","pwsh.exe","WindowsTerminal.exe","explorer.exe","(truncated)"]
21:17:04.821156 git.c:698                    | d1 | cmd_name     |     |           |              | _run_dashed_ (_run_dashed_/_run_dashed_)
21:17:04.821156 run-command.c:735            | d1 | child_start  |     |  0.062881 |              | [ch0] class:dashed argv:[git-sh-i18n--envsubst 'usage: $dashless $USAGE']
21:17:04.884374 common-main.c:48             | d2 | version      |     |           |              | 2.28.0.windows.1
21:17:04.884374 common-main.c:49             | d2 | start        |     |  0.037532 |              | git-sh-i18n--envsubst 'usage: $dashless $USAGE'
21:17:04.906374 ..._win32_process_info.c:118 | d2 | data_json    | r0  |  0.059654 | process      | windows/ancestry:["git.exe","sh.exe","sh.exe","sh.exe","sh.exe","git.exe","git.exe","cmd.exe","pwsh.exe","WindowsTerminal.exe","(truncated)"]
21:17:04.907374 sh-i18n--envsubst.c:71       | d2 | cmd_name     |     |           |              | sh-i18n--envsubst (_run_dashed_/_run_dashed_/sh-i18n--envsubst)
21:17:04.907374 ..._win32_process_info.c:166 | d2 | data_json    | r0  |  0.060129 | process      | windows/memory:"PageFaultCount":9842,"PeakWorkingSetSize":7614464,"PeakPagefileUsage":3596288
21:17:04.907374 sh-i18n--envsubst.c:112      | d2 | exit         |     |  0.060156 |              | code:0
21:17:04.907374 trace2/tr2_tgt_perf.c:213    | d2 | atexit       |     |  0.060171 |              | code:0
21:17:04.909410 run-command.c:990            | d1 | child_exit   |     |  0.151444 |              | [ch0] pid:19968 code:0
21:17:04.910465 ..._win32_process_info.c:166 | d1 | data_json    | r0  |  0.151876 | process      | windows/memory:"PageFaultCount":9505,"PeakWorkingSetSize":7655424,"PeakPagefileUsage":3694592
21:17:04.910465 git.c:720                    | d1 | exit         |     |  0.151945 |              | code:0
21:17:04.910465 trace2/tr2_tgt_perf.c:213    | d1 | atexit       |     |  0.151989 |              | code:0
21:17:15.186324 common-main.c:48             | d1 | version      |     |           |              | 2.28.0.windows.1
21:17:15.187272 common-main.c:49             | d1 | start        |     |  0.034928 |              | 'C:\Program Files\Git\mingw64\libexec\git-core\git.exe' rev-parse --git-dir
21:17:15.208271 ..._win32_process_info.c:118 | d1 | data_json    | r0  |  0.055569 | process      | windows/ancestry:["sh.exe","sh.exe","sh.exe","git.exe","git.exe","cmd.exe","pwsh.exe","WindowsTerminal.exe","explorer.exe"]
21:17:15.208271 git.c:445                    | d1 | cmd_name     |     |           |              | rev-parse (_run_dashed_/rev-parse)
21:17:15.209664 repository.c:134             | d1 | def_repo     | r1  |           |              | worktree:C:/work/repos/test/api-template
21:17:15.210099 ..._win32_process_info.c:166 | d1 | data_json    | r1  |  0.057842 | process      | windows/memory:"PageFaultCount":9505,"PeakWorkingSetSize":7639040,"PeakPagefileUsage":3690496
21:17:15.210099 git.c:675                    | d1 | exit         |     |  0.057867 |              | code:0
21:17:15.211106 trace2/tr2_tgt_perf.c:213    | d1 | atexit       |     |  0.057883 |              | code:0
21:17:21.377950 common-main.c:48             | d1 | version      |     |           |              | 2.28.0.windows.1
21:17:21.378952 common-main.c:49             | d1 | start        |     |  0.035100 |              | 'C:\Program Files\Git\mingw64\libexec\git-core\git.exe' rev-parse --git-path objects
21:17:21.401951 ..._win32_process_info.c:118 | d1 | data_json    | r0  |  0.058018 | process      | windows/ancestry:["sh.exe","sh.exe","sh.exe","git.exe","git.exe","cmd.exe","pwsh.exe","WindowsTerminal.exe","explorer.exe"]
21:17:21.401951 git.c:445                    | d1 | cmd_name     |     |           |              | rev-parse (_run_dashed_/rev-parse)
21:17:21.402950 repository.c:134             | d1 | def_repo     | r1  |           |              | worktree:C:/work/repos/test/api-template
21:17:21.403950 ..._win32_process_info.c:166 | d1 | data_json    | r1  |  0.060304 | process      | windows/memory:"PageFaultCount":9505,"PeakWorkingSetSize":7643136,"PeakPagefileUsage":3694592
21:17:21.403950 git.c:675                    | d1 | exit         |     |  0.060327 |              | code:0
21:17:21.403950 trace2/tr2_tgt_perf.c:213    | d1 | atexit       |     |  0.060339 |              | code:0
21:17:25.560719 common-main.c:48             | d1 | version      |     |           |              | 2.28.0.windows.1
21:17:25.560719 common-main.c:49             | d1 | start        |     |  0.036064 |              | 'C:\Program Files\Git\mingw64\libexec\git-core\git.exe' rev-parse -q --git-dir
21:17:25.581725 ..._win32_process_info.c:118 | d1 | data_json    | r0  |  0.056848 | process      | windows/ancestry:["sh.exe","sh.exe","sh.exe","git.exe","git.exe","cmd.exe","pwsh.exe","WindowsTerminal.exe","explorer.exe"]
21:17:25.581725 git.c:445                    | d1 | cmd_name     |     |           |              | rev-parse (_run_dashed_/rev-parse)
21:17:25.582726 repository.c:134             | d1 | def_repo     | r1  |           |              | worktree:C:/work/repos/test/api-template
21:17:25.583726 ..._win32_process_info.c:166 | d1 | data_json    | r1  |  0.059098 | process      | windows/memory:"PageFaultCount":9507,"PeakWorkingSetSize":7647232,"PeakPagefileUsage":3694592
21:17:25.583726 git.c:675                    | d1 | exit         |     |  0.059122 |              | code:0
21:17:25.583726 trace2/tr2_tgt_perf.c:213    | d1 | atexit       |     |  0.059133 |              | code:0
21:17:29.712244 common-main.c:48             | d1 | version      |     |           |              | 2.28.0.windows.1
21:17:29.712244 common-main.c:49             | d1 | start        |     |  0.033477 |              | 'C:\Program Files\Git\mingw64\libexec\git-core\git.exe' rev-parse --is-inside-work-tree
21:17:29.733278 ..._win32_process_info.c:118 | d1 | data_json    | r0  |  0.054172 | process      | windows/ancestry:["sh.exe","sh.exe","sh.exe","git.exe","git.exe","cmd.exe","pwsh.exe","WindowsTerminal.exe","explorer.exe"]
21:17:29.733278 git.c:445                    | d1 | cmd_name     |     |           |              | rev-parse (_run_dashed_/rev-parse)
21:17:29.734278 repository.c:134             | d1 | def_repo     | r1  |           |              | worktree:C:/work/repos/test/api-template
21:17:29.735842 ..._win32_process_info.c:166 | d1 | data_json    | r1  |  0.056295 | process      | windows/memory:"PageFaultCount":9488,"PeakWorkingSetSize":7573504,"PeakPagefileUsage":3657728
21:17:29.735842 git.c:675                    | d1 | exit         |     |  0.056318 |              | code:0
21:17:29.735842 trace2/tr2_tgt_perf.c:213    | d1 | atexit       |     |  0.056330 |              | code:0
21:17:31.830544 common-main.c:48             | d1 | version      |     |           |              | 2.28.0.windows.1
21:17:31.831594 common-main.c:49             | d1 | start        |     |  0.036763 |              | 'C:\Program Files\Git\mingw64\libexec\git-core\git.exe' rev-parse --show-prefix
21:17:31.849588 ..._win32_process_info.c:118 | d1 | data_json    | r0  |  0.055489 | process      | windows/ancestry:["sh.exe","sh.exe","git.exe","git.exe","cmd.exe","pwsh.exe","WindowsTerminal.exe","explorer.exe"]
21:17:31.850579 git.c:445                    | d1 | cmd_name     |     |           |              | rev-parse (_run_dashed_/rev-parse)
21:17:31.851475 repository.c:134             | d1 | def_repo     | r1  |           |              | worktree:C:/work/repos/test/api-template
21:17:31.852166 ..._win32_process_info.c:166 | d1 | data_json    | r1  |  0.057811 | process      | windows/memory:"PageFaultCount":8766,"PeakWorkingSetSize":7634944,"PeakPagefileUsage":3690496
21:17:31.852166 git.c:675                    | d1 | exit         |     |  0.057834 |              | code:0
21:17:31.852166 trace2/tr2_tgt_perf.c:213    | d1 | atexit       |     |  0.057846 |              | code:0
21:17:33.965947 common-main.c:48             | d1 | version      |     |           |              | 2.28.0.windows.1
21:17:33.965947 common-main.c:49             | d1 | start        |     |  0.037985 |              | 'C:\Program Files\Git\mingw64\libexec\git-core\git.exe' rev-parse --show-toplevel
21:17:33.984986 ..._win32_process_info.c:118 | d1 | data_json    | r0  |  0.056903 | process      | windows/ancestry:["sh.exe","sh.exe","git.exe","git.exe","cmd.exe","pwsh.exe","WindowsTerminal.exe","explorer.exe"]
21:17:33.984986 git.c:445                    | d1 | cmd_name     |     |           |              | rev-parse (_run_dashed_/rev-parse)
21:17:33.986529 repository.c:134             | d1 | def_repo     | r1  |           |              | worktree:C:/work/repos/test/api-template
21:17:33.986904 ..._win32_process_info.c:166 | d1 | data_json    | r1  |  0.059073 | process      | windows/memory:"PageFaultCount":8761,"PeakWorkingSetSize":7634944,"PeakPagefileUsage":3694592
21:17:33.986904 git.c:675                    | d1 | exit         |     |  0.059096 |              | code:0
21:17:33.987913 trace2/tr2_tgt_perf.c:213    | d1 | atexit       |     |  0.059111 |              | code:0
21:17:46.255798 common-main.c:48             | d1 | version      |     |           |              | 2.28.0.windows.1
21:17:46.255798 common-main.c:49             | d1 | start        |     |  0.036220 |              | 'C:\Program Files\Git\mingw64\libexec\git-core\git.exe' submodule--helper update-clone --
21:17:46.275839 ..._win32_process_info.c:118 | d1 | data_json    | r0  |  0.056313 | process      | windows/ancestry:["sh.exe","sh.exe","sh.exe","git.exe","git.exe","cmd.exe","pwsh.exe","WindowsTerminal.exe","explorer.exe"]
21:17:46.277436 repository.c:134             | d1 | def_repo     | r1  |           |              | worktree:C:/work/repos/test/api-template
21:17:46.277436 git.c:445                    | d1 | cmd_name     |     |           |              | submodule--helper (_run_dashed_/submodule--helper)
21:17:46.279459 read-cache.c:2315            | d1 | region_enter | r1  |  0.059520 | index        | label:do_read_index .git/index
21:17:46.279459 read-cache.c:2275            | d1 | data         | r1  |  0.059771 | index        | ..read/version:2
21:17:46.279459 read-cache.c:2277            | d1 | data         | r1  |  0.059807 | index        | ..read/cache_nr:89
21:17:46.279459 read-cache.c:2320            | d1 | region_leave | r1  |  0.059821 | index        | label:do_read_index .git/index
21:17:46.279459 run-command.c:1858           | d1 | region_enter |     |  0.059842 | submodule    | label:parallel/update max:1
21:17:46.280443 run-command.c:1864           | d1 | region_leave |     |  0.060144 | submodule    | label:parallel/update
21:17:46.280443 ..._win32_process_info.c:166 | d1 | data_json    | r1  |  0.060496 | process      | windows/memory:"PageFaultCount":9550,"PeakWorkingSetSize":7655424,"PeakPagefileUsage":3706880
21:17:46.280443 git.c:675                    | d1 | exit         |     |  0.060519 |              | code:0
21:17:46.280443 trace2/tr2_tgt_perf.c:213    | d1 | atexit       |     |  0.060531 |              | code:0
21:17:48.385295 common-main.c:48             | d1 | version      |     |           |              | 2.28.0.windows.1
21:17:48.386329 common-main.c:49             | d1 | start        |     |  0.034577 |              | 'C:\Program Files\Git\mingw64\libexec\git-core\git.exe' submodule--helper ensure-core-worktree api-configs
21:17:48.408296 ..._win32_process_info.c:118 | d1 | data_json    | r0  |  0.057052 | process      | windows/ancestry:["sh.exe","sh.exe","sh.exe","git.exe","git.exe","cmd.exe","pwsh.exe","WindowsTerminal.exe","explorer.exe"]
21:17:48.410313 repository.c:134             | d1 | def_repo     | r1  |           |              | worktree:C:/work/repos/test/api-template
21:17:48.411294 git.c:445                    | d1 | cmd_name     |     |           |              | submodule--helper (_run_dashed_/submodule--helper)
21:17:48.412306 read-cache.c:2315            | d1 | region_enter | r1  |  0.060851 | index        | label:do_read_index .git/index
21:17:48.412306 read-cache.c:2275            | d1 | data         | r1  |  0.061108 | index        | ..read/version:2
21:17:48.412306 read-cache.c:2277            | d1 | data         | r1  |  0.061128 | index        | ..read/cache_nr:89
21:17:48.412306 read-cache.c:2320            | d1 | region_leave | r1  |  0.061143 | index        | label:do_read_index .git/index
21:17:48.414294 repository.c:134             | d1 | def_repo     | r2  |           |              | worktree:C:/work/repos/test/api-template/api-configs
21:17:48.415807 ..._win32_process_info.c:166 | d1 | data_json    | r1  |  0.064903 | process      | windows/memory:"PageFaultCount":9546,"PeakWorkingSetSize":7639040,"PeakPagefileUsage":3694592
21:17:48.415807 git.c:675                    | d1 | exit         |     |  0.064926 |              | code:0
21:17:48.416807 trace2/tr2_tgt_perf.c:213    | d1 | atexit       |     |  0.064941 |              | code:0
21:17:50.520402 common-main.c:48             | d1 | version      |     |           |              | 2.28.0.windows.1
21:17:50.520402 common-main.c:49             | d1 | start        |     |  0.034157 |              | 'C:\Program Files\Git\mingw64\libexec\git-core\git.exe' submodule--helper update-module-mode 0 api-configs
21:17:50.541436 ..._win32_process_info.c:118 | d1 | data_json    | r0  |  0.054575 | process      | windows/ancestry:["sh.exe","sh.exe","sh.exe","git.exe","git.exe","cmd.exe","pwsh.exe","WindowsTerminal.exe","explorer.exe"]
21:17:50.542528 repository.c:134             | d1 | def_repo     | r1  |           |              | worktree:C:/work/repos/test/api-template
21:17:50.542923 git.c:445                    | d1 | cmd_name     |     |           |              | submodule--helper (_run_dashed_/submodule--helper)
21:17:50.543931 read-cache.c:2315            | d1 | region_enter | r1  |  0.056926 | index        | label:do_read_index .git/index
21:17:50.543931 read-cache.c:2275            | d1 | data         | r1  |  0.057075 | index        | ..read/version:2
21:17:50.543931 read-cache.c:2277            | d1 | data         | r1  |  0.057095 | index        | ..read/cache_nr:89
21:17:50.543931 read-cache.c:2320            | d1 | region_leave | r1  |  0.057108 | index        | label:do_read_index .git/index
21:17:50.543931 ..._win32_process_info.c:166 | d1 | data_json    | r1  |  0.057631 | process      | windows/memory:"PageFaultCount":9527,"PeakWorkingSetSize":7634944,"PeakPagefileUsage":3682304
21:17:50.543931 git.c:675                    | d1 | exit         |     |  0.057655 |              | code:0
21:17:50.543931 trace2/tr2_tgt_perf.c:213    | d1 | atexit       |     |  0.057689 |              | code:0
21:17:52.636205 common-main.c:48             | d1 | version      |     |           |              | 2.28.0.windows.1
21:17:52.637203 common-main.c:49             | d1 | start        |     |  0.037411 |              | 'C:\Program Files\Git\mingw64\libexec\git-core\git.exe' submodule--helper relative-path api-configs ''
21:17:52.658176 ..._win32_process_info.c:118 | d1 | data_json    | r0  |  0.059121 | process      | windows/ancestry:["sh.exe","sh.exe","sh.exe","git.exe","git.exe","cmd.exe","pwsh.exe","WindowsTerminal.exe","explorer.exe"]
21:17:52.659209 repository.c:134             | d1 | def_repo     | r1  |           |              | worktree:C:/work/repos/test/api-template
21:17:52.660211 git.c:445                    | d1 | cmd_name     |     |           |              | submodule--helper (_run_dashed_/submodule--helper)
21:17:52.661210 ..._win32_process_info.c:166 | d1 | data_json    | r1  |  0.061740 | process      | windows/memory:"PageFaultCount":9494,"PeakWorkingSetSize":7639040,"PeakPagefileUsage":3686400
21:17:52.661210 git.c:675                    | d1 | exit         |     |  0.061763 |              | code:0
21:17:52.661210 trace2/tr2_tgt_perf.c:213    | d1 | atexit       |     |  0.061775 |              | code:0
21:17:58.826520 common-main.c:48             | d1 | version      |     |           |              | 2.28.0.windows.1
21:17:58.827518 common-main.c:49             | d1 | start        |     |  0.033724 |              | 'C:\Program Files\Git\mingw64\libexec\git-core\git.exe' rev-parse --local-env-vars
21:17:58.850518 ..._win32_process_info.c:118 | d1 | data_json    | r0  |  0.057204 | process      | windows/ancestry:["sh.exe","sh.exe","sh.exe","sh.exe","sh.exe","git.exe","git.exe","cmd.exe","pwsh.exe","WindowsTerminal.exe","(truncated)"]
21:17:58.850518 git.c:445                    | d1 | cmd_name     |     |           |              | rev-parse (_run_dashed_/rev-parse)
21:17:58.850518 ..._win32_process_info.c:166 | d1 | data_json    | r0  |  0.057584 | process      | windows/memory:"PageFaultCount":9842,"PeakWorkingSetSize":7647232,"PeakPagefileUsage":3694592
21:17:58.850518 git.c:675                    | d1 | exit         |     |  0.057607 |              | code:0
21:17:58.850518 trace2/tr2_tgt_perf.c:213    | d1 | atexit       |     |  0.057619 |              | code:0
21:18:00.947362 common-main.c:48             | d1 | version      |     |           |              | 2.28.0.windows.1
21:18:00.948397 common-main.c:49             | d1 | start        |     |  0.036498 |              | 'C:\Program Files\Git\mingw64\libexec\git-core\git.exe' rev-parse --verify HEAD
21:18:00.968407 ..._win32_process_info.c:118 | d1 | data_json    | r0  |  0.056906 | process      | windows/ancestry:["sh.exe","sh.exe","sh.exe","sh.exe","git.exe","git.exe","cmd.exe","pwsh.exe","WindowsTerminal.exe","explorer.exe","(truncated)"]
21:18:00.968407 git.c:445                    | d1 | cmd_name     |     |           |              | rev-parse (_run_dashed_/rev-parse)
21:18:00.970614 repository.c:134             | d1 | def_repo     | r1  |           |              | worktree:C:/work/repos/test/api-template/api-configs
21:18:00.972622 ..._win32_process_info.c:166 | d1 | data_json    | r1  |  0.060950 | process      | windows/memory:"PageFaultCount":9506,"PeakWorkingSetSize":7634944,"PeakPagefileUsage":3682304
21:18:00.972622 git.c:675                    | d1 | exit         |     |  0.060976 |              | code:0
21:18:00.972622 trace2/tr2_tgt_perf.c:213    | d1 | atexit       |     |  0.060989 |              | code:0
21:18:00.982622 run-command.c:990            | d0 | child_exit   |     | 91.261384 |              | [ch0] pid:19900 code:0
21:18:00.982622 ..._win32_process_info.c:166 | d0 | data_json    | r0  | 91.261700 | process      | windows/memory:"PageFaultCount":6578,"PeakWorkingSetSize":7618560,"PeakPagefileUsage":3678208
21:18:00.982622 git.c:720                    | d0 | exit         |     | 91.261723 |              | code:0
21:18:00.982622 trace2/tr2_tgt_perf.c:213    | d0 | atexit       |     | 91.261737 |              | code:0

我不知道该怎么做。有人遇到过类似的事情并有解决办法吗?有关如何解决它的任何建议?

有时它会输出错误但无论如何操作都会成功,例如

❯ git submodule update
      0 [main] sh 2038 child_info::sync: wait failed, pid 18572, Win32 error 0
    997 [main] sh 2038 dofork: child -1 - forked process 18572 died unexpectedly, retry 0, exit code 0x8, errno 11
C:/Program Files/Git/mingw64/libexec/git-core\git-submodule: fork: retry: Resource temporarily unavailable
Cloning into 'C:/work/repos/test/api-template/api-configs'...
Submodule path 'api-configs': checked out '1a61134f804c0bd2d6f8a7ccf848136f7bf02309'

如果我在 WSL 中运行相同的命令,它们几乎会立即运行。 我的一些同事报告了同样的问题。他们说 Windows 重新启动通常会提供暂时的缓解。对我来说没有任何帮助。

Windows 10

❯ git version
git version 2.28.0.windows.1

WSL 2 (Ubuntu 18.04)

$ git version
git version 2.28.0

【问题讨论】:

更新到 git 2.29 并且它的工作时间一样长。 这通常是由系统上的防病毒或安全软件引起的。尝试完全卸载该软件并重新启动。 Windows Defender 不应导致此问题。 我们的系统由我们的管理员管理。没有机会修改任何安全内容。再一次,git clone 在 Win 上的两个 repos 上都能快速运行。 git submodule update 本质上是 git clone。这些命令会立即在 WSL 上运行,WSL 是同一个 Windows 会话的一部分,并且必须通过同一个网络。 【参考方案1】:

git submodule 主要用 shell 编写。 Shell 脚本通过 fork 和执行大量进程来工作,这在 Windows 上很慢,因为 Windows 没有一种有效的方法来 fork 进程。

如果您有任何进程(例如防病毒软件或其他安全软件)使这些操作变慢,那么,它们会变得更慢。其中一些进程还会窥探每个网络连接并对其进行检查,从而导致网络连接变慢。

您看不到 WSL 2 的速度下降,因为 WSL 2 本质上是一个运行真正 Linux 内核的虚拟机。因此,它在分叉和执行进程方面非常快,并且通常不会受到 Windows 防病毒或安全软件的窥探或拦截。

我的建议是完全卸载任何第三方防病毒或安全软件,重新启动,然后改用 Windows Defender 和 Windows 防火墙。第三方防病毒软件经常将代码注入每个进程,通过将每个进程暴露于同一组不安全代码,从而大大削弱了安全性。此外,它经常破坏沙盒技术,这些技术可用于防止 Chrome 等软件中的漏洞利用。如果这不可行,那么您可能不得不接受这样一个事实,即在 Windows 上性能不会很好。

【讨论】:

作为一项测试,我们禁用了所有我们可以禁用的东西(防火墙、Windows Defender、Webroot,这是我们的防病毒软件),它仍在运行 ~2 分钟。可能还有其他安全流程,但可能需要永远追查所有流程。 但有趣的是,一台配备 i9 和 32 Gb RAM 的机器,可以立即运行其他所有内容,在一些简单的 CLI 命令上会阻塞并冻结几分钟(!),需要拉20kb 的文本。【参考方案2】:

解决方法。 对于具有pwsh core 用户和WSL 2 启用的Windows Terminal,您可以将以下函数添加到您的Microsoft.PowerShell_profile.ps1。它通常位于C:\Users\<user_name>\Documents\PowerShell

function git() 
    if ($args[0] -eq 'submodule') 
        wsl git $args
    
    else 
        git.exe $args
    

在 CMD 或任何其他终端中运行任何带有 wsl 前缀的 submodule 命令:

wsl git submodule update

【讨论】:

以上是关于Git 子模块命令在 Windows 10 上非常慢的主要内容,如果未能解决你的问题,请参考以下文章

git中submodule子模块的添加使用和删除

git中submodule子模块的添加使用和删除

PhpStorm、Windows 10 PowerShell 和 Git 命令

Git修改子模块的路径

Git子模块添加:“在本地找到一个git目录”问题

git进阶