加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

windows – Git如何从UNC路径获取更改?

发布时间:2020-12-14 02:48:38 所属栏目:Windows 来源:网络整理
导读:我在 Windows PC上的共享文件夹中有一个 Git存储库,我使用UNC路径访问该文件夹,例如 git clone //server/share/MyRepo.git 当我从家中通过VPN获取此存储库中的更改时,git-upload-pack.exe需要很长时间才能运行.我意识到没有涉及服务器(如此),我的本地PC正在
我在 Windows PC上的共享文件夹中有一个 Git存储库,我使用UNC路径访问该文件夹,例如

git clone //server/share/MyRepo.git

当我从家中通过VPN获取此存储库中的更改时,git-upload-pack.exe需要很长时间才能运行.我意识到没有涉及服务器(如此),我的本地PC正在运行所有可执行文件.

git-upload-pack.exe的名称告诉我,我的本地PC正在从远程文件共享中读取文件,以便将它们上传到某处,但这本身就是自己的,这没有任何意义.这反过来又让我觉得这次获取的性能远远不够.这就像本地机器正在做所有工作来减少要传输的数据,但要做到这一点,它必须传输所有数据.

任何人都可以阐明它是如何工作的吗?没有通过SSH或远程端的任何东西运行真正的Git服务器,或者是不必要地来回传输文件,性能是否尽可能好?

解决方法

使用git 2.1(2014年8月),这个获取应该更快:一个旧的2012修复最终被集成到git中.

见(theoleblond)到(theoleblond)

compat / poll:睡眠1毫秒,以避免繁忙的等待

SwitchToThread() only gives away the rest of the current time slice to another thread in the current process. So if the thread that feeds the file decscriptor we’re polling is not in the current process,we get busy-waiting.

I played around with this quite a bit. After trying some more complex schemes,I found that what worked best is to just sleep 1 millisecond between iterations. Though it’s a very short time,it still completely eliminates the busy wait condition,without hurting perf.

There code uses SleepEx(1,TRUE) to sleep.
See 07002 for a good discussion of why that is better than calling SwitchToThread,which is what was used previously:

Note that calling SleepEx(0,TRUE) does not solve the busy wait.

The most striking case was when testing on a UNC share with a large repo,on a single CPU machine.
Without the fix,it took 4 minutes 15 seconds,and with the fix it took just 1:08
! I think it’s because git-upload-pack‘s busy wait was eating the CPU away from the git process that’s doing the real work. With multi-proc,the timing is not much different,but tons of CPU time is still wasted,which can be a killer on a server that needs to do bunch of other things.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读