Skip to content

Portable js benchmarking#191

Merged
tomusdrw merged 6 commits into
mainfrom
td-benchmark-improvements
Mar 4, 2026
Merged

Portable js benchmarking#191
tomusdrw merged 6 commits into
mainfrom
td-benchmark-improvements

Conversation

@tomusdrw
Copy link
Copy Markdown
Owner

@tomusdrw tomusdrw commented Mar 3, 2026

No description provided.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 3, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This PR moves several module-level utility functions into exported classes with static methods (Inst, IntMath, OutcomeData), updates call sites across the assembly codebase to use the new class-qualified APIs (e.g., Inst.reg, IntMath.minI32, OutcomeData.ok), refactors instruction return helpers into OutcomeData static methods, adjusts many instruction implementations and tests to use Inst accessors, and adds a pluggable PVM API with dynamic backend loading in benchmarking and trace-replay tooling.

Possibly related PRs

  • Avoid float operations #146: Introduced/modified minI32/minU32 helpers and their call sites; directly overlaps with moving those functions into IntMath and updating usages.
  • JS build #178: Changes the same code-level APIs (utils/outcome/math refactors) and likely touches identical call sites and symbols renamed to Inst/OutcomeData/IntMath.
  • Performance benchmarks and optimisations #184: Modifies assembly/instructions/outcome.ts and the ok helper behavior; may conflict with or complement the OutcomeData static-method refactor.

Suggested reviewers

  • mateuszsikora
  • DrEverr
🚥 Pre-merge checks | ❌ 3

❌ Failed checks (2 warnings, 1 inconclusive)

Check name Status Explanation Resolution
Description check ⚠️ Warning No pull request description was provided by the author. Without a description, it is impossible to assess whether the author intended to explain the changes. Add a detailed pull request description explaining the API refactoring (moving functions to static methods on classes) and the new portable JS benchmarking feature to help reviewers understand the rationale and scope of changes.
Docstring Coverage ⚠️ Warning Docstring coverage is 31.25% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'Portable js benchmarking' is related to the changeset but is quite vague. While the PR does add portable JS benchmarking support, the title is generic and doesn't convey the full scope of changes, which include significant API refactoring (moving functions to classes with static methods) across many files. Consider a more descriptive title that captures both the benchmarking feature and the underlying API refactoring, such as 'Refactor to class-based APIs and add portable JS benchmarking' or similar.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch td-benchmark-improvements

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot requested review from DrEverr and mateuszsikora March 3, 2026 18:02
@tomusdrw tomusdrw force-pushed the td-benchmark-improvements branch from 8338229 to b394a6a Compare March 3, 2026 18:04
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
bench/run.ts (1)

376-376: ⚠️ Potential issue | 🟡 Minor

Handle top-level async failures explicitly.

Line 376 invokes main() without a rejection handler. Add a terminal .catch(...) so CLI failures produce deterministic exit behavior and error reporting.

🔧 Proposed fix
-main();
+void main().catch((error) => {
+  console.error(error);
+  process.exit(1);
+});
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@bench/run.ts` at line 376, The top-level invocation main() lacks a rejection
handler; update the call site that currently calls main() to append a
.catch(...) which logs the error (using console.error or the existing logger)
and terminates the process with a non-zero exit code (e.g., process.exit(1));
specifically modify the main() invocation so any rejected promise from main is
caught, the error is reported (include error.stack/message), and process.exit(1)
is called to ensure deterministic CLI failure behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@bench/run.ts`:
- Around line 69-75: The portable-path double-cast in loadPvm masks export-shape
mismatches and defers failures until use; update loadPvm to import the module
into a temporary const (from "../dist/build/js/portable-bundle.js"), validate
that the imported object exposes the required PvmApi members (compare presence
and types of functions/properties expected by PvmApi, e.g., methods used
elsewhere on wasmPvm), and throw a clear Error if validation fails instead of
casting; also harden top-level async termination by changing the unhandled call
to main() to a handled one (e.g., await main() inside an async IIFE or call
main().catch(err => { console.error(..., err); process.exit(1); })) so any
rejected promise logs the error and exits with a deterministic non-zero code.

---

Outside diff comments:
In `@bench/run.ts`:
- Line 376: The top-level invocation main() lacks a rejection handler; update
the call site that currently calls main() to append a .catch(...) which logs the
error (using console.error or the existing logger) and terminates the process
with a non-zero exit code (e.g., process.exit(1)); specifically modify the
main() invocation so any rejected promise from main is caught, the error is
reported (include error.stack/message), and process.exit(1) is called to ensure
deterministic CLI failure behavior.

ℹ️ Review info

Configuration used: Path: .coderabbit.yml

Review profile: ASSERTIVE

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between c2b7f5a and 8338229.

📒 Files selected for processing (27)
  • assembly/arguments.ts
  • assembly/instructions/bit.test.ts
  • assembly/instructions/bit.ts
  • assembly/instructions/branch.test.ts
  • assembly/instructions/branch.ts
  • assembly/instructions/jump.ts
  • assembly/instructions/load.ts
  • assembly/instructions/logic.test.ts
  • assembly/instructions/logic.ts
  • assembly/instructions/math.test.ts
  • assembly/instructions/math.ts
  • assembly/instructions/misc.ts
  • assembly/instructions/mov.ts
  • assembly/instructions/outcome.ts
  • assembly/instructions/rot.test.ts
  • assembly/instructions/rot.ts
  • assembly/instructions/set.ts
  • assembly/instructions/shift.ts
  • assembly/instructions/store.ts
  • assembly/instructions/utils.ts
  • assembly/interpreter.ts
  • assembly/math.ts
  • assembly/memory.ts
  • assembly/program-build.ts
  • assembly/program.ts
  • bench/run.ts
  • bin/src/trace-replay.ts

Comment thread bench/run.ts
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (1)
bench/run.ts (1)

69-75: ⚠️ Potential issue | 🟠 Major

Harden backend loading and top-level async error handling.

Line 72 suppresses module-shape validation with a double cast, and Line 377 leaves async failures unhandled (main() without .catch). This can fail late and non-deterministically.

🔧 Proposed fix
+function assertPvmApi(mod: unknown): PvmApi {
+  const candidate = ((mod as { default?: unknown }).default ?? mod) as Record<string, unknown>;
+  const required = [
+    "HasMetadata",
+    "InputKind",
+    "prepareProgram",
+    "runProgram",
+    "pvmStart",
+    "pvmDestroy",
+    "pvmResume",
+    "pvmReadMemory",
+    "pvmWriteMemory",
+    "pvmSetRegisters",
+  ] as const;
+  for (const key of required) {
+    if (!(key in candidate)) {
+      throw new Error(`Invalid PVM module: missing "${key}" export`);
+    }
+  }
+  return candidate as PvmApi;
+}
+
 async function loadPvm(): Promise<PvmApi> {
   if (values.portable) {
-    // The portable build exposes the same API surface but has different nominal types.
-    return (await import("../dist/build/js/portable-bundle.js")) as unknown as PvmApi;
+    return assertPvmApi(await import("../dist/build/js/portable-bundle.js"));
   }
-  return wasmPvm;
+  return assertPvmApi(wasmPvm);
 }
-main();
+main().catch((err) => {
+  console.error(err);
+  process.exit(1);
+});
#!/bin/bash
set -euo pipefail

# 1) Verify risky cast and unhandled async entrypoint are still present.
rg -n 'as unknown as PvmApi|^main\(\);$' bench/run.ts

# 2) If portable bundle exists, verify required API keys are present in bundle text.
if fd 'portable-bundle\.js$' dist >/dev/null 2>&1; then
  bundle="$(fd 'portable-bundle\.js$' dist | head -n1)"
  rg -n 'HasMetadata|InputKind|prepareProgram|runProgram|pvmStart|pvmDestroy|pvmResume|pvmReadMemory|pvmWriteMemory|pvmSetRegisters' "$bundle"
fi

Also applies to: 377-377

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@bench/run.ts` around lines 69 - 75, Replace the unsafe double-cast in loadPvm
by validating the imported module actually implements the PvmApi surface (check
for required exports/methods like HasMetadata, InputKind, prepareProgram,
runProgram, pvmStart, pvmDestroy, pvmResume, pvmReadMemory, pvmWriteMemory,
pvmSetRegisters) and throw a descriptive error if any are missing rather than
returning as unknown as PvmApi; additionally, change the top-level startup call
to handle rejections from main() (replace the bare main() call with a promise
handler that logs the error and exits non‑zero) so async failures are
deterministic and reported.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@assembly/instructions/misc.ts`:
- Around line 20-25: The sbrk instruction can return a stale fault because the
shared faultRes isn't cleared before calling memory.sbrk; before invoking
memory.sbrk in the sbrk function, reset or reinitialize faultRes (e.g., clear
faultRes.isFault / set faultRes = { isFault: false, ... } or construct a fresh
FaultResult) so memory.sbrk cannot read a sticky fault, then call
memory.sbrk(...) and continue using OutcomeData.okOrFault(r, faultRes) as
before; update the code around sbrk, memory.sbrk, faultRes,
OutcomeData.okOrFault, and Inst.reg to ensure faultRes is freshly cleared each
call.

---

Duplicate comments:
In `@bench/run.ts`:
- Around line 69-75: Replace the unsafe double-cast in loadPvm by validating the
imported module actually implements the PvmApi surface (check for required
exports/methods like HasMetadata, InputKind, prepareProgram, runProgram,
pvmStart, pvmDestroy, pvmResume, pvmReadMemory, pvmWriteMemory, pvmSetRegisters)
and throw a descriptive error if any are missing rather than returning as
unknown as PvmApi; additionally, change the top-level startup call to handle
rejections from main() (replace the bare main() call with a promise handler that
logs the error and exits non‑zero) so async failures are deterministic and
reported.

ℹ️ Review info

Configuration used: Path: .coderabbit.yml

Review profile: ASSERTIVE

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 8338229 and b394a6a.

📒 Files selected for processing (26)
  • assembly/arguments.ts
  • assembly/instructions/bit.test.ts
  • assembly/instructions/bit.ts
  • assembly/instructions/branch.test.ts
  • assembly/instructions/branch.ts
  • assembly/instructions/jump.ts
  • assembly/instructions/load.ts
  • assembly/instructions/logic.test.ts
  • assembly/instructions/logic.ts
  • assembly/instructions/math.test.ts
  • assembly/instructions/math.ts
  • assembly/instructions/misc.ts
  • assembly/instructions/mov.ts
  • assembly/instructions/outcome.ts
  • assembly/instructions/rot.test.ts
  • assembly/instructions/rot.ts
  • assembly/instructions/set.ts
  • assembly/instructions/shift.ts
  • assembly/instructions/store.ts
  • assembly/instructions/utils.ts
  • assembly/math.ts
  • assembly/memory.ts
  • assembly/program-build.ts
  • assembly/program.ts
  • bench/run.ts
  • bin/src/trace-replay.ts

Comment thread assembly/instructions/misc.ts
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
bench/compare.ts (1)

368-390: ⚠️ Potential issue | 🟡 Minor

Combined regressions/improvements arrays lose "worst first" ordering.

When merging fibRegs with regs (and fibImps with imps), each array is individually sorted, but the combined result is not re-sorted. If both Fibonacci and regular benchmarks have regressions, they won't appear in true "worst first" order.

🔧 Proposed fix to maintain sort order
   // Regressions (combined)
   const allRegs = [...fibRegs, ...regs];
+  allRegs.sort((a, b) => b.diffPercent - a.diffPercent);
   if (allRegs.length > 0) {
     md += "\n<details><summary>Regressions (worst first)</summary>\n\n";
   // Improvements (combined)
   const allImps = [...fibImps, ...imps];
+  allImps.sort((a, b) => a.diffPercent - b.diffPercent);
   if (allImps.length > 0) {
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@bench/compare.ts` around lines 368 - 390, The combined arrays lose their
intended sort order because you simply concatenate fibRegs+regs and fibImps+imps
without re-sorting; after creating allRegs and allImps, sort them by diffPercent
(e.g., allRegs.sort((a,b)=>b.diffPercent - a.diffPercent) to preserve "worst
first" and allImps.sort((a,b)=>b.diffPercent - a.diffPercent) to show largest
improvements first) before iterating to build md; apply these sorts to the
variables allRegs and allImps in compare.ts (the locations where fibRegs, regs,
fibImps, and imps are merged).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@bench/compare.ts`:
- Around line 103-157: The Fibonacci comparison block duplicates logic used for
trace comparisons; extract a reusable helper (e.g., compareTraces or
compareBenchmarks) that accepts baseline and current arrays plus threshold and
returns { comparisons, regressions, improvements }; replace the in-place logic
that builds maps and computes diffMs/diffPercent, handles baseline medianMs ===
0, sets status, and sorts results with a call to that helper for both the
fibonacci and trace sections (referencing fibComparisons, fibRegressions,
fibImprovements and the equivalent trace variables) so the shared computation is
centralized and reused.

---

Outside diff comments:
In `@bench/compare.ts`:
- Around line 368-390: The combined arrays lose their intended sort order
because you simply concatenate fibRegs+regs and fibImps+imps without re-sorting;
after creating allRegs and allImps, sort them by diffPercent (e.g.,
allRegs.sort((a,b)=>b.diffPercent - a.diffPercent) to preserve "worst first" and
allImps.sort((a,b)=>b.diffPercent - a.diffPercent) to show largest improvements
first) before iterating to build md; apply these sorts to the variables allRegs
and allImps in compare.ts (the locations where fibRegs, regs, fibImps, and imps
are merged).

ℹ️ Review info

Configuration used: Path: .coderabbit.yml

Review profile: ASSERTIVE

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between b394a6a and eb5b308.

📒 Files selected for processing (1)
  • bench/compare.ts

Comment thread bench/compare.ts Outdated
The compare tool now includes fibonacci micro-benchmark results in
both console output and the PR markdown comment.
@tomusdrw tomusdrw force-pushed the td-benchmark-improvements branch from eb5b308 to 05d5455 Compare March 3, 2026 20:32
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
bench/compare.ts (2)

380-390: ⚠️ Potential issue | 🟡 Minor

Combined improvements array not re-sorted.

Same issue as regressions—the combined array should be re-sorted to maintain consistent ordering.

🔧 Proposed fix to re-sort combined improvements
   // Improvements (combined)
-  const allImps = [...fibImps, ...imps];
+  const allImps = [...fibImps, ...imps].sort((a, b) => a.diffPercent - b.diffPercent);
   if (allImps.length > 0) {
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@bench/compare.ts` around lines 380 - 390, The combined improvements array
allImps (created from fibImps and imps) is not re-sorted, causing inconsistent
ordering; update the code after constructing allImps to sort it the same way
other combined lists are sorted (e.g., sort allImps by diffPercent descending or
by the same comparator used for regressions) before iterating and rendering in
the Improvements details block so that entries appear in a consistent, expected
order.

263-280: ⚠️ Potential issue | 🟡 Minor

Console output inconsistency: Fibonacci regressions/improvements not listed in detail sections.

The allRegressions and allImprovements counts (lines 263-264) include Fibonacci results, but the detailed "Regressions" and "Improvements" sections (lines 268-280) only iterate over trace-specific arrays. This means the summary might show "Regressions: 5" while the detailed listing only shows 3 entries.

The markdown output correctly combines both (lines 369, 381), so the console output should match.

🔧 Proposed fix to include Fibonacci results in detailed console sections
-if (regressions.length > 0) {
+const allRegsConsole = [...fibRegressions, ...regressions].sort((a, b) => b.diffPercent - a.diffPercent);
+if (allRegsConsole.length > 0) {
   console.log("\n--- Regressions (worst first) ---\n");
-  for (const r of regressions) {
+  for (const r of allRegsConsole) {
     console.log(`  ${r.name.padEnd(40)} ${r.currentMs.toFixed(1).padStart(8)}ms  (+${r.diffPercent.toFixed(1)}%)`);
   }
 }

-if (improvements.length > 0) {
+const allImpsConsole = [...fibImprovements, ...improvements].sort((a, b) => a.diffPercent - b.diffPercent);
+if (allImpsConsole.length > 0) {
   console.log("\n--- Improvements ---\n");
-  for (const i of improvements) {
+  for (const i of allImpsConsole) {
     console.log(`  ${i.name.padEnd(40)} ${i.currentMs.toFixed(1).padStart(8)}ms  (${i.diffPercent.toFixed(1)}%)`);
   }
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@bench/compare.ts` around lines 263 - 280, The console summary counts use
regressions + fibRegressions and improvements + fibImprovements but the detailed
sections only iterate regressions and improvements; update the detailed
"Regressions" and "Improvements" console blocks to include Fibonacci entries by
iterating over combined arrays (e.g., use regressions.concat(fibRegressions) and
improvements.concat(fibImprovements) or merge them into new arrays before
printing), keeping the existing formatting and headers (and preserve
ordering/“worst first” logic for the combined regressions).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@bench/compare.ts`:
- Around line 368-378: The combined regressions array allRegs (created from
fibRegs and regs) is not re-sorted, so the "worst first" requirement is
violated; after concatenation, sort allRegs in-place by descending diffPercent
(e.g., use a comparator that orders by b.diffPercent - a.diffPercent) before
iterating to build the markdown so entries like r.name, r.baselineMs,
r.currentMs and r.diffPercent are emitted in worst-to-best order.

---

Outside diff comments:
In `@bench/compare.ts`:
- Around line 380-390: The combined improvements array allImps (created from
fibImps and imps) is not re-sorted, causing inconsistent ordering; update the
code after constructing allImps to sort it the same way other combined lists are
sorted (e.g., sort allImps by diffPercent descending or by the same comparator
used for regressions) before iterating and rendering in the Improvements details
block so that entries appear in a consistent, expected order.
- Around line 263-280: The console summary counts use regressions +
fibRegressions and improvements + fibImprovements but the detailed sections only
iterate regressions and improvements; update the detailed "Regressions" and
"Improvements" console blocks to include Fibonacci entries by iterating over
combined arrays (e.g., use regressions.concat(fibRegressions) and
improvements.concat(fibImprovements) or merge them into new arrays before
printing), keeping the existing formatting and headers (and preserve
ordering/“worst first” logic for the combined regressions).

ℹ️ Review info

Configuration used: Path: .coderabbit.yml

Review profile: ASSERTIVE

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between eb5b308 and 05d5455.

📒 Files selected for processing (1)
  • bench/compare.ts

Comment thread bench/compare.ts
@tomusdrw tomusdrw enabled auto-merge (squash) March 3, 2026 20:55
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (1)
bench/compare.ts (1)

332-346: ⚠️ Potential issue | 🟡 Minor

Re-sort combined markdown lists after concatenation.

Combined arrays are not globally ordered after merge. Regressions should remain worst-first, and improvements should remain best-first.

🔧 Suggested fix
-const allRegs = [...fibRegs, ...regs];
+const allRegs = [...fibRegs, ...regs].sort((a, b) => b.diffPercent - a.diffPercent);
@@
-const allImps = [...fibImps, ...imps];
+const allImps = [...fibImps, ...imps].sort((a, b) => a.diffPercent - b.diffPercent);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@bench/compare.ts` around lines 332 - 346, The merged arrays allRegs =
[...fibRegs, ...regs] and allImps = [...fibImps, ...imps] can be out of order
after concatenation; sort allRegs by r.diffPercent descending (worst-first) and
sort allImps by r.diffPercent ascending (best-first) immediately after creating
them so the markdown loop emits correctly ordered rows; update the code around
the allRegs/allImps declarations to call
.sort((a,b)=>b.diffPercent-a.diffPercent) for regressions and
.sort((a,b)=>a.diffPercent-b.diffPercent) for improvements before generating the
md.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@bench/compare.ts`:
- Around line 164-167: The current fibResult ternary silently skips comparison
when fibonacci data is present in only one suite; change it to explicitly handle
three cases: (1) if both baselineSuite.fibonacci and resultsSuite.fibonacci
exist, call compareBenchmarks(baselineSuite.fibonacci, resultsSuite.fibonacci,
threshold) as before; (2) if only baselineSuite.fibonacci exists, produce a
fibResult that lists each baseline Fibonacci benchmark as a "missing in results"
comparison (populate comparisons and regressions arrays accordingly) and (3) if
only resultsSuite.fibonacci exists, produce a fibResult that lists each result
Fibonacci benchmark as a "new in results" comparison (populate comparisons and
improvements arrays accordingly); keep the fibResult shape ({ comparisons,
regressions, improvements }) so downstream code consumes it unchanged and
reference compareBenchmarks, baselineSuite.fibonacci, resultsSuite.fibonacci and
fibResult when making the changes.

---

Duplicate comments:
In `@bench/compare.ts`:
- Around line 332-346: The merged arrays allRegs = [...fibRegs, ...regs] and
allImps = [...fibImps, ...imps] can be out of order after concatenation; sort
allRegs by r.diffPercent descending (worst-first) and sort allImps by
r.diffPercent ascending (best-first) immediately after creating them so the
markdown loop emits correctly ordered rows; update the code around the
allRegs/allImps declarations to call .sort((a,b)=>b.diffPercent-a.diffPercent)
for regressions and .sort((a,b)=>a.diffPercent-b.diffPercent) for improvements
before generating the md.

ℹ️ Review info

Configuration used: Path: .coderabbit.yml

Review profile: ASSERTIVE

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 05d5455 and 20e730c.

📒 Files selected for processing (2)
  • assembly/memory.ts
  • bench/compare.ts

Comment thread bench/compare.ts Outdated
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 4, 2026

Benchmark Results

✅ No regressions (improvements detected)

Metric Baseline Current Change
fib(10k) 0.0ms 7.9ms +Infinity%
fib(100k) 0.0ms 77.0ms +Infinity%
fib(1M) 0.0ms 767.0ms +Infinity%
fib(10M) 0.0ms 7683.0ms +Infinity%
Trace total 5678.1ms 5635.3ms -42.8ms (-0.8%)
Improvements
Benchmark Baseline Current Change
fib(10k) 0.0ms 7.9ms Infinity%
fib(100k) 0.0ms 77.0ms Infinity%
fib(1M) 0.0ms 767.0ms Infinity%
fib(10M) 0.0ms 7683.0ms Infinity%
All traces
Trace Baseline Current Change
trace-002 40.6ms 37.9ms -6.4%
trace-058 31.5ms 30.4ms -3.5%
trace-006 92.4ms 89.7ms -3.0%
trace-029 32.4ms 31.6ms -2.3%
trace-040 30.9ms 30.3ms -2.2%
trace-013 35.3ms 34.5ms -2.1%
trace-012 29.4ms 28.8ms -2.0%
trace-044 28.6ms 28.0ms -2.0%
trace-060 29.8ms 29.3ms -1.9%
trace-046 23.4ms 23.0ms -1.8%
trace-031 176.3ms 173.2ms -1.8%
trace-003 244.0ms 248.2ms +1.7%
trace-056 45.5ms 44.8ms -1.4%
trace-027 105.5ms 104.1ms -1.4%
trace-015 78.5ms 77.4ms -1.4%
trace-028 126.4ms 124.7ms -1.3%
trace-019 53.7ms 53.0ms -1.3%
trace-057 42.3ms 41.7ms -1.3%
trace-004 49.2ms 48.6ms -1.3%
trace-037 47.5ms 46.9ms -1.2%
trace-045 54.2ms 53.5ms -1.1%
trace-011 110.4ms 109.2ms -1.1%
trace-018 51.5ms 50.9ms -1.1%
trace-062 36.6ms 36.2ms -1.1%
trace-016 43.3ms 42.8ms -1.1%
trace-043 49.3ms 48.8ms -1.1%
trace-017 193.0ms 191.1ms -1.0%
trace-052 65.5ms 64.9ms -1.0%
trace-034 43.0ms 42.6ms -1.0%
trace-020 92.1ms 91.2ms -1.0%
trace-063 80.4ms 79.7ms -0.9%
trace-021 80.3ms 79.7ms -0.8%
trace-061 76.4ms 75.8ms -0.8%
trace-051 145.4ms 144.2ms -0.8%
trace-014 101.2ms 100.4ms -0.8%
trace-039 193.3ms 191.8ms -0.8%
trace-005 59.5ms 59.1ms -0.8%
trace-023 160.2ms 159.0ms -0.8%
trace-022 137.5ms 136.5ms -0.7%
trace-050 83.3ms 82.7ms -0.7%
trace-026 68.5ms 68.0ms -0.7%
trace-047 117.1ms 116.3ms -0.7%
trace-054 117.0ms 116.2ms -0.7%
trace-007 38.3ms 38.1ms -0.7%
trace-035 89.1ms 88.6ms -0.6%
trace-048 106.2ms 105.6ms -0.6%
trace-042 55.4ms 55.1ms -0.5%
trace-036 64.4ms 64.1ms -0.5%
trace-030 126.8ms 126.2ms -0.5%
trace-025 168.5ms 167.7ms -0.5%
trace-059 177.5ms 176.8ms -0.4%
trace-049 36.0ms 35.9ms -0.4%
trace-024 116.4ms 115.9ms -0.4%
trace-041 168.6ms 168.0ms -0.4%
trace-038 155.3ms 154.8ms -0.3%
trace-001 112.1ms 111.7ms -0.3%
trace-053 146.5ms 146.1ms -0.3%
trace-010 128.8ms 128.5ms -0.2%
trace-033 71.4ms 71.3ms -0.2%
trace-055 197.8ms 197.6ms -0.1%
trace-032 85.0ms 85.1ms +0.0%
trace-009 28.3ms 28.3ms +0.0%
trace-008 103.2ms 103.2ms +0.0%

@tomusdrw tomusdrw merged commit d27ef10 into main Mar 4, 2026
4 checks passed
@tomusdrw tomusdrw deleted the td-benchmark-improvements branch March 4, 2026 13:24
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