Skip to content

Speed up checkout by fetching minimal data from remote and lazily loading it later #612

@Tyriar

Description

@Tyriar

One of my big annoyances with the extension is how long it takes to checkout a branch, particularly on the first time checking this out. It's also even worse on Windows as git seems to be a little slower (due to FS?). This problem is also much worth with larger repos due to the size of the history, branch/tag count, etc.

I'm proposing that when a PR is checked out for the first time we fetch just the branch (r branch) and no history (--depth=1), something like this:

git remote add r
git fetch --depth 1 r branch
git checkout remote_branch

The history and rest of branches can then be lazily fetched later with this:

git fetch --unshallow r

Based on my testing this should provide a very significant speed up:

Normal fetch and checkout:

powershell -Command "Measure-Command {git remote add r https://github.com/Tyriar/xterm.js; git fetch r}"
...
Days              : 0
Hours             : 0
Minutes           : 0
Seconds           : 2
Milliseconds      : 935
Ticks             : 29353111
TotalDays         : 3.39735081018518E-05
TotalHours        : 0.000815364194444444
TotalMinutes      : 0.0489218516666667
TotalSeconds      : 2.9353111
TotalMilliseconds : 2935.3111

Fetch remote branch only with no history:

powershell -Command "Measure-Command {git remote add r https://github.com/Tyriar/xterm.js; git fetch --depth 1 r 1747_npe}"
...
Days              : 0
Hours             : 0
Minutes           : 0
Seconds           : 1
Milliseconds      : 149
Ticks             : 11490152
TotalDays         : 1.3298787037037E-05
TotalHours        : 0.000319170888888889
TotalMinutes      : 0.0191502533333333
TotalSeconds      : 1.1490152
TotalMilliseconds : 1149.0152

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions