为什么在回购变得更大时git操作会变慢 [英] Why git operations becomes slow when repo gets bigger

查看:103
本文介绍了为什么在回购变得更大时git操作会变慢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道git会在repo变大时变慢.
但是为什么呢?
由于git将文件存储为单独的目录和 .git 下的文件,因此我无法找出操作速度变慢的原因.让我们看一下 commit 操作.最近,我克隆了Webkit存储库,并从master分支,然后将 2k 文件提交到该分支.但是我觉得它比我的小仓库要慢.
因为我还没有阅读过git源代码,所以我猜想提交操作会危及到将文件存储到磁盘,插入提交日志,更新索引以及将 HEAD 更新为文件的sha值的问题.

写入速度很快.
插入速度很快.(我想,如果插入操作是将日志追加到文件中)
更新索引很快.
HEAD更新快.

为什么慢呢? 有人可以向我说明吗?
谢谢.

一些答案​​很有帮助,但不是很令人信服,提供一些代码片段来支持您将非常有用.

解决方案

提交树的时间应该是恒定的,因为它只需要创建一个新的提交对象(git write-tree)并更新HEAD引用. /p>

我过去曾做过不同SCM的基准测试,git commit确实不受树大小,存储库大小,历史记录长度等的影响.

I know git would get slow when the repo get bigger.
But why?
As git stores files as separate directories and files under .git, i can not find out why the operations get slowwer. Let's have a look at the commit operation. Recently, i cloned the webkit repo and i branch from master, then i commit a 2k file to the branch. But i feel it gets slowwer than that i do on my small repo.
Because i have not read through git source code, i guess the commit operation compromises storing the file to the disk, inserting the commit log, updating the index and updating the HEAD to the sha value of the file.

The write is fast.
The inserting is fast.(I guess, if the insert action is append log to a file)
The updating index is fast.
The updating HEAD is fast.

And why it is slow? Can anyone illustrate it to me?
Thanks.

Some answers is helpful but not very convincible, it will be great to provide some code snippets to support you.

解决方案

Committing a tree should be constant in time, since it only needs to create a new commit object (git write-tree) and update the HEAD ref.

I did benchmarks of different SCMs in the past and git commit was indeed not affected by tree size, repository size, history length, etc.

这篇关于为什么在回购变得更大时git操作会变慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆