Repository navigation
perf(ts): leave out runtime the codec's bundle never calls - #119
Conversation
Quest-Claim: ac82fbd881dca22c
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0115AT2ue6x9cT5e5J9SZtCn
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0115AT2ue6x9cT5e5J9SZtCn
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
kixelated
left a comment
There was a problem hiding this comment.
Automated review by review (OpenAI)
Reviewed commit: cdcb578
No actionable bugs found. The width-specific integer helpers preserve the existing signedness, limb normalization, shift checks, and fixed-width big-endian behavior. The structural inclusive-range check and type-only iterator declarations fit the runtime's supported representations.
Direction: focused tree-shaking improvements are preferable here to changing MIR lowering or adding a shared runtime driver. The modest 64/128-bit duplication is justified by keeping unused paths out of bundles; the plain error object also matches the documented representation.
Verification: static diff and surrounding-runtime inspection only. I did not run translation, tests, size measurements, or benchmarks; the reported size/performance results were not independently reproduced.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0115AT2ue6x9cT5e5J9SZtCn
Problem
quest/m2/ts-mir-size.md: the codec's bundle on
just ts benchwas larger than the THIR lowering's (at most 30629 bytes minified and 9422 gzipped). On current main it measured 30722 and 9819. Most of it was runtime code the bundle carried but never called.Approach
Each cut leaves out runtime the codec never calls; none changes what runs.
boundstests"exhausted" in r, notinstanceof RangeInclusive, sobtreeRangeno longer pulls in the whole classleading_*, and{from,to}_be_bytessplit into a function per width, so a bundle withoutu128drops the bigint pathsTryFromIntErrora plain object, as the README maps a struct without drop glueu32/i32::from_be_bytesread one unrolled word, whichu64's now shares, not a byte loopIter'snextBackandlendeclared through an interface, not stubbed with a throwTargets: codec at most 30629 / 9422, handoff at most 3458 gzipped. Both met.
Speed, Chrome 155,
--route main=<main's translations>in the same run, translated ÷ main per workload:Each outlier past 10% either way had A/A on the other side (A/A differed from translated by up to 38% in a run). Host: Ryzen 9 5900XT, 32 threads, load average 0.4 to 6.3 during the runs, each run through
quest gate.Choices made without asking:
nextBackorlennow throws JS'sTypeError: ... is not a functioninstead of the runtime'srust2-ts: an iterator without .... Rust calls either only where std implements the trait, so it was a stub for a translator bug; it still fails loud, with the method's name.wordandputWordread and write a 32-bit word unrolled; 64-bitto_be_bytesno longer allocates an array of words.Impact
rt.TryFromIntErroris a type, not a class:new rt.TryFromIntError(...)is gone. The translator only ever names it as a type.rt.Iter'snextBackandlenare no longer inherited stubs; subclasses that implement them are unchanged.Alternatives
Iter's*[Symbol.iterator](about 40 bytes gzipped):debugListEntriestakes anyIterable, anIteramong them.ok_or(e)?into oneundefinedtest: smaller and allocation-free, but a translator change for about 10 bytes a site.if (a) { if (b) S }asif (a && b) S, andelse ifchains asswitch: Bun keeps both as written, but repeats like these gzip to little.Follow-ups
Two open PRs grow the codec's bundle well past the target again:
advanceBy,countItems,lastItem, and[Symbol.dispose], and class methods can't be tree-shaken, so every bundle using an adaptor carries them all.#104 takes off 105 / 29.
(written by Opus 5.5)
🤖 Generated with Claude Code
https://claude.ai/code/session_0115AT2ue6x9cT5e5J9SZtCn