Skip to content

perf(arm64): reduce loop scans, spill loads, and state copy overhead - #783

Merged
tignear merged 30 commits into
masterfrom
perf/heliodor-arm64-phase2
Sep 9, 2026
Merged

perf(arm64): reduce loop scans, spill loads, and state copy overhead#783
tignear merged 30 commits into
masterfrom
perf/heliodor-arm64-phase2

Conversation

@tignear

@tignear tignear commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Summary

Heliodor's native ARM64 kernel repeatedly scans inactive entries, reloads spilled values, and copies small state arrays. Reduce this work in MIR optimization, register allocation, and machine-code emission:

  • Convert eligible bitmap and circular scans to bit scans, remove redundant loop counters, pack invariant byte predicates, and simplify exclusive predicates and empty conditional branches.
  • Preserve bit bounds through lowering, collapse packed-bit reconstruction, and recover contiguous copies.
  • Rematerialize constant phi inputs at their edges, weight spills by loop frequency, reuse nearby reloads, and coalesce bit-insert destinations with their bases. Keep critical-edge phi sources live across every spill retry.
  • Reuse state page addresses, skip empty sparse-worklist groups, specialize commits covered by one dirty word, and pair short vector copies using fixed offsets. Emit direct conditional branches with range-safe fallbacks.

Loop rewrites check bounds, escaped values, and effects on skipped paths. Memory rewrites preserve aliasing, overlap, partial chunks, and both value planes.

Native ARM64 comparison: release runners compiled on the same Neoverse-N2 host; Celox native/O2; Heliodor a78d04730cf2b37c616e039b4a5bd437c1cfd355. Three alternating rounds compare master 1ff7f81e with this source tree and synchronous Veryl-CC. Timed executions exclude IR dumps and sampling.

Linux boot execution Median, seconds Range, seconds
Celox master 33.121 33.120–33.126
Celox with this change 20.487 20.478–20.489
Veryl-CC synchronous 19.914 19.909–19.917

Celox execution time falls by 38.1%, bringing the gap to Veryl-CC to 2.9%. Heliodor compilation falls from 13.263 s to 12.413 s (medians; 6.4% lower). Veryl-CC's AOT compilation was cold in the first round (163.864 s) and cached in the later rounds (8.636–8.779 s).

All nine boots matched cy=87cda0 x3=aa pass=1. The benchmarked commit 26c1b8c1 and the PR head have identical Git trees (698273195684401200cad34a2fa1ab2052e9cbbd). An independent image comparison also measured 20.481 s for the selected code versus 19.955 s for synchronous Veryl-CC, with all fifteen boots matching.

The profiling workflow now supports same-host baseline/candidate/Veryl-CC comparisons. Each comparison and profile invocation has its own 1,200-second timeout, addressing the P2 review.

Validation

  • 83 ARM64 backend tests passed under QEMU, including differential checks for loop rewrites, register-pressure/phi preservation, copies, sparse commits, shift boundaries, and far branches.
  • 98 simulator/native integration tests and 40 host backend tests passed; the full optimized Linux boot also passed under QEMU.
  • Host and ARM64 Clippy passed with warnings denied; formatting, workspace checking, and workflow YAML/shell syntax checks passed.
  • The selected source completed the native ARM64 compilation/execution comparison and all Linux boots above. CI passed on the final commit, including ARM64 backend, Rust/SystemVerilog/cocotb, NAPI/WASM, JavaScript, and browser tests. Heliodor gates, compile-time benchmarks, and CodeQL also passed.

@tignear
tignear marked this pull request as ready for review September 8, 2026 19:01
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 8, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-09T01:44:07.737235Z 865eb81 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@codspeed-hq

codspeed-hq Bot commented Sep 8, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 4 untouched benchmarks


Comparing perf/heliodor-arm64-phase2 (865eb81) with master (1ff7f81)

Open in CodSpeed

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7ef53d2489

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread .github/workflows/heliodor-bench.yml Outdated
Comment on lines +346 to +347
"$runner" --project "$HELIODOR_DIR" --test test_soc_linux_boot \
--backend native --opt-level o2 "${args[@]}" > "$log" 2>&1

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Apply a timeout to each comparison run

When either the downloaded baseline or candidate runner hangs, this direct invocation bypasses the timeout protection in scripts/run-heliodor-bench.sh:1356-1395, so the comparison stalls until the entire 120-minute job timeout and the remaining rounds/profile never run. GNU timeout --help confirms that timeout DURATION COMMAND terminates a command after the specified duration; invoke the runners through the existing run_in_heliodor helper or wrap each invocation with an equivalent per-run timeout.

Useful? React with 👍 / 👎.

@tignear
tignear marked this pull request as draft September 8, 2026 19:49
@tignear tignear changed the title perf(arm64): reuse nearby spills and shorten conditional branches perf(arm64): reduce loop scans, spill loads, and state copy overhead Sep 9, 2026
@tignear
tignear marked this pull request as ready for review September 9, 2026 01:34
@tignear
tignear added this pull request to the merge queue Sep 9, 2026
Merged via the queue into master with commit 7c015ad Sep 9, 2026
30 checks passed
@tignear
tignear deleted the perf/heliodor-arm64-phase2 branch September 9, 2026 06:28
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