跳到主内容

repo sync 加速

项目是用 repo 来管理 SDK,随着 SDK 中包含的仓库越来越多,以及单个仓库的体积越来越大,下载 SDK 的时间越来越长,目前已经超过了 15 分钟。 有没有办法加速 SDK 的下载? 答案是有的,就是利用 repo 命令的 --reference 参数,可以将下载时间优化到 1 分钟左右。

该方法需要先创建本地 SDK mirror,然后在执行 repo init 命令的时候设定 --reference 参数。 SDK mirror 只需要创建一次,未来 sync 代码时可以重复使用。

创建 SDK mirror:

mkdir sdk_repo_mirror
cd sdk_repo_mirror
repo init -u ssh://YOUR_ACOUNT@GERRIT_HOST/manifest --mirror
repo sync --no-tags;

Download SDK Source:

mkdir sdk_work
cd sdk_work
repo init -u ssh://YOUR_ACOUNT@GERRIT_HOST/manifest --reference=YOUR_SDK_MIRROR_PATH
repo sync

repo 仓库中的注释:

The --reference option can be used to point to a directory that has the content of a --mirror sync. This will make the working
directory use as much data as possible from the local reference directory when fetching from the server. This will make the sync
go a lot faster by reducing data traffic on the network.

评论