Performance benchmark scripts for PerlOnJava.
These scripts measure the runtime performance of specific Perl operations under PerlOnJava (and optionally system Perl for comparison). Use them to:
- Establish a baseline before making performance-sensitive changes
- Verify that an optimization actually improves throughput
- Detect regressions after refactoring
| Script | What it measures |
|---|---|
benchmark_closure.pl |
Closure creation and invocation |
benchmark_eval_string.pl |
eval STRING compilation overhead |
benchmark_global.pl |
Package (global) variable access |
benchmark_lexical.pl |
Lexical variable access |
benchmark_memory.pl |
Memory usage for common data structures |
benchmark_memory_delta.pl |
Memory growth / leak detection |
benchmark_method.pl |
Method dispatch (class, inheritance) |
benchmark_regex.pl |
Regex compilation and matching |
benchmark_refcount_store.pl |
Tracked reference stores after weaken() activates lifecycle bookkeeping |
benchmark_string.pl |
String operations (concat, substr, etc.) |
benchmark_threads.pl |
Ithread snapshot, creation, scheduling, and join overhead |
performance_over_perl.py |
Paired, warmup-aware Perl versus PerlOnJava workload measurements |
tests/test_performance_over_perl.py |
Unit tests for stability, checksums, eligibility, and paired statistics |
# Single benchmark
./jperl dev/bench/benchmark_closure.pl
# Compare with system Perl
perl dev/bench/benchmark_closure.pl
./jperl dev/bench/benchmark_closure.plFor the #1863 acceptance anchors, compare the original method-call loop, the original captured-closure loop, and bit-packed Life. Pin the standard Perl source revision (a Perl release tag or a blead commit) in the report:
The method and closure workers load their original benchmark definitions in load-only mode. The method receiver resets between measurement windows, outside the timed window; the inner loop and sink behavior match the original source. Each worker verifies a fixed 20,000-call checksum and the measured-window method result against its operation count.
python3 dev/bench/performance_over_perl.py \
--workloads method_anchor closure_anchor life \
--perl /path/to/blead-prefix/bin/perl5.45.5 \
--perl-source-revision <blead-commit> \
--output /tmp/performance-over-perl.jsonFor the primary method acceptance comparison, set --perl to the separately
built optimized blead executable and --perl-source-revision to its exact
commit. Run the stable Perl release separately and report it as a second
reference. The runner records the complete Perl -V configuration, executable,
source revision, JVM flags, JAR hash, workload source hashes, commands, process
priority, warmup windows, measurements, checksums, and paired confidence
intervals. Launch order is randomized with a recorded seed and balanced across
both engines for each workload. A requested priority that cannot be verified
makes the pair ineligible for its summary.
The exact origin/master directional baseline, initial inactive fast-path
experiment, corrected fast-path comparisons, and pooled-argument measurements
are retained under reports/ (generated, not tracked).
The macOS runs are diagnostic because this host denied the requested process
priority; see dev/design/performance-over-perl.md for the measured values and
limitations.
To attribute a change to exact PerlOnJava artifacts, pin both JARs. The candidate and reference JARs run in balanced randomized order in each independent pair, and both artifact paths and hashes are recorded. This is diagnostic attribution evidence, not Perl parity evidence:
python3 dev/bench/performance_over_perl.py \
--workloads method_anchor closure_anchor life \
--jperl-jar target/perlonjava-5.44.1.jar \
--reference-jperl-jar /path/to/parent/perlonjava-5.44.1.jar \
--output /tmp/performance-over-perl-parent-candidate.jsonThe six other diagnostic groups from #1196 remain available alongside the method and closure anchors; Life is shared by both sets. The default run covers all nine unique groups with seven balanced randomized fresh-process pairs, stabilized warmup, and raw JSON samples. Use smaller window and pair counts only to smoke-check the runner; smoke runs are not performance evidence.
Use this sequence when a benchmark points to a runtime bottleneck:
- Set the comparison first. Keep the optimization question, workload, and
acceptance rule explicit. Record a source/JAR-matched baseline against the
exact parent for attribution, and compare the candidate against pinned
optimized blead for Perl parity. A comparison against
origin/mastershows branch progress; it does not establish Perl parity. - Check that the workload does the same work. Use identical inputs and operation counts, verify checksums, and keep startup, compilation, and JVM warmup outside the scored window. Use the persistent paired runner for claims; retain the full report, attempted pairs, exclusions, environment, and worker logs.
- Profile outside scored runs. Use JFR CPU, allocation, and GC events, and HotSpot compilation/inlining evidence to identify a specific cost. A sampled hotspot is a hypothesis, not proof that removing it will improve end-to-end throughput. Keep profiler output separate from benchmark timing.
- Make a guarded, attributable change. State the preconditions for the fast path and preserve the general fallback. Add focused regression tests for those preconditions and fallback transitions. Validate Perl-level behavior with standard Perl and runtime parity on the required backends. Keep independent optimization hypotheses separate so each can be measured against the exact parent.
- Keep only demonstrated improvements. Repeat paired measurements with the same pinned reference and protocol. Require the workload's confidence interval to meet its stated acceptance rule; do not infer a gain from a point estimate, a single run, or a portfolio average that hides a slow workload. Record the candidate artifact hash and link the durable report.
- Batch the expensive gates. On a shared host, finish related edits and
focused checks before running one full
nice -n 19 timeout 3600 makegate on the immutable candidate. Do not benchmark alongside a build or profile inside scored windows. Push and check hosted CI after the local candidate passes rather than after each small edit.
The life workload above disables rendering and measures computation. Running
examples/life_bitpacked.pl with its default arguments also writes substantial
terminal output; that is a separate end-to-end I/O workload. A reported result
near 0.5x Perl for this mode is a signal to investigate, not part of the
rendering-disabled Life score.
For an output comparison, run both engines with identical arguments and the same output destination. Measure real terminal/PTY output separately from redirected output, since those measure different sink costs. Confirm output byte counts and hashes after the timed run so result validation does not add work to the measured interval. Report elapsed time and bytes per second along with the sink type, and keep the output workload distinct from compute-only throughput claims.
dev/bench/perl-reference-builds.md— pinned blead and stable Perl buildsdev/design/optimization.md— optimization design decisionsdev/design/interpreter_benchmarks.md— interpreter-mode benchmarksdev/tools/jvm_profiler/— JFR / async-profiler skill for deeper analysis