5D Library › Enterprise Bottleneck Diagnostics, SKU Cannibalization Audits and Automation Return Bounds · 中文
Chapter 8. Finding the Bottleneck in the Logs, a Contract Ledger and a Pre-Registered Switchback Experiment
Estimating loads from event logs
The first step of a diagnosis is measurement, not interviews. The network of Chapter 1 is simulated job by job for 32 days (the first 2 as warm-up), and each day’s event log gives every team’s busy fraction (busy staff time divided by headcount times one day).
Calculation
# Chapter 8. p14: Finding the bottleneck from event logs. The network of
# p01 is simulated job by job for 32 days (2 days warm-up) at 20 jobs a
# day; each day's log gives every team's busy fraction (busy server time
# / (servers x 1 day)). How often does a sample of k logged days name the
# right team? Bootstrap over days, seed 83, 2,000 resamples per k.
import heapq
import importlib.util
import random
def load(name):
spec = importlib.util.spec_from_file_location(name, name + ".py")
m = importlib.util.module_from_spec(spec)
spec.loader.exec_module(m)
return m
p01 = load("p01_jackson_open")
C, MU = p01.BASE["c"], p01.BASE["mu"]
DAYS, WARM = 32, 2
def simulate(rng, lam=20.0):
busy = [[0.0] * DAYS for _ in range(4)]
free = list(C)
queue = [[] for _ in range(4)]
ev = [(rng.expovariate(lam), 0, -1)] # (time, kind, station)
seq = 0
def add_busy(i, t0, t1):
while t0 < t1 and int(t0) < DAYS:
d = int(t0)
step = min(t1, d + 1) - t0
busy[i][d] += step
t0 += step
def start(i, t):
nonlocal seq
free[i] -= 1
s = rng.expovariate(MU[i])
add_busy(i, t, t + s)
seq += 1
heapq.heappush(ev, (t + s, seq, i))
def arrive(i, t):
if free[i] > 0:
start(i, t)
else:
queue[i].append(t)
while ev:
t, kind, i = heapq.heappop(ev)
if t >= DAYS:
break
if i < 0:
arrive(0, t)
heapq.heappush(ev, (t + rng.expovariate(lam), 0, -1))
continue
free[i] += 1
if queue[i]:
queue[i].pop(0)
start(i, t)
u, acc = rng.random(), 0.0
for j in range(4):
acc += p01.ROUTE[i][j]
if u < acc:
arrive(j, t)
break
return [[busy[i][d] / C[i] for d in range(WARM, DAYS)]
for i in range(4)]
if __name__ == "__main__":
rng = random.Random(83)
load_ = simulate(rng)
n = len(load_[0])
true = p01.network(20.0, C, MU)[0]
print(" team true load logged load ({} days)".format(n))
for i, name in enumerate(p01.NAMES):
print(" {:<12} {:9.3f} {:11.3f}".format(
name, true[i], sum(load_[i]) / n))
for k in (1, 3, 7, 14, 30):
hit = 0
for _ in range(2000):
days = [rng.randrange(n) for _ in range(k)]
est = [sum(load_[i][d] for d in days) for i in range(4)]
hit += max(range(4), key=lambda i: est[i]) == 2
print(" {:2d} logged days: bottleneck named correctly {:.3f}"
.format(k, hit / 2000))
# team true load logged load (30 days)
# content 0.714 0.778
# acquisition 0.625 0.678
# conversion 0.833 0.858
# fulfilment 0.579 0.553
# 1 logged days: bottleneck named correctly 0.526
# 3 logged days: bottleneck named correctly 0.716
# 7 logged days: bottleneck named correctly 0.827
# 14 logged days: bottleneck named correctly 0.904
# 30 logged days: bottleneck named correctly 0.976Thirty days of logs estimate the loads at content 0.778, acquisition 0.678, conversion 0.858 and fulfilment 0.553 (theoretical values 0.714, 0.625, 0.833 and 0.579). The logs do find the bottleneck, but they need enough days: with 1 day the bottleneck is named correctly with probability 0.526; with 3 days 0.716; 7 days 0.827; 14 days 0.904; 30 days 0.976. The content team’s load is only a little over a tenth below conversion’s, and short-run random variation is enough to rank the two wrongly.
A 24-month contract ledger
Calculation
# Chapter 8. p15: A 24-month engagement ledger. Contracts from p09, each
# with the base fee that gives the consultant a certainty equivalent of
# RM 25k a month: the best share beta*, a 50% share, and a flat fee
# (beta 0). The gain ramps up linearly over the first 6 months; money is
# discounted at 1% a month. Figures in RM 1k, present values.
import importlib.util
def load(name):
spec = importlib.util.spec_from_file_location(name, name + ".py")
m = importlib.util.module_from_spec(spec)
spec.loader.exec_module(m)
return m
p09 = load("p09_gainshare")
SIGMA = 40.0
def ledger(beta):
ec, ef = beta * p09.A, (1 - beta) * p09.B
gain = p09.A * ec + p09.B * ef
fee = p09.base_fee(beta, SIGMA)
pv = {"gain": 0.0, "fees": 0.0, "effort": 0.0}
for t in range(1, 25):
ramp = min(t / 6, 1.0)
df = 1.01 ** -t
pv["gain"] += df * ramp * gain
pv["fees"] += df * (fee + beta * ramp * gain)
pv["effort"] += df * ramp * ef ** 2 / 2
pv["client"] = pv["gain"] - pv["fees"] - pv["effort"]
return pv
if __name__ == "__main__":
b = p09.best(SIGMA)
print(" contract PV gain PV fees client effort client net")
for label, beta in (("beta* = {:.3f}".format(b), b), ("beta = 0.5", 0.5),
("flat fee", 0.0)):
v = ledger(beta)
print(" {:<16} {:8,.0f} {:8,.0f} {:14,.0f} {:11,.0f}".format(
label, v["gain"], v["fees"], v["effort"], v["client"]))
# contract PV gain PV fees client effort client net
# beta* = 0.214 1,622 519 580 523
# beta = 0.5 1,278 629 235 415
# flat fee 1,880 531 940 409With the three contracts of Chapter 5 (each with the base fee that gives the consultant a certainty equivalent of RM 25k a month), the gain ramps up linearly over the first 6 months and money is discounted at 1% a month. At the best share of 0.214: present value of the gain 1,622 (RM thousand), of the consultant’s fees 519, of the company’s own effort 580, company net 523. At a share of 0.5 the gain falls to 1,278 and the company nets 415. With a flat fee the gain is highest (1,880), because a company that keeps all of the improvement puts in the most effort, but its own effort cost is also highest (940), and it nets 409. The sharing contract is better for the company not because the consultant’s fees are lower but because both sides’ efforts are closer to the best.
Note
A four-step check. First, estimate each team’s load from at least two weeks of event logs, not from interviews or timesheets. Second, add capacity at the bottleneck first, and release upstream work at the bottleneck’s pace; improvements at non-bottlenecks should aim first at reducing variability. Third, before delisting SKUs, estimate diversion ratios and incremental contributions, and confirm that the products receiving the demand have the capacity. Fourth, write a control group, annual reconciliation and audit triggers into sharing contracts, and state in the contract that results, good or bad, are settled by the same method (Kohavi et al. 2020).
A pre-registered switchback experiment
How can the effect of fixing a bottleneck be shown? By switching at random week by week: in some weeks the extra closer works, in others not; the first 2 days of each week are dropped as wash-out.
Calculation
# Chapter 8. p16: A pre-registered switchback test of a bottleneck fix.
# Weeks alternate at random between "extra closer on" and "off"; the
# outcome is closed sales per week, with week-to-week coefficient of
# variation 0.12. The first 2 days of each week are dropped as wash-out,
# which leaves 5 of 7 days and raises the CV by sqrt(7/5). Weeks per arm
# for power 0.80, two-sided alpha 0.05: 2 * ((1.96 + 0.84) * cv / lift)^2.
from math import ceil, sqrt
def weeks(lift, cv=0.12, washout=True):
c = cv * sqrt(7 / 5) if washout else cv
return ceil(2 * ((1.96 + 0.84) * c / lift) ** 2)
if __name__ == "__main__":
print(" lift weeks per arm (no wash-out / with wash-out)")
for lift in (0.05, 0.10, 0.15, 0.20):
print(" {:4.0%} {:3d} / {:3d}".format(
lift, weeks(lift, washout=False), weeks(lift)))
# lift weeks per arm (no wash-out / with wash-out)
# 5% 91 / 127
# 10% 23 / 32
# 15% 11 / 15
# 20% 6 / 8With a week-to-week coefficient of variation of 0.12 in sales, detecting a 10% lift needs 23 weeks per arm without wash-out and 32 with it; a 20% lift needs only 6 and 8 weeks; a 5% lift needs 91 and 127 weeks.
Hypothesis · not established
Pre-registered prediction (not yet tested): in the illustrative four-team structure, adding one closer to the conversion team raises weekly sales by at least 10%, while automation of the content team at the same cost raises them by less than 3%. What would show it wrong: in an experiment switching at random by week, the former’s lift is significantly below 10%, or the latter’s significantly above 3%.
Summary of the book
In a queueing network throughput is set by the bottleneck; automating a non-bottleneck can shorten lead times but cannot raise the ceiling on output, and pushing more work into the bottleneck only makes work in progress swell along a hyperbola and lets leads go cold. Self-cannibalization in a product line is read from diversion ratios and the margin dilution matrix: sub-line products whose recaptured margin exceeds their own margin lower total profit, and “cut 30%” is not a law. Under double moral hazard an outside consultant’s contract should be a small base fee plus a share of about a fifth of the gain, with the gain measured against a control and reconciled annually. Diagnosis produces no capacity by itself; its value lies in steering investment to the bottleneck.
References
Fan, Y. (2026). Enterprise Bottleneck Diagnostics, SKU Cannibalization Audits and Automation Return Bounds: Theory-of-Constraints Queueing Networks, Margin Dilution Matrices and Value-Based Advisory Pricing [企业瓶颈诊断、产品线自蚕食审计与自动化改造回报边界] (Version 1.0.0). 5D Library. https://doi.org/10.5281/zenodo.24090217 · Licensed under Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0).