Terminology (6)Terms used in this lesson
Term on the front, definition on the back. Paste with tabs between fields and a new line between cards, or import the download in Anki as Basic.
- Linear growth
- Adding the same amount each step. After r steps the total has grown by r times that amount.
- Exponential growth
- Multiplying by the same factor each step. After r steps the total has been multiplied by the factor to the power r.
- Logarithmic growth
- The number of multiplying steps needed to reach a size grows like the logarithm of that size: doubling the size adds one step.
- Fan-out Also branching factor
- How many others each participant contacts per round. With fan-out f the informed count multiplies by f + 1.
- Concurrency limit
- A cap on how much work can happen in one step. It turns the exponential phase of a process into a linear tail.
- Doubling time
- How long a quantity growing at a steady rate takes to double: ln 2 divided by ln(1 + rate), about 70 divided by the percentage rate.
Why this matters
Rollouts, gossip protocols, cache warm-up, retries and user growth all multiply. Search trees and binary search shrink by a factor. Estimating them as if they added a fixed amount per step is off by orders of magnitude, and a limit somewhere in the system can turn a fast multiplying process into a slower linear tail. This broadcast is an ideal planning model: real gossip may contact nodes that already know the change or lose deliveries, so it can take longer.
This lesson assumes logarithms and powers of two from earlier lessons.
How growth rules determine the estimate
Linear growth adds a fixed amount each step. Exponential growth multiplies the current amount by a fixed factor. A logarithm reverses that multiplication: it asks how many factors are needed to reach a target. Counting complete rounds then requires a whole-number boundary decision.
A delivery cap can change the rule during the process. Before it binds, the informed population determines how much can be sent; afterward, the cap determines the new deliveries per round. Estimate those successive phases using the stated ideal model, including its distinct recipients and successful sends.
01Repeated doubling
Repeated doubling
A configuration controller plans a broadcast through a 20,000-node fleet. Its model assigns each informed node three distinct uninformed peers per round, with no failed or duplicate sends. A fleet-wide cap of 1,000 new deliveries per round changes the completion estimate. Work out where multiplying gives way to adding.
If the informed count doubles each round, after r rounds it is 2^r. The rounds needed to reach n are the smallest r with 2^r ≥ n, which is log₂ n rounded up. Predict the three lines this program prints.
const nodes = 2 ** 49 + 1; // just past a power of two
console.log(Math.ceil(Math.log2(20_000))); // doubling to a 20,000-node fleet
console.log(Math.ceil(Math.log2(nodes))); // the same formula, far larger
let rounds = 0;
for (let count = 1; count < nodes; count *= 2) rounds++;
console.log(rounds); // counting with integers
Math.log2 returns a double. Numbers are exact integers up to 2⁵³, but log2 of 2⁴⁹ + 1 is closer to 49 than to any other double, so it returns 49. Count with integers, or use the length of n − 1 in binary.
02Multiply by 1 + f
Multiply by 1 + f
With fan-out 3, each informed node tells 3 new nodes and stays informed itself, so the count multiplies by 4 each round. The rounds to reach n are log₄ n rounded up.
Computing log₄ n as Math.log(n) / Math.log(4) can land a hair above an integer for an exact power and round up one round too many. Multiplying an integer counter until it reaches n takes at most a few dozen steps and is exact.
03A cap makes a linear tail
A cap makes a linear tail
Now the network accepts at most 1,000 new connections per round. The count still multiplies by 4 while the informed nodes would add fewer than 1,000.
| Round | Added | Informed |
|---|---|---|
| 0 | — | 1 |
| 5 | 768 | 1,024 |
| 6 | 1,000 (3,072 asked) | 2,024 |
| 7 | 1,000 | 3,024 |
| 24 | 976 (last nodes) | 20,000 |
04Compute the tail
Compute the tail
After round 5, 1,024 nodes are informed and 18,976 remain. At 1,000 per round they take ⌈18,976 / 1,000⌉ = 19 rounds, so the broadcast takes 24 rounds instead of 8. A loop that simulates every round works for this case, but with a cap of 1 and 10¹⁵ nodes it would run 10¹⁵ times. Multiply while the cap does not bind, then divide once.
Taking the larger of the two estimates, 8 rounds uncapped or ⌈(n − 1) / 1,000⌉ = 20 rounds fully linear, gives 20. The exponential phase and the linear tail happen one after the other, so their rounds add.
05Growth rates and doubling time
Growth rates and doubling time
06Estimate the broadcast
Estimate the broadcast
The controller first needs the least whole number of doubling rounds, including a target just beyond a large power. Its assigned fan-out then changes the multiplication factor to 1 + f. The global delivery cap introduces a second phase: compute when it binds, then count the remaining full or partial rounds without simulating a potentially enormous tail.
A cluster broadcast
Count doubling rounds, count fan-out rounds, then respect the rate limit.
In the frontend A rollout estimate in Next.js and Svelte Optional
A rollout dashboard shows rounds left from the current informed count. The estimate uses the same multiply-then-divide rule, so it stays fast even when the tail is long, and it is memoized or derived so it reruns only when the inputs change. It uses the lab’s whole-number bounds and requires at least one informed node; unavailable inputs produce no estimate instead of a nonprogressing loop. The final round stops at the fleet size.
import { useMemo } from "react";
// Ideal collision-free deliveries; final partial rounds count as whole rounds.
function roundsLeft(
nodes: number,
informed: number,
fanout: number,
cap: number
): number | null {
if (
![nodes, informed, fanout, cap].every(Number.isSafeInteger) ||
nodes < 1 ||
nodes > 2 ** 52 ||
informed < 1 ||
informed > nodes ||
fanout < 1 ||
fanout > 1_000 ||
cap < 1 ||
cap > 2 ** 52
)
return null;
let count = informed;
let rounds = 0;
while (count < nodes) {
const added = count * fanout;
if (added >= cap) return rounds + Math.ceil((nodes - count) / cap);
count += added;
rounds++;
}
return rounds;
}
export function RolloutEta({
nodes,
informed,
fanout,
cap,
secondsPerRound
}: {
nodes: number;
informed: number;
fanout: number;
cap: number;
secondsPerRound: number;
}) {
const rounds = useMemo(
() => roundsLeft(nodes, informed, fanout, cap),
[nodes, informed, fanout, cap]
);
if (
rounds === null ||
!Number.isFinite(secondsPerRound) ||
secondsPerRound <= 0 ||
secondsPerRound > 3_600
) {
return <p>Estimate unavailable</p>;
}
return (
<p>
{rounds} rounds left, about {Math.ceil((rounds * secondsPerRound) / 60)} min
</p>
);
}
See React useMemo and Svelte $derived.
Check this idea later
Sources
- ECMAScript: Math.log2
- Go: bits.Len64
- Rust: u64::ilog2
- C++: std::bit_width
- Easley and Kleinberg, Networks, Crowds, and Markets (cascades and spreading)
Values above were run in Node 22, Go 1.27, Rust 1.99 and Apple clang 17. The cluster is a worked model.
Sign in to keep your read marks on every device. Sign in
Was this helpful?