Improving Git push times through faster server side hooks
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.
Related posts
- Building GitHub with Ruby and Rails
GitHub Engineering mediumAdeptGitHub'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. CI also runs a parallel build against the latest Ruby commit, which let GitHub test Ruby 3.2 release candidates on production traffic, catch regressions such as a keyword-argument allocation increase before release, and adopt Ruby 3.2.1 on release day. Benefits include dropping nearly all Rails patches, avoiding big-bang migrations, and better security posture. The approach depends on a thorough test suite and progressive rollout deploys.
- Scaling merge-ort across GitHub
GitHub Engineering mediumAdeptGitHub 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. Both changes were validated with Scientist experiments that ran old and new code paths side by side in production. For merges, P50 dropped from about 71 ms to under 8 ms and P99 from 1.63 s to about 330 ms, a 10x speedup on the github/github monolith. Rebases moved to the new git-replay subcommand, and in testing they took under 10 minutes of compute versus 2.56 hours with libgit2.
- How we improved availability through iterative simplification
GitHub Engineering mediumAdeptGitHub cut timeouts in its Rails monolith with small, measured changes found through Datadog metrics, Splunk logs and custom MySQL slow-query monitors. Each change was validated with Scientist experiments or rolled out gradually behind Flipper feature flags. Reordering a Command Palette query to look up a user's contributions before filtering by org removed a large IN clause and was 80-90% faster, and batching access checks added another 20-80% and 30-40%. Skipping unneeded authorization filters on a busy redirect endpoint cut tail latency and timeouts. Not every idea paid off: moving sorting into the application was 40-80% slower, so that experiment was dropped.
- GitHub Does My Operations Homework: A Ruby Speed Story
Shopify Engineering mediumAdeptShopify'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. The setup is low-maintenance: GitHub Actions runs a cron job that SSHes into an AWS instance to run the benchmarks, then commits the results to a Jekyll site hosted on GitHub Pages, and automatically files an issue if any benchmark slows down too much. The write-up covers the practical snags along the way, including Jekyll's _includes and collections constraints, SSH host-key problems caused by AWS reusing IPs, and passing environment variables over SSH. It also compares D3 generated from Erb, raw SVG and matplotlib for producing the graphs.
- How we improved push processing on GitHub
GitHub Engineering mediumAdeptGitHub 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. The monolithic job was hard to retry because different tasks had conflicting retry needs. Its tight coupling meant a failure early in the job, such as in the Pushes MySQL cluster, could block unrelated work like pull request sync, and its sequential design added latency. The migration needed a reliable Kafka publisher, dedicated worker pools, finer observability and per-event feature flags for a safe rollout. Afterward, p50 pull request sync time fell from about 3s to 2s, ownership spread to 15+ teams, and fully processed pushes rose from 99.897% to at least 99.999%.