Multibranch builds and reference cloning slowness

I recently was trying to use reference cloning to shorten git checkout times. Our git repo is quite large and takes several minutes to checkout. However, when checking out with git on a multibranch build - the reference cloning did not appear to be working as expected. I compared several different ways of doing this and this was my result. My question is - is this erroneous behaviour? Am I missing something? What is going on here?

For all these tests I used the same AWS machine. I’ve also removed identifying info in the outputs.

  1. git clone --reference directly on the machine → 3 minutes to clone
  2. GitSCM with CloneOption reference → 3 minutes to clone
11:47:39  The recommended git tool is: git
11:47:39  using credential c-shared
11:47:39  Cloning the remote Git repository
11:47:38  Cloning repository https://github.com/x/x
11:47:38   > git init c:\Users\Administrator\jenkins\workspace\Jenkins Testing\extra_test # timeout=10
11:47:38  Using reference repository: C:/jenkins/workspace/x
11:47:38  Fetching upstream changes from https://github.com/x/x
11:47:38   > git --version # timeout=10
11:47:38   > git --version # 'git version 2.27.0.windows.1'
11:47:38  using GIT_ASKPASS to set credentials Shared Git Token
11:47:38   > git fetch --tags --force --progress -- https://github.com/x/x +refs/heads/*:refs/remotes/origin/* # timeout=10
11:47:50  Avoid second fetch
11:47:50  Checking out Revision 47647507ea4ea44a7e95d0b7b9d3f0e44829441f (refs/remotes/origin/master)
11:47:49   > git config remote.origin.url https://github.com/x/x # timeout=10
11:47:49   > git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10
11:47:49   > git rev-parse "refs/remotes/origin/master^{commit}" # timeout=10
11:47:49   > git config core.sparsecheckout # timeout=10
11:47:49   > git checkout -f 47647507ea4ea44a7e95d0b7b9d3f0e44829441f # timeout=10
11:51:06  Commit message: "x"
11:51:05   > git rev-list --no-walk 47647507ea4ea44a7e95d0b7b9d3f0e44829441f # timeout=10
  1. Multibranch build with Path of the reference repo to use during clone → 9 minutes
12:19:53  The recommended git tool is: git
12:19:57  using credential x
12:19:57  Cloning the remote Git repository
12:19:57  Cloning repository https://github.com/x/x.git
12:19:57   > git init C:\Jenkins\workspace\x_master # timeout=10
12:19:59  Using reference repository: C:/jenkins/workspace/x
12:19:59  Fetching upstream changes from https://github.com/x/x.git
12:19:59   > git --version # timeout=10
12:19:59   > git --version # 'git version 2.27.0.windows.1'
12:19:59  using GIT_ASKPASS to set credentials Git credentials with token
12:19:59   > git fetch --tags --force --progress -- https://github.com/x/x.git +refs/heads/*:refs/remotes/origin/* # timeout=60
12:21:04  Avoid second fetch
12:21:04  Checking out Revision 47647507ea4ea44a7e95d0b7b9d3f0e44829441f (master)
12:21:03   > git config remote.origin.url https://github.com/x/x.git # timeout=10
12:21:03   > git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10
12:21:03   > git config core.sparsecheckout # timeout=10
12:21:04   > git checkout -f 47647507ea4ea44a7e95d0b7b9d3f0e44829441f # timeout=10
12:28:54  Commit message: "x"
12:28:54   > git rev-list --no-walk c16ae73804138a415dc0db7156ebc97afe497250 # timeout=10
  1. Normal checkout without reference clone → 9 minutes