首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >git藏在窗户上很慢

git藏在窗户上很慢
EN

Stack Overflow用户
提问于 2016-05-30 15:16:03
回答 1查看 10.5K关注 0票数 54

在我的windows机器上,每次调用git stash的开销约为3.5秒,这为我的git钩子增加了大约7秒。

在linux (同一台机器)下,相同的命令大约需要0.01秒。性能问题也适用于空存储库。

我从这条线这条线中尝试了以下几种方法

  • core.fscache设置为true
  • core.preloadindex设置为true
  • gc.auto设置为256
  • 设置PS1='$‘
  • 在管理模式下运行cmd
  • 在cmd.exe中运行而不是git-bash。

运行GIT_TRACE=true git stash list

代码语言:javascript
复制
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

运行GIT_TRACE_PERFORMANCE=true git stash list

代码语言:javascript
复制
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                                                                                                                                                                                          

从日志中我们看到,在运行git-stash命令和运行git-rev-解析之间需要大约3秒的时间。还有其他的标志我可以跑找到瓶颈吗?

EN

回答 1

Stack Overflow用户

发布于 2017-03-07 13:04:55

git-stash是一个脚本,而不是在git.exe二进制文件中编译的命令。

在linux上:我可以在git-stash上找到/usr/lib/git-core/git-stash -我会让你在windows上寻找正确的路径.

这个脚本使用#!/bin/sh来运行,我不知道在windows上运行它时使用的是什么shell实现。

您可以尝试使用另一个兼容的shell (此处: bash)运行它:

代码语言:javascript
复制
# 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

您还可以打开-x标志,它将打印执行的所有命令的跟踪,并直观地检查其中一个子命令是否似乎是挂起的:

代码语言:javascript
复制
$ PATH=/usr/lib/git-core:$PATH bash -x /usr/lib/git-core/git-stash
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37529016

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档