How a One Line Change Decreased Our Clone Times by 99%

1,845
Pinterest
Pinterest is a social bookmarking site where users collect and share photos of their favorite events, interests and hobbies. One of the fastest growing social networks online, Pinterest is the third-largest such network behind only Facebook and Twitter.

By Urvashi Reddy | Software Engineer, Engineering Productivity Team Adam Berry | Tech Lead, Engineering Productivity Team Rui Li | Software Engineer, Engineering Productivity Team


The Engineering Productivity team at Pinterest came across a small change that had a large impact in reducing build times across pipelines. We found that setting the refspec option during git fetch reduced our cloning step by 99%.

The Engineering Productivity team at Pinterest is responsible for supporting the engineers who build and deploy software at the company. Our team maintains a number of infrastructure services and often works on large scale efforts — migrating all software at Pinterest to Bazel, creating a Continuous Delivery platform called Hermez, and maintaining the monorepos that get committed to a few hundred times a day, to name a few.

All our larger efforts are designed to progress on the goal of making software development and delivery at Pinterest a fast and painless experience. Recently, we were reminded of how small details can also have a large impact on that goal. We discovered an overlooked Git option that significantly reduced the build times in our continuous integration pipelines. In order to understand how this small change had such a large impact, we need to share a little information on our monorepos and our pipelines.

Monorepos and Pipelines

We have six main repositories at Pinterest: Pinboard, Optimus, Cosmos, Magnus, iOS, and Android. Each one is a monorepo and houses a large collection of language-specific services. Pinboard is as old as the company and is the largest monorepo. Pinboard has more than 350K commits and is 20GB in size when cloned fully.

Cloning monorepos that have a lot of code and history is time consuming, and we need to do it frequently throughout the day in our continuous integration pipelines. For Pinboard alone, we do more than 60K git pulls on business days. Most of our Jenkins pipeline configuration scripts (written in Groovy) start with a “Checkout” stage where we clone the repository that the later stages will build and test. Here’s what a typical “Checkout” stage looks like:

If we were using the Git CLI directly, it would translate to:

Even though we’re telling Git to do a shallow clone, to not fetch any tags, and to fetch the last 50 commits, we’re still not running this operation as fast as we could be. That’s because we aren’t setting the refspec option. Notice that by not setting it in the pipeline configuration script, we’re telling Git to fetch all refspecs: +refs/heads/*:refs/remotes/origin/*. In the case of Pinboard, that operation would be fetching more than 2,500 branches.

By simply adding the refspec option and specifying which refs we care about (master, in our case), we can limit the refs to the branch we care about and save a lot of time. Here’s what that looks like in our pipeline code:

This simple one line change reduced our clone times by 99% and significantly reduced our build times as a result. Cloning our largest repo, Pinboard went from 40 minutes to 30 seconds. It goes to show that sometimes our small efforts can have a big impact as well.

Learnings

Like most developer productivity teams, we work on large services that have a big impact on our day-to-day experience. However, it’s sometimes the one line fixes that can make a huge difference. Our work is about understanding that.

If you have a passion for improving developer productivity, join our team! We’re hiring for engineering roles on our Engineering Productivity team.

To learn more about Engineering at Pinterest, check out our Engineering Blog, and visit our StackShare page. To view and apply to open opportunities, visit our Careers page.

Pinterest
Pinterest is a social bookmarking site where users collect and share photos of their favorite events, interests and hobbies. One of the fastest growing social networks online, Pinterest is the third-largest such network behind only Facebook and Twitter.
Tools mentioned in article
Open jobs at Pinterest
Software Engineer, Continuous Delivery
San Francisco, CA, US

About Pinterest:  

Millions of people across the world come to Pinterest to find new ideas every day. It’s where they get inspiration, dream about new possibilities and plan for what matters most. Our mission is to help those people find their inspiration and create a life they love. In your role, you’ll be challenged to take on work that upholds this mission and pushes Pinterest forward. You’ll grow as a person and leader in your field, all the while helping Pinners make their lives better in the positive corner of the internet.

The Engineering Productivity team is a small and diverse group of experienced engineers who build products, tools and systems enabling thousands of Pinterest engineers to be productive across the development lifecycle (code, build, deploy). Our vision is to build a platform that inspires developers to do their best work, and our mission is to provide a fast and safe path from prototype to production without worrying about the underlying infrastructure. We believe in contributing to open source work and collaboration as much as possible. 

What you’ll do:

  • Work on our next-generation, continuous delivery platform for multiple compute backends (VM, K8S, Yarn)
  • Build partnerships with various teams (our customers) by learning their use-cases and pain points; champion key efforts across teams.
  • Have an opportunity to impact key open source systems such as Teletraan (Deploy/Compute Engine), Kubernetes (Compute Engine), Spinnaker (Workflow Orchestration).

What we’re looking for:

  • 4+ years experience as a software engineer and have a penchant to build and scale critical distributed systems.
  • Proficient in coding and scripting languages such as Go, Java, NodeJS or Python.
  • You enjoy articulating technical details on key problem areas by writing RFCs and design documents.

#LI-SG1

Engineering Manager, Creator Platform
San Francisco, CA, US

About Pinterest:  

Millions of people across the world come to Pinterest to find new ideas every day. It’s where they get inspiration, dream about new possibilities and plan for what matters most. Our mission is to help those people find their inspiration and create a life they love. In your role, you’ll be challenged to take on work that upholds this mission and pushes Pinterest forward. You’ll grow as a person and leader in your field, all the while helping Pinners make their lives better in the positive corner of the internet.

The Core Eng - Create Team’s mission is to empower people to create content and build communities that inspire others to create a life they love.

Our focus is to:

  • Grow our quality native content corpus, so we can enable more immersive and engaging experiences on Pinterest.
  • Build delightful tools for anyone who wants to create inspiring content, then build sustained value in our publishing ecosystem - whether through a positive, growing community for the creator or monetization.
  • Protect our pinners and creators by maintaining a positive community and the trust and safety of our pinners.

What you'll do:

  • Partner closely with Design, Product Management, and other Engineering leaders within Core Eng and across Pinterest to identify the highest-impact opportunities to accelerate the product and user experience.
  • Take ownership of critical outcomes. Manage a cross-platform (Android/iOS/Web/Backend) engineering team through the process of planning and executing against those outcomes, delivering software experiences and solutions of the highest quality.
  • Grow the team's capabilities through career development of the current engineers and strategic hiring.

What we're looking for:

  • Passion for developing software solutions for the people using Pinterest.
  • Ability to deliver on immediate goals and form long-term strategies around technology, processes, and people.
  • Strong people development skills and software project management skills.
  • Proven success launching complex software development projects that deliver high-impact outcomes.

#LI-AG1

Design Technologist - Figma Plugin De...
, US

About Pinterest:  

Millions of people across the world come to Pinterest to find new ideas every day. It’s where they get inspiration, dream about new possibilities and plan for what matters most. Our mission is to help those people find their inspiration and create a life they love. In your role, you’ll be challenged to take on work that upholds this mission and pushes Pinterest forward. You’ll grow as a person and leader in your field, all the while helping Pinners make their lives better in the positive corner of the internet.

Pinterest is looking for a Javascript developer to help build out our Figma tooling solutions to better support the company’s design team. You will be creating the tools which help our designers improve Pinterest so it can live up to its mission to bring inspiration and a positive impact to people’s lives.
 
What you’ll do:
  • Talk with product designers to gain a direct understanding of how they work and how our plugins can better support their workflow.
  • Work directly with the product design team to craft and ship tools that will help our team work better and with greater velocity.
  • Develop a strong baseline/framework for all future Figma plugin solutions within Pinterest.
What we’re looking for:
  • 5+ years of experience building on the web platform.
  • Strong background in current web app development practices as well as a strong familiarity with Javascript, Typescript and Webpack.
  • Solid experience with HTML and CSS fundamentals.
  • Background and familiarity with modern design processes and tools is a big plus.
  • Experience with React and using Figma’s plugin/REST APIs a big plus.

More about contract roles at Pinterest: 

  • This is a contract position at Pinterest. As such, the contractor who fills this role will be employed either by our staffing partner (ProUnlimited) or by an agency partner, and not an employee of Pinterest
  • All interviews will be scheduled and/or conducted by the Pinterest assignment manager. When a finalist has been selected, ProUnlimited or the agency partner will extend the offer and provide assignment details including duration, benefits options and onboarding details

#LI-AZ415

#LI-REMOTE

Engineering Manager, Stream Processin...
San Francisco, CA, US

About Pinterest:  

Millions of people across the world come to Pinterest to find new ideas every day. It’s where they get inspiration, dream about new possibilities and plan for what matters most. Our mission is to help those people find their inspiration and create a life they love. In your role, you’ll be challenged to take on work that upholds this mission and pushes Pinterest forward. You’ll grow as a person and leader in your field, all the while helping Pinners make their lives better in the positive corner of the internet.

As the manager for the Stream Processing Platform team at Pinterest, you will lead a team of talented engineers to work on the large scale platform that powers real-time stream processing applications that process trillions of messages every day. You will have the opportunity to work with the team on the latest cutting edge real-time stream processing challenges, defining the future strategy and taking the platform to the next level. You will also have the opportunity to work closely with product teams that develop exciting new applications on our platform every day, from machine learning, analytics, trust safety to shopping. 

What you’ll do:

  • Lead the team that owns the entire stack of stream processing platform
  • Drive Pinterest’s stream processing strategy and vision
  • Collaborate with customers to understand requirements and incorporate them in the roadmap and work closely with partners to align on strategic directions
  • Hire and further build up the team to support more use cases

What we’re looking for:

  • 7+ years of experience, including 2+ years of management experience
  • Solid expertise in big data or other types of large scale distributed systems
  • Platform development and operational experience
  • Enjoying working in an agile environment

#LI-MJ1

Verified by
Security Software Engineer
Tech Lead, Big Data Platform
Software Engineer
Talent Brand Manager
Sourcer
Software Engineer
You may also like