Skip to content

Add benchmark suite comparing PL/Ruby to sibling PLs#7

Merged
jdatcmd merged 1 commit into
masterfrom
feature/benchmark-suite
Jul 7, 2026
Merged

Add benchmark suite comparing PL/Ruby to sibling PLs#7
jdatcmd merged 1 commit into
masterfrom
feature/benchmark-suite

Conversation

@jdatcmd

@jdatcmd jdatcmd commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Mirrors PL/php's bench/ + doc/benchmarks.md layout, extended to five languages and four workloads.

What's here

  • bench/setup.sql — four workloads with matching semantics in PL/Ruby, PL/pgSQL, PL/Perl, PL/Python and PL/Tcl: call overhead, string/numeric ops, an SPI loop over 1,000 rows, and int[] array marshaling. All five languages are cross-checked to return identical results before timing.
  • bench/run.shpgbench -c 1 harness reporting TPS per function per language; a missing PL is reported as skipped, not fatal. Configurable via SECS, LANGS, PGBENCH, PGPORT.
  • doc/benchmark.md — first published numbers (PostgreSQL 18.4, Ruby 3.2, Ubuntu 24.04 / x86-64), results table and analysis, linked from the README.

Findings (representative TPS)

Workload PL/Ruby PL/pgSQL PL/Perl PL/Python PL/Tcl
Call overhead 46,000 55,000 53,000 51,000 53,000
String ops 34,500 36,000 36,000 36,000 35,000
SPI loop (1,000 rows) 2,600 6,600 2,400 3,800 2,500
Array marshaling 18,600 25,000 15,900 19,600 17,600

PL/Ruby is at parity on compute, mid-pack on SPI row iteration, and second only to PL/Python on array marshaling. The small fixed call-overhead tax is the protected MRI entry path (rb_protect/rb_eval) that makes Ruby exceptions catchable PostgreSQL errors.

Numbers were produced in the plruby-build container and confirmed across two runs.

🤖 Generated with Claude Code

Mirrors PL/php's bench/ + doc/benchmarks.md layout for PL/Ruby:

- bench/setup.sql: four workloads (call overhead, string/numeric ops, SPI
  row loop, array marshaling) written with matching semantics in PL/Ruby,
  PL/pgSQL, PL/Perl, PL/Python and PL/Tcl. Functions are cross-checked to
  return identical results before timing.
- bench/run.sh: pgbench -c 1 harness that reports TPS per function per
  language; missing extensions are reported as skipped, not fatal.
- doc/benchmark.md: first published numbers (PostgreSQL 18.4, Ruby 3.2),
  results table and analysis. PL/Ruby is at parity on compute, mid-pack on
  SPI row iteration, and second only to PL/Python on array marshaling; a
  small fixed call-overhead tax comes from the protected MRI entry path.

Linked from the README documentation list.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jdatcmd jdatcmd merged commit 0720d8e into master Jul 7, 2026
8 of 9 checks passed
@jdatcmd jdatcmd deleted the feature/benchmark-suite branch July 7, 2026 22:34
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