Skip to content

perf: Rust 1.95's APIs where they measure better, with every seeded result unchanged - #424

Merged
tachsin merged 9 commits into
mainfrom
perf/rust-1.95-apis
Oct 2, 2026
Merged

tachsin merged 9 commits into
mainfrom
perf/rust-1.95-apis

Conversation

@tachsin

@tachsin tachsin commented Oct 2, 2026

Copy link
Copy Markdown
Owner

The follow-up to #402 and #422: the APIs that Rust 1.95 allows, plus the older ones #402 listed as "usable now". One topic per commit, each measured in instruction counts against its parent. Every seeded result is identical to the bit: portable_runs, the linalg fixed-bit tests, and all 223 examples against their output.txt.

Instruction counts, this branch against main (valgrind, gungraun 0.19.4, Rust 1.99, one codegen unit). No benchmark gained.

Benchmark Change
L-BFGS-B rounds, n = 1000 −4.94%
L-BFGS-B with forward differences −1.11%
gemm, n = 64 −3.13%
Cholesky, n = 200 −0.81%
CMA-ES sep-100 −1.24%
CMA-ES 10 −0.29%
DE generation −0.12%

Kept:

  • core::hint::cold_path (1.95) on ln's special cases, the source of the CMA-ES and DE gains, and on exp, a NaN violation, the Cholesky pivot, L-BFGS-B's projected gradient and Nelder-Mead's mirror.
  • array_windows (1.94) in Rosenbrock, Dixon-Price, Trid, Penalized 1 and 2, Schaffer F7, Kursawe, the gradients, the crowding distance, nn and more. The same float operations, in the same order.
  • Slices cut to n in gemv and in L-BFGS-B's O(n) loops, which removes their bounds checks. This is the −4.94%.
  • as_chunks_mut in gemm's A panel and in the Cholesky update's panel.
  • #[expect] in place of #[allow]. This removed the stale dead_code allows of cholesky and triangular, which L-BFGS-B uses now, and a stale type_complexity.
  • For clarity, with counts unchanged: split_off, split_last_chunk and as_array in checkpoints; carrying_mul in below_u64; isqrt in SPEA2 (the same k for every n up to 2^28); is_multiple_of.

Dropped, measured:

  • cold_path in below_u64: tournament selection −2.9%, but DE +1.6%.
  • cold_path in Fitness::try_new: the fitness loop −8.5%, but the OneMax run +1.45%.
  • cold_path on L-BFGS-B's skipped pair: a small cost.
  • as_chunks_mut for the Cholesky column tiles: +0.87%.
  • f64::midpoint in DE: identical to the bit over 200M pairs and every class of f64, but DE +0.39%.

Not adopted: cfg_select!. rustfmt doesn't format inside it, and the paired functions read no better wrapped in it.

ln's and exp's special cases, a NaN constraint violation, a pivot that isn't positive in the
Cholesky factorization, and the NaN checks of L-BFGS-B's projected gradient and Nelder-Mead's
mirroring. Measured site by site in instruction counts: ln's lowers DE's and CMA-ES's
generations; the others are unchanged. Lemire's rejection in below_u64, a NaN score in
Fitness::try_new and a skipped L-BFGS-B pair were left out: each made some benchmarks cost more.
…exing

Rosenbrock, Dixon-Price, Trid, the two penalized functions, Schaffer F7, Kursawe and the CLI's
Rosenbrock, the analytic gradients, NSGA-II's crowding distance, the network's parameter count,
the check for a repeated variable name, and the tests' Rosenbrock helpers: the same float
operations in the same order.
The loops index slices resliced to n first, so the compiler can drop the bounds checks; the
operations and their order are unchanged.
…'s panels

The panels of MR rows are written through fixed-size column chunks, whose index is known to be
in bounds; the same copies in the same order. The packed column tiles of the Cholesky update
stay as they were: written the same way, they cost more.
An expectation that turns out unfulfilled is a warning, so a lint allowed for no reason shows.
The dead_code allows of the Cholesky factorization and the triangular solves, both used by
L-BFGS-B, and a type_complexity allow in the Python package were stale: removed. The linear
algebra's other dead code is used by the tests only, so its expectations hold outside them.
…ce of the take helper

The fields of a checkpoint are cut off the front of the bytes with <[T]>::split_off and the
fixed-size lengths read as arrays; the checksum is the last chunk of 8 bytes.
The low and high halves of the 128-bit product, without the u128 casts.
The same k as the float square root for every size up to 2^28, far above what SPEA2 allows.
The OpenEs population size check, the even-parity table, WFG2's intervals, the double factorial
series, the Büche-Rastrigin function and its gradient, the hypervolume's inclusion-exclusion
sign, and the Python WFG check.
@tachsin
tachsin merged commit b2f93ac into main Oct 2, 2026
22 checks passed
@tachsin
tachsin deleted the perf/rust-1.95-apis branch October 2, 2026 20:48
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