Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Doximity Technology 8 min read Case study mediumAdept

Profiling Performance Bottlenecks in Production

A slow Sidekiq background job at Doximity was traced with the Vernier sampling profiler to a Redis fetch memoized on a per-record builder instance. Because a new builder was created for each record, the full reference dataset was refetched tens of thousands of times. Moving the fetch to the parent batch class and passing it down cut that step from 8.95s to 1.44s on ~45k records, and overall job runtime fell by about 80%. The practical lessons are to use dashboards and traces to pick the target, then profile it, and when profiling in production, benchmark separately, plan cleanup of side effects, and use Sidekiq's built-in Vernier integration.

Assumes: Ruby basicsSidekiq background jobsmemoization

Related posts

  • How we improved availability through iterative simplification

    GitHub Engineering mediumAdept

    GitHub 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 mediumAdept

    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. 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 built a Ruby library that saves 50% in testing time

    Datadog Engineering hardMaster

    Datadog built a Ruby test impact analysis library for its Intelligent Test Runner that maps each test to the source files it executes, so tests unrelated to a commit's changed files can be skipped, cutting testing time roughly in half. Ruby's Coverage module (up to 300% overhead, conflicts with simplecov) and TracePoint (~200–400%) were too slow. A C extension hooking RUBY_EVENT_LINE got overhead to 60–80%, and further gains came from rb_profile_frames to avoid string copies and from caching the rb_sourcefile pointer to skip repeated prefix checks. Code-less classes such as Active Record models emit no line events, so a small allocation profiler on RUBY_INTERNAL_EVENT_NEWOBJ adds the source files of instantiated classes. External services, processes and data files remain untracked and are handled through tracked-file lists and unskippable tests.

  • Diggin’ and Fetchin’ with TruffleRuby

    Shopify Engineering mediumAdept

    Refactoring a chained Hash#fetch with default values leads to prototyping a new Hash#dig_fetch method in TruffleRuby, combining fetch's KeyError/default semantics with dig's nested traversal. Benchmarks with benchmark-ips showed that both the recursive dig_fetch and TruffleRuby's existing recursive Hash#dig fell off a performance cliff as nesting depth grew, because the compiler cannot inline recursive calls indefinitely. Rewriting dig as an iterative loop in a shared Diggable module lifted nine-level lookups from about 2.5M to about 16M iterations per second, and that fix shipped upstream in TruffleRuby.

  • Making Shopify’s Flagship App 20% Faster in 6 Weeks Using a Novel Caching Solution

    Shopify Engineering mediumAdept

    Shop's home feed, which aggregated orders and carrier tracking data and accounted for 30% of database load, was moved behind a custom write-through cache in Memcached, cutting database load by 15%, overall GraphQL latency by about 20% and CPU usage by a double-digit percentage. To handle concurrent order updates without serving stale data, each user has a pending-writes counter that workers increment before a database write and decrement after it. A short-expiry key detects crashed writers so the cache can be safely rewarmed. The logic was mixed into Active Record models as concerns, so the ORM API was unchanged. Correctness was validated in a shadow rollout that compared cache and database reads before serving from the cache.

The quest for software engineering knowledge.

Look:
Layout: