Skip to content

Optimize dense numeric array fill loops - #4958

Merged
proggeramlug merged 1 commit into
feat/perf-investigate-runtime-comparisonfrom
feat/perf-array-append-fast-path
Jun 11, 2026
Merged

Optimize dense numeric array fill loops#4958
proggeramlug merged 1 commit into
feat/perf-investigate-runtime-comparisonfrom
feat/perf-array-append-fast-path

Conversation

@TheHypnoo

Copy link
Copy Markdown
Member

Summary

  • lower compiler-proven dense numeric array fill loops into bulk runtime helpers
  • add raw-f64 bulk fill helpers for constant and iota writes, including arr.length-bounded variants
  • gate typed feedback collection in normal runtime unless feedback tracing is enabled

Benchmarks

Median of 3 runs with --no-auto-optimize, compared to the prior typed-feedback baseline:

  • 03_array_write.ts: 3270 ms -> 4 ms (817.5x faster; faster than Node 9 ms and Bun 6 ms locally)
  • 04_array_read.ts: 3388 ms -> 174 ms (19.5x faster)
  • 10_nested_loops.ts: 4300 ms -> 307 ms (14.0x faster)
  • 11_prime_sieve.ts: 549 ms -> 47 ms (11.7x faster)
  • 16_matrix_multiply.ts: 8854 ms -> 581 ms (15.2x faster)
  • bench_numeric_array_numeric.ts: 3651 ms -> 243 ms (15.0x faster)
  • bench_array_grow.ts: 523 ms -> 125 ms (4.2x faster)

Current local comparison after this change (Perry / Node / Bun, median ms):

  • 03_array_write.ts: 4 / 9 / 6
  • 06_math_intensive.ts: 51 / 51 / 52
  • 05_fibonacci.ts: 318 / 1029 / 553
  • 15_mandelbrot.ts: 23 / 25 / 29

Remaining gaps to target next:

  • 09_method_calls.ts: Perry 7338 ms vs Node 11 ms vs Bun 19 ms
  • 16_matrix_multiply.ts: Perry 581 ms vs Node/Bun 35 ms
  • bench_numeric_array_numeric.ts: Perry 243 ms vs Node/Bun 5 ms
  • 04_array_read.ts: Perry 174 ms vs Node 12 ms vs Bun 19 ms

Validation

  • cargo check -p perry-codegen --quiet
  • cargo test -p perry-runtime numeric_array --quiet
  • cargo test -p perry-runtime typed_feedback --quiet
  • cargo build -p perry --release --quiet
  • cargo build -p perry-runtime --release --quiet
  • rustfmt --check on the four touched source files
  • git diff --check
  • Perry vs Node smoke comparisons for array write/read, numeric arrays, grow, array methods/slice/object arrays, guarded raw numeric arrays, and bulk-fill length semantics

Note: cargo fmt -- --check currently reports unrelated pre-existing formatting diffs in perry-codegen/perry-hir files. cargo test --workspace cannot complete on this machine because pkg-config cannot find the system gtk4 and graphene-gobject-1.0 libraries required by gdk4-sys/graphene-sys.

@proggeramlug
proggeramlug merged commit ecd9622 into feat/perf-investigate-runtime-comparison Jun 11, 2026
1 check passed
@proggeramlug
proggeramlug deleted the feat/perf-array-append-fast-path branch June 11, 2026 03:15
proggeramlug pushed a commit that referenced this pull request Jun 11, 2026
* Optimize numeric array raw payload helpers

* Optimize dense numeric array fill loops (#4958)

* Optimize class method field fast paths (#4959)
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