Engineering Diaries · CI/CD
§
CI/CDEngineering MetricsDeveloper Experience

The Average CI Build Is Not The One Your Engineers Wait For. Why I Measure P90, And What Took It From 81 To 52 Minutes.

Averages and medians describe the build nobody complains about. What P50, P75 and P90 each expose, how to measure them without fooling yourself, why you cannot average percentiles, and how safe parallelisation took successful-build CI P90 from 81 to 52 minutes.

01 · The Number

Nobody Remembers The 35-Minute Build

Ask an engineer how long CI takes and you will not get the median. You will get the worst build they had this week. "CI takes over an hour" is what people say, even if most of their builds finished in forty minutes. They are not exaggerating. They are reporting the build that cost them something: the one that finished after standup, or after the reviewer had logged off, or after they had already switched to a different task and lost the thread of the first one.

That is the gap this piece is about. Dashboards love averages, and the average build is a very pleasant build. But the build that shapes how people work is the slow one, and the slow one lives in the tail of the distribution, which an average flattens and a median ignores completely.

So when I worked on CI wait times on a large SaaS platform, the target was not "make the average faster". It was the 90th percentile: the duration that nine builds in ten finish under, and one in ten does not. After parallelising the integration-test suites that were safe to run in parallel, across ten product and platform domains, the three P90s we tracked moved like this:

81→52
Successful build P90 (min)
76→40
Backend PR P90 (min)
88→58
Frontend PR P90 (min)
47%
Biggest P90 cut

That is 29 minutes off the successful-build tail (about 36%), 36 minutes off the backend pull-request tail (about 47%) and 30 minutes off the frontend pull-request tail (about 34%). Tests that shared state stayed serial, which matters more than it sounds, and I will come back to it.

I am deliberately reporting only P90 here, because P90 is what we targeted and what I can stand behind. This is not a post about a magic parallelisation trick. It is about the metric choice that came first: why P90 is the honest number for developer wait time, what P50 and P75 tell you that P90 does not, how to compute them without accidentally lying to yourself, and the tradeoffs that show up the moment you start optimising the tail on purpose.

02 · The Vocabulary

P50, P75 And P90 Are Three Different Questions

A percentile is a position in a sorted list. Sort every build duration from fastest to slowest. The value that half the builds finish under is the 50th percentile, P50, which is the median. The value that three quarters finish under is P75. The value nine in ten finish under is P90. Each one answers a different question about the same set of builds.

An example makes it concrete. The numbers below are illustrative, not real pipeline data: twenty pull-request builds, in minutes, shaped the way CI durations usually are. Most cluster together, and a handful run long because they hit a slow suite, a cold cache or a busy agent pool.

twenty builds, sorted (minutes, illustrative)
31  33  34  35  36  37  38  38  39  40
41  42  44  46  58  64  71  79  86  92
StatisticValueWhat it says about these builds
Mean49.2 minA duration no build actually took. It sits in the empty gap between 46 and 58.
P50 (median)40 minThe routine build. Half finish faster than this.
P7558 minOne build in four is slower than this. "Bad, but common."
P9079 minTwo builds in twenty are slower than this. The build people tell stories about.

Look at the spread. The median says forty minutes. P90 says nearly double that. Both are correct. They are just describing different builds, and an engineer pushing several times a day will meet all of them.

The mean is the strangest number in the table. It is pulled upwards by the six slow builds, so it overstates the routine case, and it is diluted by the fourteen fast ones, so it understates the bad case. It ends up describing a build that does not exist. When a distribution has a long right tail, which CI durations, page loads and API latencies almost always do, the mean is a weighted compromise between two populations that it refuses to name.

The median describes the build nobody complains about. P90 describes the build people plan around.

03 · The Trap

How A Team Can Make CI "Faster" Without Anyone Waiting Less

Here is the failure mode that makes me suspicious of any CI improvement reported as an average or a median.

Take the same illustrative twenty builds. Suppose someone ships a sensible improvement: a faster dependency install, say, that saves six minutes on every build that was already running normally. It does nothing for the slow builds, because their slowness comes from somewhere else, perhaps one enormous serial suite. Recompute:

StatisticBeforeAfterChange
Mean49.2 min45.0 min8.5% faster
P5040 min34 min15% faster
P7558 min58 minNo change
P9079 min79 minNo change

The update writes itself: "Median CI time down 15%." It is true. It is also nearly irrelevant to the people who are actually unhappy, because the builds that hurt did not move at all. The engineer who waited 79 minutes last week will wait 79 minutes next week, and they will reasonably conclude that the infrastructure team is measuring the wrong thing.

The reverse is just as possible. A change that targets the tail, like splitting the slow suite, might leave the median exactly where it was. A team that only watches the median would see a flat line and wonder why people suddenly stopped complaining.

None of this means the dependency improvement was bad. Six minutes on most builds is real time, and over hundreds of builds a day it adds up to a lot of compute and a lot of small waits. The point is that it is a different improvement from fixing the tail, and the two should be reported with the numbers that describe them. Median for the routine experience. P90 for the painful one.

The question to ask in review

When someone reports a CI speed-up, ask which percentile moved. If the answer is only "the average", you do not yet know whether anyone's worst build got better.

04 · What Each One Exposes

Choosing A Percentile Is Choosing Whose Experience Counts

Every percentile is a decision about how much of the bad experience you are willing to ignore. P50 ignores the slower half entirely. P90 ignores the worst tenth. P99 ignores the worst hundredth. There is no neutral choice, so it helps to be explicit about what each one is good for.

  • P50 shows the routine cost. It moves when you improve something every build does: installs, checkout, caching, image pulls. It is the right number for capacity and cost conversations, because most of your compute is spent there. It is the wrong number for "are people suffering".
  • P75 shows the bad-but-common case. One build in four is slower. Web performance already uses this level: Core Web Vitals are assessed at the 75th percentile of page loads. Google's write-up on how the thresholds were defined explains the reasoning. It wanted most visits to meet the target while keeping a few extreme outliers from distorting the result. It also notes that a 95th percentile on a site with 100 visits would be swung by just five outlier samples.
  • P90 shows what trust is built on. If one build in ten takes nearly twice as long as normal, engineers do not plan around the normal one. They plan around the risk. They batch changes, avoid pushing late in the day and stop running CI as a feedback loop. P90 is where developer-experience problems turn into behaviour.
  • P99 is mostly noise for CI. In a window of a hundred builds, P99 is the slowest build or very close to it. One build stuck behind an agent outage can set it. It is useful for alerting on pathological cases and almost useless as a target you move week to week, unless your build volume is very high.

Why did I land on P90 for wait time rather than P75? Volume is part of it. A busy monorepo runs enough builds that P90 is stable from week to week, which is not true for every repository. But mostly it is about what changes behaviour. An engineer does not notice one slow build in four as a pattern. They notice one in ten that is dramatically slower, because those are the builds that collide with a meeting, a release window or the end of the day.

That makes the gap between P50 and P90 one of the most useful single numbers you can put on a dashboard. A small gap means CI is predictable, even if it is slow, and predictable slowness can be planned around. A large gap means CI is a lottery. In my experience, people tolerate slow far better than they tolerate unpredictable.

05 · The Compounding

One In Ten Sounds Rare. It Is Not Rare For The Person Pushing.

The most common objection to tail metrics is "it is only ten percent of builds". That framing is per build. Engineers do not experience CI per build. They experience it per day, per pull request and per release, and each of those involves several builds.

Do the arithmetic. If each build independently has a one-in-ten chance of landing above P90, an engineer who pushes five times in a day has a 1 - 0.95 ≈ 41% chance of hitting at least one tail build that day. A pull request that needs four or five rounds of review fixes will very likely meet the tail at least once before it merges. "Ten percent of builds" quietly becomes "most pull requests, eventually".

Real builds are not perfectly independent, so treat the number as an intuition rather than a measurement. Slow builds cluster around busy hours and around changes that touch the same expensive suites. But clustering usually makes the experience worse, not better, because the people who hit one slow build are disproportionately likely to hit the next.

Distributed systems people have been making this argument for years. In The Tail at Scale (Communications of the ACM, 2013), Jeffrey Dean and Luiz André Barroso describe servers that usually respond in about 10 ms but have a 99th-percentile latency of one second. One user request in a hundred hitting one such server is slow. A request that must wait for responses from a hundred such servers in parallel is slower than a second 63% of the time. The rare tail of each component becomes the common experience of the whole.

A metric that is rare per build can be routine per engineer. Measure the unit people actually live in.

CI has the same shape. A pull request waits on several jobs. A merge waits on a pipeline. A release waits on many merges. Each layer gathers up the tails below it. If you want to know what CI feels like, the tail is not the edge case. It is what people actually get.

06 · The Measurement

How To Compute P90 Without Fooling Yourself

Percentiles are easy to compute and surprisingly easy to compute wrongly. These are the decisions I think matter most, and each one changes the number.

  • Segment before you aggregate. The three numbers at the top of this piece are separate populations: successful builds, backend pull requests and frontend pull requests. Blending a frontend pipeline and a backend pipeline into one P90 gives you a number that describes neither, and an improvement in one can be hidden by growth in the other.
  • Decide what to do with failures. A build that fails in the third minute is not a fast build. Mixing failed and cancelled runs into a duration metric drags the distribution down and rewards pipelines that fail early for bad reasons. Measuring successful builds separately keeps "how long does a green build take" clean. Failure rate is its own metric.
  • Write down where the clock starts. Time spent queued for an agent is time the engineer waits. Whether you include it changes the answer, and both choices are defensible. What is not defensible is changing it halfway through a quarter.
  • Use a window with enough samples. With 20 builds, P90 is decided by the second-slowest one. With 2,000, it is stable. Pick a window, a week or a month, that gives the segment enough volume, and keep it fixed when comparing before and after.
  • Know which percentile formula your tool uses. Nearest-rank returns an actual observed value. Interpolated methods blend between neighbours. PostgreSQL exposes both as percentile_disc and percentile_cont, and the default in many analysis libraries interpolates. On large samples the difference is small. On small segments it is not.
percentiles.ts
type Build = { pipeline: string; state: "passed" | "failed" | "canceled"; minutes: number };

// Nearest-rank: always returns a duration a real build actually took.
function percentile(values: number[], p: number): number {
  const sorted = [...values].sort((a, b) => a - b);
  const rank = Math.ceil((p / 100) * sorted.length);
  return sorted[Math.max(0, rank - 1)];
}

export function summarise(builds: Build[], pipeline: string) {
  // Segment first, and keep only green builds, so early failures cannot flatter the tail.
  const mins = builds
    .filter((b) => b.pipeline === pipeline && b.state === "passed")
    .map((b) => b.minutes);
  return {
    n: mins.length,
    p50: percentile(mins, 50),
    p75: percentile(mins, 75),
    p90: percentile(mins, 90),
  };
}

Always report n next to the percentile. A P90 without a sample size is a number you cannot argue with, and that is exactly the problem.

07 · The Mistake Everyone Makes

You Cannot Average Percentiles

This one deserves its own section, because it shows up in almost every hand-built metrics pipeline I have looked at. Someone computes a daily P90, stores it, and later builds a weekly chart by averaging the seven daily values. The chart looks reasonable. It is wrong.

Another illustrative example. A busy day has 40 builds, six of which run long, and its P90 is 81 minutes. A quiet day has 10 builds, all quick, and its P90 is 35 minutes. Average the two P90s and you get 58 minutes. Pool all 50 builds and compute P90 properly and you get 78 minutes.

Twenty minutes, gone by arithmeticAveraging the daily P90s gives the quiet day the same weight as the busy one, even though the busy day had four times as many builds and every slow one. The averaged number hides most of the tail, and it does so most on the days that matter.

The rule is simple: percentiles must be computed from the raw values, or from a data structure designed to merge them. You can sum counts and average means. You cannot average P90s, and you cannot take the P90 of a set of P90s.

Monitoring tools have the same trap built in, and it is worth knowing which metric type you are using. Datadog is a good example. Its histogram metric type computes percentiles on each Agent, per host and per flush interval. So a P95 graphed across a fleet of hosts is built from per-host percentiles, not from all the raw values together. Its distribution type sends the values to be aggregated server-side, using the DDSketch data structure, and Datadog documents those percentiles as globally accurate across your infrastructure. If your CI agents report durations as histograms and you graph a fleet-wide P90, you have quietly averaged percentiles.

The same applies to any pipeline you build yourself. Store raw durations, or store a mergeable sketch. Store one percentile per day and you have thrown away the information you need to answer the next question.

08 · What Moved The Tail

Why Parallelism Hits P90 Harder Than P50

Once the metric was P90, the question became: what makes a build land in the tail? For integration-heavy pipelines, a common answer is that the build is waiting on its longest serial path. Wall-clock time for a pipeline is not the sum of its work. It is the length of the slowest chain of steps that must run one after another. A large serial suite sets that length for every build that runs it.

That is why parallelisation is a tail tool more than a median tool. Splitting a suite that runs for an hour into shards that run side by side shortens the critical path directly. Builds that were long because of that suite get much shorter. Builds that were already short barely change. The distribution does not slide left evenly. Its right side gets pulled in, which is exactly the part P90 measures.

Where parallelisation shortens the critical path
Checkout & install
Build
One long serial integration run
Checkout & install
Build
Independent suites in parallel
Shared-state suites, still serial

The work spanned integration-test suites across ten product and platform domains. The important word is safe. A suite is safe to parallelise when it does not depend on state another suite also touches: a shared database fixture, a global cache, a singleton service, an ordering assumption nobody wrote down. Those suites stayed serial. The temptation to parallelise them too is real, because they are often the slowest ones, but a test that passes or fails depending on what ran next to it is worse than a slow test.

Which is how the three P90s moved: 81 to 52 minutes for successful builds, 76 to 40 for backend pull requests and 88 to 58 for frontend pull requests. The backend pull-request tail moved most, nearly halving. That is consistent with the idea that its tail was most dominated by long serial runs, though I would not generalise it into a rule. Every pipeline's tail has its own cause, and the first job is always to find it rather than assume it.

Find the tail's cause first

Pull the slowest tenth of builds for one segment and compare their step timings with the median build's. If the same step is long in most of them, you have a critical-path problem. If different steps are long each time, you probably have a queueing, cache or infrastructure problem, and parallelism will not fix it.

09 · The Tradeoffs

Optimising The Tail Creates New Tails

Targeting P90 is not free, and anyone who tells you parallelisation is a pure win has not looked at what happens after it ships.

  • The slowest shard sets the pace. A parallel stage finishes when its last shard finishes. If each of eight shards independently has a one-in-ten chance of running slow, the stage has a 1 - 0.98 ≈ 57% chance that at least one does. More shards means more chances for one of them to straggle. Balance shards by measured duration, not by file count, and keep checking it. Suites grow unevenly.
  • Queue time moves into the tail. Parallel stages ask for more agents at once. At peak hours, the build may wait for capacity instead of waiting for tests. If your P90 is measured from the start of execution rather than from the request, you will miss this entirely. That is one more reason to write down where the clock starts.
  • Compute cost goes up. Each shard repeats setup: checkout, install, warm-up, fixtures. Wall-clock time drops, total machine time often rises. That is usually a good trade for developer time, but it is a trade, and someone will eventually ask about the bill.
  • A faster pipeline can be a less trustworthy one. Hidden shared state that was harmless in a serial run becomes an intermittent failure in a parallel one. If P90 drops while the rate of flaky failures rises, engineers rerun more often, and every rerun is another build on their clock. You can lower the metric and still make the experience worse.

That last point is why I am wary of P90 as the only number. A tail metric needs a guardrail metric beside it. Flake rate is the obvious one, and measuring it properly is its own discipline. One green rerun proves very little, which is why the flaky-test detection I built runs the full suite twenty times against a known-green commit before scoring anything. Duration and reliability have to be read together, because each one is easy to improve at the other's expense.

A tail metric without a reliability guardrail is an invitation to make CI fast and wrong.

10 · The Decision Framework

Which Percentile To Put On Which Dashboard

If I were setting up CI metrics from scratch for a team today, this is the split I would start with. It is not universal, but it maps each number to a question someone actually asks.

QuestionMetricWhy
What does CI cost us in compute?Mean and totalMoney adds up linearly, so the mean is the right tool here.
What does a normal build feel like?P50Moves with improvements every build benefits from.
What do engineers plan around?P90Captures the slow builds that change behaviour.
Is CI predictable?P90 ÷ P50A ratio near 1 is predictable. A ratio near 2 is a lottery.
Did something break badly?P99 or max, as an alertGood at catching outliers, bad as a target.
Is faster still trustworthy?Flake rate, rerun rateThe guardrail that keeps duration work honest.

A few habits make this hold up over time:

  • Show P50 and P90 on the same chart. The space between the lines is the information. A median line on its own can stay flat while the tail climbs underneath it.
  • Set targets per segment. A frontend pipeline and a backend pipeline have different work and different floors. One shared target either goes easy on one or is unfair to the other.
  • Report before and after with the same definition. Same segment, same window length, same clock start, same percentile formula. Otherwise you are comparing two different metrics that happen to share a name.
  • Say what you did not measure. I have only given P90s in this piece because those are the numbers I can defend. A good metrics write-up is clear about its blind spots.
11 · The Short Version

Measure The Build People Remember

  • CI durations have a long right tail. The mean describes a build that does not exist, and the median describes the one nobody complains about.
  • P50 is the routine cost, P75 is the bad-but-common case (the level Core Web Vitals use), and P90 is the slow build that changes how engineers work.
  • One in ten per build compounds quickly per engineer. Five pushes a day gives roughly a 41% chance of hitting the tail at least once.
  • Segment by pipeline, separate failed builds, fix the window, write down where the clock starts and report n.
  • Never average percentiles. Compute them from raw values or a mergeable sketch, and check whether your monitoring metric type does that for you.
  • Parallelising safe suites shortens the critical path, which is why it moves P90 more than P50. Here it took successful-build P90 from 81 to 52 minutes, backend PR P90 from 76 to 40 and frontend PR P90 from 88 to 58. Shared-state tests stayed serial.
  • Pair every duration target with a reliability guardrail. A fast pipeline that flakes is not faster for anyone.

The most useful thing the P90 target did was not the 29 minutes. It was making the argument concrete. "CI feels slow" is a complaint you can nod along to and do nothing about. "One build in ten takes over 80 minutes" is a problem with a size, a segment and an owner. Pick the percentile that describes the pain, write down exactly how you compute it, and then go and find out what lives in the tail.

The P90 figures (successful builds 81 to 52 minutes, backend pull requests 76 to 40, frontend pull requests 88 to 58) are from CI pipelines on a large SaaS platform, measured before and after parallelising safe integration-test suites across ten product and platform domains; shared-state tests were kept serial. Median values are deliberately not reported. The twenty-build dataset, the six-minute improvement and the two-day averaging example are illustrative, constructed to show how the statistics behave, and are not pipeline data. The probabilities in sections 05 and 09 assume independent builds or shards. Core Web Vitals reasoning is from web.dev, "How the Core Web Vitals metrics thresholds were defined". The 10 ms / one second / 100 servers / 63% example is from Dean and Barroso, "The Tail at Scale", Communications of the ACM 56(2), 2013. Datadog histogram and distribution behaviour is from Datadog's Distributions documentation, checked in November 2026. Cover photo by Luke Chesser on Unsplash.