Skip to content

fix(sim): bound the rendition ladder the transcoder will act on - #62

Merged
xevrion merged 1 commit into
xevrion:mainfrom
kevin9327:fix/rendition-bounds
Sep 7, 2026
Merged

fix(sim): bound the rendition ladder the transcoder will act on#62
xevrion merged 1 commit into
xevrion:mainfrom
kevin9327:fix/rendition-bounds

Conversation

@kevin9327

Copy link
Copy Markdown
Contributor

What

A design carrying a renditions count larger than the inspector can set does not make the farm slow,
it ends the process. The ladder is a loop that runs once per rendition per outgoing edge for every
finished job:

for (let n = 0; n < renditions; n++) {
  if (!ctx.emitDetached(state, edge, req.key)) break;
  ctx.countCustom(state, 'output', 1);
}

and the count it runs to is read like this:

const v = state.config.renditions;
return v !== undefined && v >= 1 ? Math.floor(v) : 3;

Infinity >= 1 is true and Math.floor leaves it alone, so the loop above has no end for it. A
large finite count has no ceiling either.

Measured

Running the decoded topology through the engine for 120 ticks:

renditions   what happens
NaN          fine: `NaN >= 1` is false, so the fallback of 3 catches it
Infinity     does not return (killed at 15s)
1e9          does not return (killed at 15s)

Against main the new test file cannot finish. The worker exits rather than reporting:

Caused by: Error: Worker exited unexpectedly
 Test Files   (1)
      Tests   (4)

Where it comes from

Not the inspector: its number input stops at 12. isTopology checks the nine core config numbers —
capacity, serviceMs, serviceCv, queueLimit, hitRate, errorRate, timeoutMs, retries,
rps — and not renditions, so a shared link, a .breakscale file and a restored session carry it
through untouched.

Fix

cfgRenditions rejects anything that is not a finite number and caps at MAX_RENDITIONS = 12, the
maximum the inspector already offers. A ladder is a small number by nature — 1080p, 720p, 480p — so
the ceiling is not a compromise, it is the shape of the thing.

The fallback of 3 and the v < 1 behaviour are unchanged.

Tests

src/sim/behaviour-resilience.bounds.test.ts, new. The ladder is observable as write amplification
on the store behind the farm, which is the lesson the component exists to teach, so that is what the
tests read:

  • a ladder of Infinity and of 1e9 both run, in well under a second
  • an absent count still lands between the two- and four-rendition ladders, which is what a fallback
    of three means where the number is visible
  • four renditions still write more to the store than two do, which is the check that the ceiling
    changed nothing a reader can reach

How I tested

Windows 11, Bun 1.3.14. bun run test is 933 passed across 40 files, up from 929 by the four new
tests, with nothing else moving. bun run typecheck, bun run lint and bun run format:check are
clean.

Same shape as #58, and a sibling of #60 (data-tier counts) and #61 (broker partitions). All three
touch different files and none depends on the others.

@kevin9327
kevin9327 requested a review from xevrion as a code owner September 6, 2026 11:48
@vercel

vercel Bot commented Sep 6, 2026

Copy link
Copy Markdown

@kevin9327 is attempting to deploy a commit to the whoarrryou's projects Team on Vercel.

A member of the Team first needs to authorize it.

@xevrion

xevrion commented Sep 7, 2026

Copy link
Copy Markdown
Owner

Confirmed the hang on main, Infinity really does lock it up rather than just run slow. LGTM, thanks!

@xevrion
xevrion merged commit dcb6980 into xevrion:main Sep 7, 2026
6 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants