2016-05-30 19 views
29

Sulla mia macchina windows git stash ha circa 3,5 secondi di overhead su ogni invocazione, che aggiunge circa 7 secondi al mio hook di commit git.git stash è lento su Windows

Lo stesso comando in linux (stessa macchina) richiede circa 0,01 secondi. Il problema di prestazioni si applica anche ai repository vuoti.

Ho provato quanto segue dal this thread e this thread:

  • core.fscache è impostato su true
  • core.preloadindex è impostato su true
  • gc.auto è impostato su 256
  • Impostazione PS1 = '$'
  • Correre cmd in administratio Modalità n
  • esecuzione all'interno cmd.exe invece di git-bash

Esecuzione GIT_TRACE=true git stash list

16:58:16.844591 git.c:563    trace: exec: 'git-stash' 'list' 
16:58:16.844591 run-command.c:336  trace: run_command: 'git-stash' 'list' 
16:58:19.699591 git.c:350    trace: built-in: git 'rev-parse' '--git-dir' 
16:58:19.859591 git.c:350    trace: built-in: git 'rev-parse' '--git-path' 'objects' 
16:58:20.069591 git.c:350    trace: built-in: git 'rev-parse' '--show-toplevel' 
16:58:20.154591 git.c:350    trace: built-in: git 'rev-parse' '--git-path' 'index' 
16:58:20.244591 git.c:350    trace: built-in: git 'config' '--get-colorbool' 'color.interactive' 
16:58:20.334591 git.c:350    trace: built-in: git 'config' '--get-color' 'color.interactive.help' 'red bold' 
16:58:20.424591 git.c:350    trace: built-in: git 'config' '--get-color' '' 'reset' 
16:58:20.514591 git.c:350    trace: built-in: git 'rev-parse' '--verify' '--quiet' 'refs/stash' 

real 0m3.845s 
user 0m0.000s 
sys  0m0.047s 

Esecuzione GIT_TRACE_PERFORMANCE=true git stash list

16:59:18.414591 trace.c:420    performance: 0.001078046 s: git command: 'C:\Program Files\Git\mingw64\libexec\git-core\git.exe' 'rev-parse' '--git-dir'           
16:59:18.569591 trace.c:420    performance: 0.000947184 s: git command: 'C:\Program Files\Git\mingw64\libexec\git-core\git.exe' 'rev-parse' '--git-path' 'objects'        
16:59:18.779591 trace.c:420    performance: 0.001253627 s: git command: 'C:\Program Files\Git\mingw64\libexec\git-core\git.exe' 'rev-parse' '--show-toplevel'          
16:59:18.869591 trace.c:420    performance: 0.001285517 s: git command: 'C:\Program Files\Git\mingw64\libexec\git-core\git.exe' 'rev-parse' '--git-path' 'index'         
16:59:18.955591 trace.c:420    performance: 0.001139994 s: git command: 'C:\Program Files\Git\mingw64\libexec\git-core\git.exe' 'config' '--get-colorbool' 'color.interactive'     
16:59:19.040591 trace.c:420    performance: 0.001182881 s: git command: 'C:\Program Files\Git\mingw64\libexec\git-core\git.exe' 'config' '--get-color' 'color.interactive.help' 'red bold'  
16:59:19.125591 trace.c:420    performance: 0.001128997 s: git command: 'C:\Program Files\Git\mingw64\libexec\git-core\git.exe' 'config' '--get-color' '' 'reset'         
16:59:19.215591 trace.c:420    performance: 0.001567766 s: git command: 'C:\Program Files\Git\mingw64\libexec\git-core\git.exe' 'rev-parse' '--verify' '--quiet' 'refs/stash'      
16:59:19.295591 trace.c:420    performance: 3.730583540 s: git command: 'C:\Program Files\Git\mingw64\bin\git.exe' 'stash' 'list'                 

real 0m3.819s                                               
user 0m0.000s                                               
sys  0m0.062s                                               

Dal registro vediamo che ci vogliono circa 3 secondi tra il comando git-stash viene eseguito e git-rev-parse viene eseguito. Ci sono altre bandiere che posso eseguire per trovare il collo di bottiglia?

+0

E 'possibile il repository è grande, si potrebbe provare a lanciare 'git gc' sul repository locale e remota? – Flows

+0

Richiede lo stesso tempo in un repository vuoto. Ho aggiornato la domanda. – sighol

+0

@sighol hai passato [questo thread] (http://stackoverflow.com/questions/4485059/git-bash-is-extremely-slow-in-windows-7-x64) e testato [questo suggerimento] (http : //stackoverflow.com/a/2967519/365237) – eis

risposta

3

git-stash è uno script, non un comando compilato nel binario git.exe.

Su Linux: posso trovare git-stash a /usr/lib/git-core/git-stash - vi farò cercare il percorso corretto sulle finestre ...


Questo script utilizza #!/bin/sh a correre, io non so cosa implementazione shell è usato quando lo si esegue su Windows.

Si può provare a correre con un altro shell compatibile (qui: bash):

# the git-core/ dir needs to be in the PATH, 
# obviously you will need to provide the correct path for your git-core dir 

$ PATH=/usr/lib/git-core:$PATH bash /usr/lib/git-core/git-stash 

È inoltre possibile attivare il flag -x, che stamperà una traccia di tutti i comandi eseguiti, e controllare visivamente se uno dei comandi secondari sembra essere il gancio:

$ PATH=/usr/lib/git-core:$PATH bash -x /usr/lib/git-core/git-stash