Skip to content

Print out Wasm phase timings - #26

Open
Lubrsi wants to merge 1 commit into
LadybirdBrowser:masterfrom
Lubrsi:wasm-phase-timings
Open

Print out Wasm phase timings#26
Lubrsi wants to merge 1 commit into
LadybirdBrowser:masterfrom
Lubrsi:wasm-phase-timings

Conversation

@Lubrsi

@Lubrsi Lubrsi commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Relies on LadybirdBrowser/ladybird#10934

Suite           Test                    Mean ± σ        Range (min … max)    Max RSS (mean)
--------------  ----------------------  --------------  -------------------  ----------------
WasmMicroBench  call-00-args.wasm       0.082 ± 0.005   0.078 … 0.087        32.4 MB
WasmMicroBench  call-01-args.wasm       0.080 ± 0.001   0.079 … 0.081        32.4 MB
WasmMicroBench  call-02-args.wasm       0.081 ± 0.001   0.080 … 0.081        32.4 MB
WasmMicroBench  call-03-args.wasm       0.090 ± 0.001   0.088 … 0.091        32.4 MB
WasmMicroBench  call-04-args.wasm       0.082 ± 0.001   0.081 … 0.082        32.4 MB
WasmMicroBench  call-16-args.wasm       1.408 ± 0.004   1.404 … 1.410        32.5 MB
WasmMicroBench  call-32-args.wasm       1.794 ± 0.007   1.787 … 1.801        32.5 MB
WasmRustBench   base64-bench.wasm       0.620 ± 0.004   0.616 … 0.623        30.8 MB
WasmRustBench   blake3-bench.wasm       27.788 ± 0.197  27.560 … 27.903      30.9 MB
WasmRustBench   json-bench.wasm         1.993 ± 0.018   1.974 … 2.008        39.2 MB
WasmRustBench   regex-match-bench.wasm  0.947 ± 0.016   0.934 … 0.964        379.9 MB
WasmRustBench   sha512-bench.wasm       1.023 ± 0.027   1.006 … 1.055        41.7 MB

WebAssembly phase timings (seconds; not used for score):
Suite           Test                    Parse ± σ      Validate ± σ    Native compile ± σ    Instantiate ± σ    Execute ± σ
--------------  ----------------------  -------------  --------------  --------------------  -----------------  --------------
WasmMicroBench  call-00-args.wasm       0.000 ± 0.000  0.000 ± 0.000   0.003 ± 0.001         0.001 ± 0.000      0.051 ± 0.000
WasmMicroBench  call-01-args.wasm       0.000 ± 0.000  0.000 ± 0.000   0.002 ± 0.000         0.001 ± 0.000      0.052 ± 0.000
WasmMicroBench  call-02-args.wasm       0.000 ± 0.000  0.000 ± 0.000   0.002 ± 0.000         0.001 ± 0.000      0.054 ± 0.000
WasmMicroBench  call-03-args.wasm       0.000 ± 0.000  0.000 ± 0.000   0.003 ± 0.000         0.001 ± 0.000      0.062 ± 0.000
WasmMicroBench  call-04-args.wasm       0.000 ± 0.000  0.000 ± 0.000   0.003 ± 0.000         0.001 ± 0.000      0.055 ± 0.000
WasmMicroBench  call-16-args.wasm       0.000 ± 0.000  0.000 ± 0.000   0.002 ± 0.000         0.001 ± 0.000      1.380 ± 0.004
WasmMicroBench  call-32-args.wasm       0.000 ± 0.000  0.000 ± 0.000   0.003 ± 0.000         0.001 ± 0.000      1.765 ± 0.008
WasmRustBench   base64-bench.wasm       0.001 ± 0.001  0.007 ± 0.000   0.025 ± 0.002         0.000 ± 0.000      0.563 ± 0.003
WasmRustBench   blake3-bench.wasm       0.001 ± 0.000  0.008 ± 0.000   0.030 ± 0.003         0.000 ± 0.000      27.722 ± 0.200
WasmRustBench   json-bench.wasm         0.001 ± 0.000  0.010 ± 0.000   0.049 ± 0.007         0.000 ± 0.000      1.907 ± 0.016
WasmRustBench   regex-match-bench.wasm  0.013 ± 0.001  0.115 ± 0.002   0.553 ± 0.012         0.001 ± 0.001      0.232 ± 0.002
WasmRustBench   sha512-bench.wasm       0.001 ± 0.000  0.008 ± 0.000   0.064 ± 0.001         0.000 ± 0.000      0.924 ± 0.028

@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

run.py adds optional WebAssembly benchmark timing collection, including capability detection, stderr JSON parsing, per-run collection, suite integration, and phase statistics.

Changes

WebAssembly timing collection

Layer / File(s) Summary
Timing capability and parsing
run.py
Defines timing phases, detects --benchmark-timings support, validates emitted JSON records, and extends run_benchmark to return collected timing runs.
Suite integration and timing report
run.py
Enables timing collection for supported WebAssembly suites, passes the timing flag, accumulates results, and prints per-phase mean and standard deviation values.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested reviewers: awesomekling

Sequence Diagram(s)

sequenceDiagram
  participant main
  participant wasm_executable
  participant run_benchmark
  participant timing_table
  main->>wasm_executable: check --benchmark-timings support
  main->>run_benchmark: execute WebAssembly suite with timing collection
  run_benchmark->>wasm_executable: pass --benchmark-timings
  wasm_executable-->>run_benchmark: emit phase timing record
  run_benchmark-->>timing_table: append parsed timing runs
  main->>timing_table: compute and print phase statistics
Loading
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description check ✅ Passed The description directly matches the WebAssembly phase timing changes and includes representative output.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@run.py`:
- Around line 159-160: Update the collect_wasm_timings handling in run_benchmark
so parse_wasm_benchmark_timings failures are caught locally; retain the
benchmark result, emit a warning, and omit the timing row instead of propagating
the exception or aborting the suite. Keep successful timing rows unchanged and
preserve existing CalledProcessError behavior.
- Around line 104-106: Update supports_wasm_benchmark_timings to pass a finite
timeout to subprocess.run and treat subprocess.TimeoutExpired or a non-zero
return code as timings unavailable by returning False. Preserve the existing
stdout capability check for successful executions.
- Around line 286-288: Separate the scored benchmark invocation from the
timing-instrumented invocation in the executable flow: keep executable_arguments
unmodified for the run used to calculate ScoreMetric.time, and add
--benchmark-timings only to a distinct timing pass whose results populate the
timing report.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 581256f4-89d4-4374-915d-f904aba96cf7

📥 Commits

Reviewing files that changed from the base of the PR and between e2a86b7 and af3179e.

📒 Files selected for processing (1)
  • run.py

Comment thread run.py Outdated
Comment thread run.py Outdated
Comment thread run.py Outdated
@Lubrsi
Lubrsi force-pushed the wasm-phase-timings branch from af3179e to f08af24 Compare July 30, 2026 16:09
@Lubrsi

Lubrsi commented Jul 30, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@run.py`:
- Around line 127-131: Validate that record is a mapping/object before iterating
through WASM_BENCHMARK_PHASES and calling record.get. For non-object records,
follow the existing local handling that omits optional timings rather than
raising AttributeError; retain the current numeric-list validation for valid
mapping records.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 1706d2a3-3162-4504-903d-52d263006186

📥 Commits

Reviewing files that changed from the base of the PR and between af3179e and f08af24.

📒 Files selected for processing (1)
  • run.py

Comment thread run.py
Comment on lines +127 to +131
record = records[0]
for phase, _ in WASM_BENCHMARK_PHASES:
values = record.get(phase)
if not isinstance(values, list) or not all(isinstance(value, (int, float)) for value in values):
raise RuntimeError(f"Invalid Wasm benchmark timing values for {phase}")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Reject non-object timing records before accessing .get().

Line 129 assumes the decoded JSON is a mapping. A list or scalar record raises AttributeError, bypasses the local handler, and aborts the suite instead of omitting optional timings.

Proposed fix
     record = records[0]
+    if not isinstance(record, dict):
+        raise RuntimeError("Invalid Wasm benchmark timing record")
     for phase, _ in WASM_BENCHMARK_PHASES:
#!/bin/bash
python - <<'PY'
import json
for payload in ("[]", "null", '"timings"', "42"):
    record = json.loads(payload)
    print(payload, type(record).__name__, hasattr(record, "get"))
PY
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@run.py` around lines 127 - 131, Validate that record is a mapping/object
before iterating through WASM_BENCHMARK_PHASES and calling record.get. For
non-object records, follow the existing local handling that omits optional
timings rather than raising AttributeError; retain the current numeric-list
validation for valid mapping records.

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.

1 participant