Skip to content

bench: COMPARE=perl + life_bitpacked in run_baseline.sh#529

Merged
fglock merged 1 commit intofeature/refcount-perf-combinedfrom
bench/compare-with-perl
Apr 21, 2026
Merged

bench: COMPARE=perl + life_bitpacked in run_baseline.sh#529
fglock merged 1 commit intofeature/refcount-perf-combinedfrom
bench/compare-with-perl

Conversation

@fglock
Copy link
Copy Markdown
Owner

@fglock fglock commented Apr 21, 2026

Summary

Small prerequisite for PR #526's §0 perf work. Currently dev/bench/run_baseline.sh only records jperl numbers, so the recently-discovered life_bitpacked regression (see #526) slipped in unnoticed. This PR upgrades the harness so every subsequent perf change is easy to evaluate against system perl.

Changes

  • COMPARE=perl — when set, every benchmark runs under both jperl and system perl, and the output includes a ratio column and a parity marker (✅ ≤1.0×, ≈ ≤1.2×, ❌ >1.2×).
  • examples/life_bitpacked.pl integrated into the baseline loop, tracked as Mcells/s (higher = faster; ratio inverted).
  • Dual output: results/baseline-<sha>.json (machine) + results/baseline-<sha>.md (human).
  • SKIP_LIFE=1 to opt out when you just want the short benches.
  • bash 3.2 compatible (macOS default) — no associative arrays.
  • dev/bench/README.md — short doc covering how to run + what each workload measures.

Current numbers (PR #526 tip, BENCH_RUNS=1 sanity run)

Benchmark ratio parity
benchmark_lexical 0.40×
benchmark_string 0.62×
benchmark_regex 1.36×
benchmark_closure 1.39×
benchmark_method 1.78×
benchmark_global 1.92×
benchmark_refcount_anon 3.82×
benchmark_eval_string 4.68×
benchmark_anon_simple 5.43×
benchmark_refcount_bless 6.67×
life_bitpacked ~3.17×

A 3-runs default amortizes JVM startup so actual ratios are slightly better.

Merge plan

This targets feature/refcount-perf-combined rather than master so it can merge back into PR #526 before #526 lands. It's an isolated, zero-risk shell change (no behaviour change to the interpreter).

Test plan

  • COMPARE=perl dev/bench/run_baseline.sh produces both JSON and markdown
  • life_bitpacked Mcells/s extraction works
  • bash 3.2 compatibility (ran on macOS /bin/bash 3.2.57)
  • Verified by reviewer on Linux CI bash

Generated with Devin

Prerequisite for the §0 parity work (see dev/design/next_steps.md).
Without side-by-side `jperl` vs `perl` numbers, perf changes are
hard to evaluate and regressions (like the one currently shipped
in PR #526) slip in unnoticed.

Changes to dev/bench/run_baseline.sh:

- COMPARE=perl: when set, each bench runs under both jperl and
  system perl (configurable via PERL=/path/to/perl); ratio +
  parity marker are emitted in the markdown summary.
- life_bitpacked: if examples/life_bitpacked.pl exists, run it
  with `-r none -g 500` and parse "Cell updates per second" from
  stdout. Tracked as Mcells/s rather than wallclock seconds, so
  higher = faster (ratio is inverted: perl / jperl).
- Dual output: baseline-<sha>.json (machine-readable) AND
  baseline-<sha>.md (human-readable table).
- SKIP_LIFE=1 to opt out of the life bench (e.g. in CI where
  startup cost dominates short runs).
- bash 3.2 compatible (macOS default) — no associative arrays.

Add dev/bench/README.md documenting the harness, workloads, and
link to the parity plan.

Current baseline (PR #526 tip, BENCH_RUNS=1 sanity run, macOS
M-series, perl 5.42):

  lexical         0.40×  ✅
  string          0.62×  ✅
  closure         1.39×  ❌
  regex           1.36×  ❌
  method          1.78×  ❌
  global          1.92×  ❌
  refcount_anon   3.82×  ❌
  eval_string     4.68×  ❌
  anon_simple     5.43×  ❌
  refcount_bless  6.67×  ❌
  life_bitpacked  ~3.17× ❌ (6.47 Mcells/s vs 20.52)

3 runs per bench (default) amortizes JVM startup better than the
single-run shown above.

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@fglock fglock merged commit d071692 into feature/refcount-perf-combined Apr 21, 2026
@fglock fglock deleted the bench/compare-with-perl branch April 21, 2026 17:38
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