A one-line change reduced clone times by 99% at Pinterest.
While it may sound clichรฉ, small changes can definitely create a big impact.
The Engineering Productivity team at Pinterest witnessed this first-hand.
They made a small change in the Jenkins build pipeline of their monorepo codebase called Pinboard.
And it brought down clone times from 40 minutes to a staggering 30 seconds.
For reference, Pinboard is the oldest and largest monorepo at Pinterest. Some facts about it:
Cloning monorepos having a lot of code and history is time consuming. This was exactly what was happening with Pinboard.
The build pipeline (written in Groovy) started with a โCheckoutโ stage where the repository was cloned for the build and test steps.
The clone options were set to shallow clone, no fetching of tags and only fetching the last 50 commits.
But it missed a vital piece of optimization.
The Checkout step didnโt use the Git refspec option.
This meant that Git was effectively fetching all refspecs for every build. For the Pinboard monorepo, it meant fetching more than 2500 branches.
๐๐จ - ๐ฐ๐ก๐๐ญ ๐ฐ๐๐ฌ ๐ญ๐ก๐ ๐๐ข๐ฑ?
The team simply added the refspec option and specified which ref they cared about. It was the โmasterโ branch in this case.
This single change allowed Git clone to deal with only one branch and significantly reduced the overall build time of the monorepo.