Add a reproducible benchmark suite and publish the results#26
Merged
Conversation
bench/run.sh + bench/setup.sql compare PL/php against PL/pgSQL and PL/Perl on four workloads (scalar math, string ops, an SPI loop over 1000 rows, repeated small SPI statements) via pgbench, with identical logic in each language. doc/benchmarks.md publishes the numbers and their reading: scalar/string work is call-overhead-bound and all three languages are within a few percent; row iteration is PL/pgSQL's native strength while PL/php still runs 1.75x faster than PL/Perl; repeated SPI statements carry the subtransaction that makes PL/php and PL/Perl errors catchable, with PL/php ~25% ahead of PL/Perl. One optimization was tried and rejected: interning column-name hash keys per result measured as a no-op (the row-loop cost is per-cell value conversion, not key handling), so it was dropped rather than kept as complexity without benefit. The document records that, and the plausible future fast path (binary Datum conversion for common scalars). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The first published performance numbers for the modernized PL/php, with the suite committed so anyone can rerun them (
sh bench/run.sh).Headlines: within a few percent of PL/pgSQL on computation (call overhead dominates, not the interpreter), 1.75× faster than PL/Perl on row loops, and between the two on repeated SPI (both PL/php and PL/Perl pay the subtransaction that makes their errors catchable).
doc/benchmarks.mdincludes the analysis, honest methodology, and a "tried and rejected" section: per-result column-key interning measured as a no-op (the row-loop cost is per-cell value conversion), so it was dropped instead of merged — the plausible future fast path (binary Datum conversion for common scalars) is recorded for whoever picks it up.No code changes; docs +
bench/only.🤖 Generated with Claude Code