Contents

What it costs

make bench PG_CONFIG=/path/to/pg_config

tests/bench.py on the throwaway cluster. “Directly” means an identical role – same grants, same statement, same parameters – that is not registered as an agent; never a superuser. Each of ITER iterations (300) runs both paths back to back, alternating which goes first; the throughput test runs PAIRS (7) alternating pairs of pgbench -S restarts of SECONDS (15) each, preloaded and bare, and reports the median loss with every pair shown. It prints medians with p25/p75 and writes them to target/bench/result.json. The thresholds were declared before the code, and the run says whether each one holds:

what make bench measures threshold
extra time per read act (propose + commit) over the same query directly <= 10 ms
extra time per kept write over the same UPDATE directly, which pays its own durable commit <= 5 ms
throughput lost by sessions that are not agents when the library is preloaded <= 3%
extra time per read act with attempt_durability = durable <= 10 ms
the same durable read act in ONE call (propose_and_commit) <= 10 ms

This README publishes no timing of its own: one machine’s numbers are not yours, so run it where the gate will run.

Where the time goes. The gate’s own work inside the server – parse, plan, the amplification and function checks, run, decide – is a part of an act; most of the rest is the record: every act is a proposal and an execution written to append-only tables, in their own commits. That is not overhead to optimize away; it is what makes an agent’s actions auditable. With durable every one of those records pays its own flush, and a flush is the disk: propose + commit pay two, propose_and_commit writes both records in one commit and pays one (counted by tests/flushes.sh). A durable act costs about the gate’s own work plus one or two flushes, so its number is mostly the disk’s, and only as good as the disk it was taken on.

make bench starts from an empty record. What an act costs must not grow with the record, and up to 0.4.4 it did: the write budget’s count read every execution ever recorded (190 ms per write on a record of 865,000). tests/budget.sh case 8 keeps it from coming back: after 200,000 recorded acts, a commit must not read the executions table from end to end.

Two of the checks scale with the catalog: the commit backstop reads the transaction ’s tuple statistics (twice per kept write), and no_amplification walks the inheritance of the target. On a database with thousands of tables, expect the per-act cost to grow; run make bench against your own schema. Build PostgreSQL without --enable-cassert for it (pgrx’s own instance has assertions on, which inflates every number).