Small PRs and frequent deploys only speed you up once CI/CD is fast

Continuous delivery asks for small batches: small pull requests, merged and deployed often. Each batch pays a fixed cost, call it KK: a CI run someone waits on, a review, a release. Smaller batches pay it more often. Finished work waiting in an unshipped batch costs something too: late feedback, drift from main, a larger blast radius. Call that the holding cost hh, what one unit of work costs for each unit of time it waits. Bigger batches hold more work for longer. The best size balances the two.

This is the Economic Order Quantity, which Ford Harris derived in 1913 for how many parts a factory should make per run [1] and Donald Reinertsen carries into product development [2]. With work arriving at rate DD, batches of QQ pay the fixed cost D/QD/Q times per unit time and hold on average Q/2Q/2 units of waiting work, so the cost per unit time is

C(Q)=KDQ+hQ2.C(Q) = \frac{KD}{Q} + \frac{hQ}{2}.

In software both costs are mostly time, so CC is the time a batch size costs a team each week: hours spent waiting on CI, review and release, plus the delay finished work spends unshipped. The batch term falls as QQ grows and the waiting term rises, and their sum is smallest where they are equal: the best batch spends as much on batch overhead as on waiting work. Each term is then hQ∗/2hQ^*/2, so

Q∗=2KDh,C(Q∗)=hQ∗=2KDh.Q^* = \sqrt{\frac{2KD}{h}}, \qquad C(Q^*) = hQ^* = \sqrt{2KDh}.
Why the minimum is where the two costs are equal

The two terms multiply to KDh/2KDh/2, which doesn't depend on QQ. Two positive numbers with a fixed product have their smallest sum when they are equal, since a+b≥2aba + b \ge 2\sqrt{ab} with equality at a=ba = b (the AM–GM inequality). Setting the derivative −KD/Q2+h/2-KD/Q^2 + h/2 to zero gives the same point.

So batch size is an output of the costs, not a policy, and forcing it off the optimum costs time. Measure a batch against the optimum, x=Q/Q∗x = Q/Q^*: the batch term scales by 1/x1/x and the waiting term by xx, and since the two split the minimum evenly,

C(Q)C(Q∗)=12(x+1x).\frac{C(Q)}{C(Q^*)} = \frac{1}{2}\left(x + \frac{1}{x}\right).

"Make smaller PRs" while CI takes 45 minutes pushes xx below 1. At a quarter of the optimal size, x=1/4x = 1/4, the team loses 12(4+14)≈2.1\tfrac{1}{2}(4 + \tfrac{1}{4}) \approx 2.1 times the minimum, so people resist for a sound reason.

The formula names the lever instead. DD is how much work arrives and hh is what waiting costs; neither is the team's to set. KK is: it's the pipeline. Faster CI and automated deploys lower KK, and then two things fall as K\sqrt{K}. Q∗Q^* falls, so smaller PRs become the best choice rather than a sacrifice. C(Q∗)C(Q^*) falls, so the floor on the hours the team loses each week drops. The square root sets the exchange rate: a pipeline four times cheaper justifies PRs half the size, not a quarter. Toyota made the same move in manufacturing with Shigeo Shingo's single-minute exchange of die, which cut die changes from hours to minutes and made small lots pay.

Economic batch sizeDelay cost against PR size, both relative to today's best. On the slow CI/CD curve the best size is 1 at cost 1; mandating quarter-size PRs climbs the curve to 2.1 times the cost. With CI/CD four times cheaper, the curve drops and its best is half the size at half the cost.0×1×2× cost0×1×2×3×PR size, relative to today's besttoday's bestmandate ¼-size PRs: 2.1× costfast CI/CD: best is ½ size, ½ cost
  • slow CI/CD
  • CI/CD four times cheaper
Forcing smaller PRs climbs the slow curve; cheaper CI/CD lowers the curve and moves its best size down.

The cost curve is also flat at the bottom: missing Q∗Q^* by a factor of two either way, x=2x = 2 or x=1/2x = 1/2, costs 12(2+12)=1.25\tfrac{1}{2}(2 + \tfrac{1}{2}) = 1.25 times the minimum. Getting the pipeline cheap matters far more than tuning the batch size exactly.

References

  1. How Many Parts to Make at Once [link]
    Harris, F. W., 1990. Operations Research, Vol 38(6), pp. 947–950. Institute for Operations Research and the Management Sciences (INFORMS). DOI: 10.1287/opre.38.6.947

  2. The Principles of Product Development Flow: Second Generation Lean Product Development
    Reinertsen, D. G., 2009. Celeritas Publishing.