Repository navigation
feat(ts): time Timestamp's checked_add and Ord in the bench - #108
Conversation
Quest-Claim: d509131a2b9b1a66
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: ba5cf56
No actionable bugs found in the new Timestamp workloads, their generated translations, or benchmark integration. The inputs stay within the hand-written route's safe-number range, and the finer-scale-first ordering makes its equality behavior agree with Rust's tie-break for this workload.
Direction looks sound: separate stamping and interleaving cases expose the two paths without complicating the harness, while retaining output checks against wasm. These are workload-level timings (including timestamp updates/allocation), not isolated operator costs; the reported A/A variation also limits small performance claims.
Verification: source/snapshot review only. I did not execute tests or reproduce the browser benchmarks.
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
Problem
#89 moved
Timestamp::checked_addandOrd(cross products compared inu128) offbigint, but no bench workload reached them, so Chrome never timed them.Approach
fixtures/codec/src/bench.rsvendors moq-net'sTimestamp(scale as a plainu64, notNonZero) with itschecked_addandOrd, and adds two workloads besidetime/u128:time/checked-add/micros: a video track's frames stamped 33,333 µs apart bychecked_add, from 1.9e14 µs since moq's epoch.time/ord/micros-48k: that track interleaved with a 48 kHz audio track byOrd, one comparison per frame. Every value is under 2^53 and every cross product past it.bench/timestamp.ts): moq's ownjs/netTimestamp, whoseisBeforecompares across scales inbigint. It has nochecked_add, so the route adds with its constructor's check. The first track has the finer scale, so a tie resolves the same way as Rust's(scale, value)tie-break.interleaveorders witha < b, which the inheritedltfrom #107 now translates aspartialCmp$PartialOrd(a, b) === -1, forwarding tocmp$Ord. The timings below were taken before that merge, witha.cmp(&b).is_lt()(cmp$Ord(a, b) < 0). After the merge, a one-round output check passed on every route and engine. Its timings are only a smoke test, and they show no break. I did not rerun the timed bench for one forwarding call.rescale.tssaid op 8, but it is op 9.Measurements
Two
just ts benchruns throughquest gate, AMD Ryzen 9 5900XT. Median ns per timestamp, run 1 / run 2. There is no main baseline, since main has no such workload.Native is 0.74-0.76 ns (checked-add) and 1.55-1.60 ns (ord). wasm is 1.55-2.8 ns and 7.8-9.3 ns. In Chrome, translated
Ordruns 1.7x faster than moq'sbigintisBefore, andchecked_addruns about 1.5x slower than a plain number add. Firefox runs both translated routes about 2.4x slower than hand-written, the same gap as on itstime/u64rows. The run-1 Chrome checked-add A/A gap (12.4 against 8.23) is the noise floor at ~10 ns per call.Bundle size (minified, raw/gzip): translated 32765/10464 and hand-written 34067/10990. Both now carry the new workloads, and the hand-written route also pulls in moq's
time.ts.Impact
Alternatives
bigintfor the hand-written route, asrescale.tsdoes: dropped in favor of moq's ownTimestamp, which is what moq's TypeScript ships for ordering.Follow-ups
stamp, the loop-invariantlet step = Timestamp { .. }is rebuilt inside the loop (const step2 = { value: step, scale }per iteration, seeexpected/bench.ts). That is an allocation per call that native Rust doesn't make. It is a candidate quest for/quest-plan.Checks
just check,just test, andquest check --base origin/mainpass after merging main (with #107). Ran two fulljust ts benchruns (Node, Bun, Chrome, Firefox), and every route's output matched native Rust's.(written by Opus 5.5)
🤖 Generated with Claude Code
https://claude.ai/code/session_0115AT2ue6x9cT5e5J9SZtCn