NAME

problem48-spvm-benchmark - compare SPVM PBKDF2 with Perl and OpenSSL FFI

PURPOSE

This script measures the same PBKDF2-HMAC-SHA256 inputs and iteration count through three implementations: the existing Perl reference loop, the Dashboard's OpenSSL FFI adapter, and an experimental SPVM-compiled loop. Every measured digest must match before its timing is accepted.

WHY IT EXISTS

Problem 48 evaluates multiple acceleration technologies. The earlier SPVM probe crossed from Perl for each HMAC call and was not a fair measure of a compiled SPVM routine. This script keeps PBKDF2's inner loop inside SPVM, reports SPVM load/compile time separately, and makes the comparison reproducible without adding SPVM to the Dashboard runtime dependencies.

WHEN TO USE

Use this only in the isolated Problem 48 Docker benchmark environment, where SPVM, SPVM::Digest::SHA, and the optional FFI modules are installed. The fixture under t/fixtures/problem48-spvm is benchmark-only and is not an authentication implementation.

HOW TO USE

perl script/problem48-spvm-benchmark
perl script/problem48-spvm-benchmark --iterations 1000 --runs 7

The default measures the production 210,000-round work factor over five alternating runs. A smaller iteration count is useful for a quick smoke check. The script exits with an error if any implementation is unavailable or if a digest differs.

WHAT USES IT

Problem 48 performance research uses this script to determine whether a full SPVM PBKDF2 implementation is faster than the existing reference and the OpenSSL FFI adapter. It is not called by the application or release workflow.

EXAMPLES

Run the production-work-factor comparison in Docker:

d2 docker compose -p dd-problem48-bench -f /tmp/d2-problem48-bench.yml -f /tmp/d2-problem48-init.yml run --rm bench perl script/problem48-spvm-benchmark

Quickly verify setup and output parity with fewer iterations:

d2 docker compose -p dd-problem48-bench -f /tmp/d2-problem48-bench.yml -f /tmp/d2-problem48-init.yml run --rm bench perl script/problem48-spvm-benchmark --iterations 1000 --runs 3

Run the parity regression before benchmarking:

d2 docker compose -p dd-problem48-bench -f /tmp/d2-problem48-bench.yml -f /tmp/d2-problem48-init.yml run --rm bench prove -lv t/655-spvm-hmac-loop.t