Skip to content

bench_pg_unwind

Benchmark PostgreSQL/Rust exception unwinding overhead

bench_pg_unwind · Benchmark PostgreSQL/Rust exception unwinding overhead

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
100564bench_pg_unwindbench_pg_unwind0.1FEATApache-2.0Rust

Usage

Sources:

bench_pg_unwind 0.1 is a narrow 2020 microbenchmark for comparing repeated Rust-to-C calls with and without a PostgreSQL error-unwind guard. It is diagnostic code, not an application extension.

Disposable benchmark

Use small, positive iteration counts on an isolated server:

CREATE EXTENSION bench_pg_unwind;
SELECT bench_cross_fn(1000, 0, 1);
SELECT bench_try_fn(1000, 0, 1);

Both functions return the repeated addition result. Each call also emits a WARNING containing total and per-iteration timing, so collect server and client messages as the benchmark output.

Caveats

  • The iteration count directly controls a tight backend CPU loop and has no upper bound. Never expose it to untrusted input.
  • Zero or negative iterations make the timing code divide a duration by a nonpositive value and can enter a Rust panic path.
  • Addition occurs in signed 64-bit C arithmetic without overflow checks. Choose start, increment, and iteration values whose result remains in range.
  • Results include SQL-call, logging, clock, compiler, and build effects; they are not a general measure of PostgreSQL or Rust performance.
  • The build depends on a historical Timescale Rust support branch and 2020-era PostgreSQL headers. Upstream provides no tests, compatibility matrix, README, or complete repository license files.

Table reader