Git submodule commands are very slow on Windows 10

1.2k views Asked by At

Git submodule commands are very slow on current Windows 10 (at least when working with BitBucket, have not tried any other server).

I have a simple repo with a single submodule in it that contains 2 small text files (the whole submodule repo is 20kb). If I clone both repos individually I get them in 1-5 secs.

git submodule init takes ~5-10 seconds.
git submodule update takes ~2 minutes.
git submodule update --init and git submodule add https://bitbucket.org/... show same result.
--progress flag shows nothing.

I tried running them in pwsh (Windows Terminal) and in plain cmd with same result.
I tried SSH and HTTPS.

I've read this git submodule update is slow. How can I debug why it's slow?
I tried the command from here Git submodule update slow on Windows

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

and got this result (removed 2 columns: 1 that just said main and another with dup times):

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

I'm not sure what to make of it. Did someone experience something similar and had a fix? Any suggestions on how to troubleshoot it?

Sometimes it outputs errors but the operation succeeds anyway, e.g.

❯ 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'

If I run same commands in WSL they run almost instantly.
A few of my co-workers reported same problem. They say a Windows reboot usually provides a temporary relief. Nothing helps in my case.

Windows 10

❯ git version
git version 2.28.0.windows.1

WSL 2 (Ubuntu 18.04)

$ git version
git version 2.28.0
2

There are 2 answers

2
bk2204 On

git submodule is written mostly in shell. Shell scripts work by forking and execing a large number of processes, and this is slow on Windows because Windows does not have an efficient way to fork a process.

If you have any process, such as an antivirus or other security software, which makes those operations slower, then, well, they'll be even slower. Some of those processes also snoop every network connection and inspect it, making network connections slow as well.

You don't see a slowdown in WSL 2 because WSL 2 is essentially a virtual machine running a real Linux kernel. As such, it is very fast at forking and execing processes and it is not generally subject to snooping or interception by Windows antivirus or security software.

My recommendation is to completely uninstall any third-party antivirus or security software, reboot, and use Windows Defender and Windows Firewall instead. Third-party antivirus often injects code into every process which considerably weakens security by exposing every process to the same set of insecure code. In addition, it often breaks sandboxing techniques which can be used to prevent exploits in software like Chrome. If that's not possible, then you'll probably have to live with the fact that things aren't going to perform well on Windows.

0
iseiryu On

Workaround.
For the Windows Terminal with pwsh core users and WSL 2 enabled you can add the following function to your Microsoft.PowerShell_profile.ps1. It's usually located at C:\Users\<user_name>\Documents\PowerShell.

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

In CMD or any other terminal run any submodule commands with wsl prefix:

wsl git submodule update