---
title: "Improving Git push times through faster server side hooks"
description: "GitHub cut pre-receive hook execution time on every Git push from about 880ms median to 10ms, dropping P99 by 95%, by rewriting the hooks from Ruby into its Go Git service."
url: "https://swe.quest/articles/improving-git-push-times-through-faster-server-side-hooks-21ad6ccb34bf4962"
canonical: "https://github.blog/engineering/architecture-optimization/improving-git-push-times-through-faster-server-side-hooks/"
source: "GitHub Engineering"
published: "2022-04-21"
difficulty: "medium"
kind: "Case study"
reading_minutes: 5
tags: ["performance","version-control","go","ruby","refactoring"]
---

# Improving Git push times through faster server side hooks

A post on [GitHub Engineering](https://swe.quest/sources/github.md), published 2022-04-21, 5 min read, Case study. Original: [https://github.blog/engineering/architecture-optimization/improving-git-push-times-through-faster-server-side-hooks/](https://github.blog/engineering/architecture-optimization/improving-git-push-times-through-faster-server-side-hooks/)

## Summary

GitHub cut pre-receive hook execution time on every Git push from about 880ms median to 10ms, dropping P99 by 95%, by rewriting the hooks from Ruby into its Go Git service. The Ruby hooks ran as subprocesses under Git and loaded the Rails monolith's 450+ gems on every push, twice per push (quarantine and post-receive), so an empty push could take over two seconds. Pruning outlier dependencies found with a debugger and strace saved 350-400ms, but load time would creep back as the monolith grew. The rewrite instead passes the needed configuration through an existing per-push data mechanism and rolled out behind a feature flag.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Performance engineering](https://swe.quest/tags/performance.md) (Reliability & operations)
- [Version control](https://swe.quest/tags/version-control.md) (Engineering practices)
- [Go](https://swe.quest/tags/go.md) (Languages)
- [Ruby](https://swe.quest/tags/ruby.md) (Languages)
- [Refactoring & migrations](https://swe.quest/tags/refactoring.md) (Engineering practices)

## Prerequisites

- Git server-side hooks
- Ruby on Rails boot process ([easy posts on Ruby](https://swe.quest/tags/ruby.md?difficulty=easy))

## Keywords

Git, pre-receive hooks, Ruby on Rails, Go, strace, GitHub Enterprise Server

## Related posts

- [Building GitHub with Ruby and Rails](https://swe.quest/articles/building-github-with-ruby-and-rails-99851966c067c871.md): GitHub Engineering · 2023-04-06 · Medium · 5 min read · Ruby, Refactoring & migrations, CI/CD, Deployment, Open source
  GitHub's ~2M-line Rails monolith upgrades to the latest Rails main-branch commit every week via a scheduled GitHub Actions workflow that opens an automated PR, runs all builds, and ships the next day.
- [Scaling merge-ort across GitHub](https://swe.quest/articles/scaling-merge-ort-across-github-6d05304b446e2f08.md): GitHub Engineering · 2023-07-27 · Medium · 5 min read · Version control, Performance engineering, Deployment
  GitHub replaced its libgit2-based server-side merge and rebase implementation with Git's merge-ort strategy, which needs no working directory and matches what the Git command line does.
- [How we improved availability through iterative simplification](https://swe.quest/articles/how-we-improved-availability-through-iterative-simplification-1aa63e0def5687e6.md): GitHub Engineering · 2024-07-23 · Medium · 6 min read · Performance engineering, MySQL, Ruby, Observability, Deployment
  GitHub cut timeouts in its Rails monolith with small, measured changes found through Datadog metrics, Splunk logs and custom MySQL slow-query monitors.
- [GitHub Does My Operations Homework: A Ruby Speed Story](https://swe.quest/articles/github-does-my-operations-homework-a-ruby-speed-story-423c3866d401e486.md): Shopify Engineering · 2021-10-19 · Medium · 8 min read · CI/CD, Performance engineering, Ruby, Compilers
  Shopify's YJIT team runs a continuously updated public benchmark site, speed.yjit.org, that reports YJIT as 20.6% faster than interpreted CRuby and 17.4% faster than MJIT overall, and 18.5% faster than CRuby on Railsbench.
- [How we improved push processing on GitHub](https://swe.quest/articles/how-we-improved-push-processing-on-github-ee01af72cf149679.md): GitHub Engineering · 2024-06-11 · Medium · 7 min read · Event-driven architecture, Queues & messaging, Resilience, Ruby, Scaling
  GitHub replaced RepositoryPushJob, a single sequential background job that ran over 60 push-handling tasks from 20 services, with a Kafka push event fanned out to roughly 16 independently owned, parallel jobs.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
