Search code examples
gitwindows-10git-bashmintty

Windows10 GitBash hanging for about five minutes on commit: is this normal?


My GitBash's version is 2.36.1
My Mintty's version is 3.6.1 (x86_64-pc-msys) [Windows 19044]

My GitBash's Mintty terminal hung for about five minutes on commit upon running the following:

<user> <path> (master)
$ git add .

<user> <path> (master)
$ git commit -m "..."
Auto packing the repository in background for optimum performance.
See "git help gc" for manual housekeeping.
Enumerating objects: 384, done.
Counting objects: 100% (17/17), done.
Delta compression using up to 4 threads
Compressing objects: 100% (16/16), done.
Writing objects: 100% (17/17), done.
Total 17 (delta 4), reused 0 (delta 0), pack-reused 0
Removing duplicate objects: 100% (256/256), done.

Here it hung for about five minutes.
It had never done that previously.
Is this normally possible or am I probably doing something wrong (and, if yes, what and how to correct it)?

EDIT: .git folder's hooks: my .git folder hooks

EDIT 3: removed EDIT 2 which showed trace2 logs upon a "git status" command, in EDIT 3 I publish trace2 logs upon my latest "git commit":

commit -m <my message>
d0 | main                     | data_json    | r0  |  0.036147 |  0.036147 | process      | windows/ancestry:["bash.exe","bash.exe"]
d0 | main                     | def_repo     | r1  |           |           |              | worktree:'<my path>'
d0 | main                     | cmd_name     |     |           |           |              | commit (commit)
d0 | main                     | region_enter | r1  |  0.112412 |           | index        | label:do_read_index .git/index
d0 | main                     | region_enter | r1  |  0.114001 |           | cache_tree   | ..label:read
d0 | main                     | region_leave | r1  |  0.114116 |  0.000115 | cache_tree   | ..label:read
d0 | main                     | data         | r1  |  0.114183 |  0.001771 | index        | ..read/version:2
d0 | main                     | data         | r1  |  0.114214 |  0.001802 | index        | ..read/cache_nr:401
d0 | main                     | region_leave | r1  |  0.114240 |  0.001828 | index        | label:do_read_index .git/index
d0 | main                     | region_enter |     |  0.115291 |           | index        | label:refresh
d0 | main                     | data         |     |  0.118960 |  0.003669 | index        | ..refresh/sum_lstat:401
d0 | main                     | data         |     |  0.119016 |  0.003725 | index        | ..refresh/sum_scan:0
d0 | main                     | region_leave |     |  0.119039 |  0.003748 | index        | label:refresh
d0 | main                     | region_enter | r1  |  0.226613 |           | unpack_trees | label:unpack_trees
d0 | main                     | region_enter | r1  |  0.227008 |           | unpack_trees | ..label:traverse_trees
d0 | main                     | region_leave | r1  |  0.227473 |  0.000465 | unpack_trees | ..label:traverse_trees
d0 | main                     | region_leave | r1  |  0.228410 |  0.001797 | unpack_trees | label:unpack_trees
d0 | main                     | region_enter | r1  |  0.228996 |           | diff         | label:setup
d0 | main                     | region_leave | r1  |  0.229037 |  0.000041 | diff         | label:setup
d0 | main                     | region_enter | r1  |  0.229053 |           | diff         | label:write back to queue
d0 | main                     | region_leave | r1  |  0.229067 |  0.000014 | diff         | label:write back to queue
d0 | main                     | region_enter | r1  |  0.254939 |           | status       | label:worktrees
d0 | main                     | region_enter | r1  |  0.255650 |           | diff         | ..label:setup
d0 | main                     | region_leave | r1  |  0.255705 |  0.000055 | diff         | ..label:setup
d0 | main                     | region_enter | r1  |  0.255731 |           | diff         | ..label:write back to queue
d0 | main                     | region_leave | r1  |  0.255752 |  0.000021 | diff         | ..label:write back to queue
d0 | main                     | region_leave | r1  |  0.255774 |  0.000835 | status       | label:worktrees
d0 | main                     | region_enter | r1  |  0.255795 |           | status       | label:index
d0 | main                     | region_enter | r1  |  0.256585 |           | unpack_trees | ..label:unpack_trees
d0 | main                     | region_enter | r1  |  0.256929 |           | unpack_trees | ....label:traverse_trees
d0 | main                     | region_leave | r1  |  0.256993 |  0.000064 | unpack_trees | ....label:traverse_trees
d0 | main                     | region_leave | r1  |  0.257023 |  0.000438 | unpack_trees | ..label:unpack_trees
d0 | main                     | region_enter | r1  |  0.257040 |           | diff         | ..label:setup
d0 | main                     | region_leave | r1  |  0.257053 |  0.000013 | diff         | ..label:setup
d0 | main                     | region_enter | r1  |  0.257066 |           | diff         | ..label:write back to queue
d0 | main                     | region_leave | r1  |  0.257079 |  0.000013 | diff         | ..label:write back to queue
d0 | main                     | region_leave | r1  |  0.257093 |  0.001298 | status       | label:index
d0 | main                     | region_enter | r1  |  0.257114 |           | status       | label:untracked
d0 | main                     | region_enter | r1  |  0.257441 |           | dir          | ..label:read_directory
d0 | main                     | region_enter | r1  |  0.257591 |           | index        | ....label:name-hash-init
d0 | main                     | region_leave | r1  |  0.257678 |  0.000087 | index        | ....label:name-hash-init
d0 | main                     | data         | r1  |  0.259703 |  0.002262 | read_directo | ....path:
d0 | main                     | data         | r1  |  0.259737 |  0.002296 | read_directo | ....directories-visited:29
d0 | main                     | data         | r1  |  0.259753 |  0.002312 | read_directo | ....paths-visited:454
d0 | main                     | region_leave | r1  |  0.259766 |  0.002325 | dir          | ..label:read_directory
d0 | main                     | region_leave | r1  |  0.259782 |  0.002668 | status       | label:untracked
d0 | main                     | data         | r1  |  0.260047 |  0.260047 | status       | count/changed:0
d0 | main                     | data         | r1  |  0.260069 |  0.260069 | status       | count/untracked:0
d0 | main                     | data         | r1  |  0.260083 |  0.260083 | status       | count/ignored:0
d0 | main                     | region_enter | r1  |  0.260096 |           | status       | label:print
d0 | main                     | region_leave | r1  |  0.262113 |  0.002017 | status       | label:print
d0 | main                     | data         | r1  |  0.262167 |  0.262167 | fsync        | fsync/writeout-only:0
d0 | main                     | data         | r1  |  0.262183 |  0.262183 | fsync        | fsync/hardware-flush:0
d0 | main                     | data_json    | r1  |  0.262521 |  0.262521 | process      | windows/memory:{"PageFaultCount":5233,"PeakWorkingSetSize":9674752,"PeakPagefileUsage":7364608}
d0 | main                     | exit         |     |  0.262553 |           |              | code:1
d0 | main                     | data_json    | r1  |  0.262570 |  0.262570 | traverse_tre | statistics:{"traverse_trees_count":2,"traverse_trees_max_depth":1}
d0 | main                     | atexit       |     |  0.262588 |           |              | code:1
d0 | main                     | version      |     |           |           |              | 2.36.1.windows.1
d0 | main                     | start        |     |  0.012317 |           |              | 'C:\Program Files\Git\mingw64\bin\git.exe' rev-parse --git-dir --is-inside-git-dir --is-bare-repository --is-inside-work-tree --short HEAD
d0 | main                     | data_json    | r0  |  0.052169 |  0.052169 | process      | windows/ancestry:["bash.exe","bash.exe","bash.exe","bash.exe"]
d0 | main                     | cmd_name     |     |           |           |              | rev-parse (rev-parse)
d0 | main                     | def_repo     | r1  |           |           |              | worktree:'<my path>'
d0 | main                     | data         | r1  |  0.065587 |  0.065587 | fsync        | fsync/writeout-only:0
d0 | main                     | data         | r1  |  0.065763 |  0.065763 | fsync        | fsync/hardware-flush:0
d0 | main                     | data_json    | r1  |  0.066035 |  0.066035 | process      | windows/memory:{"PageFaultCount":5960,"PeakWorkingSetSize":7704576,"PeakPagefileUsage":5218304}
d0 | main                     | exit         |     |  0.066077 |           |              | code:0
d0 | main                     | atexit       |     |  0.066102 |           |              | code:0
d0 | main                     | version      |     |           |           |              | 2.36.1.windows.1
d0 | main                     | start        |     |  0.011809 |           |              | 'C:\Program Files\Git\mingw64\bin\git.exe' config --bool core.sparseCheckout
d0 | main                     | data_json    | r0  |  0.053999 |  0.053999 | process      | windows/ancestry:["bash.exe","bash.exe","bash.exe","bash.exe"]
d0 | main                     | def_repo     | r1  |           |           |              | worktree:'<my path>'
d0 | main                     | cmd_name     |     |           |           |              | config (config)
d0 | main                     | data         | r1  |  0.058257 |  0.058257 | fsync        | fsync/writeout-only:0
d0 | main                     | data         | r1  |  0.058297 |  0.058297 | fsync        | fsync/hardware-flush:0
d0 | main                     | data_json    | r1  |  0.058552 |  0.058552 | process      | windows/memory:{"PageFaultCount":5874,"PeakWorkingSetSize":7675904,"PeakPagefileUsage":3547136}
d0 | main                     | exit         |     |  0.058593 |           |              | code:1
d0 | main                     | atexit       |     |  0.058619 |           |              | code:1
d0 | main                     | version      |     |           |           |              | 2.36.1.windows.1
d0 | main                     | start        |     |  0.012306 |           |              | 'C:\Program Files\Git\mingw64\bin\git.exe'

Is there anything abnormal here? Thanks!


Solution

  • This can be perfectly normal. The clue is in this line (and what comes after it):

    Auto packing the repository in background for optimum performance.
    

    As is very well put in this answer, some Git commands (including git commit since Git 2.17) invoke git gc --auto. When there are enough loose objects (this builds up over time, when you use git), this command will start packing those loose objects. This is done to have some lightweight garbage collection from time to time (see the git-scm docs on this as well).

    The amount of time this takes is dependent on which operations you recently did, and which type of objects live inside of your git repo.

    I would say: Let the packing finish properly and don't worry too much about this. After this you should be able to use Git like you're used to. This automatic garbage collection only happens from time to time.

    Hope this helps!