Postgres 18 beta1: large server, CPU-bound Insert Benchmark
This has results for a CPU-bound Insert Benchmark with Postgres on a large server. A blog post about a similar workload on a small server is here.
This report was delayed because I had to debug a performance regression (see below) and then repeat tests after implementing a workaround in my benchmark client.
tl;dr -
- creating connections
- this is slower in 18 beta1 with io_method=io_uring vs 17.4
- initial load step (l.i0)
- 18 beta1 is 1% to 3% faster than 17.4
- This step is short running so I don't have a strong opinion on the change
- create index step (l.x)
- 18 beta1 is 1% to 3% slower than 17.4
- This step is short running so I don't have a strong opinion on the change
- write-heavy steps (l.i1, l.i2)
- 18 beta1 is 0% to 4% faster
- range query steps (qr100, qr500, qr1000)
- 18 beta1 and 17.4 have similar performance
- point query steps (qp100, qp500, qp1000)
- 18 beta1 is 0% to 2% faster
Connection create is much slower in Postgres 18 beta1, at least with io_method=io_uring. On my large server it takes ~2.3X longer when the client runs on the same server as Postgres (no network latency) and the CPU overhead on the postmaster process is ~3.5X larger. When the benchmark client shares the server with Postgres it used to take ~3 milliseconds to get a connection and that increases to ~7 milliseconds with 18 beta1 when using io_method=io_uring.
More details on the regression are here. By postmaster I mean this process, because the docs claim that postmaster is deprecated:
/home/mdcallag/d/pg174_o2nofp/bin/postgres -D /data/m/pg
From some debugging it looks like there is just more time spent in the kernel dealing with the VM (page tables, etc).
- conf.diff.cx10b_c32r128 (x10b) - uses io_method=sync
- conf.diff.cx10cw4_c32r128 (x10cw4) - uses io_method=worker with io_workers=4
- conf.diff.cx10d_c32r128 (x10d) - uses io_method=io_uring
- l.i0
- insert 10 million rows per table in PK order. The table has a PK index but no secondary indexes. There is one connection per client.
- l.x
- create 3 secondary indexes per table. There is one connection per client.
- l.i1
- use 2 connections/client. One inserts 16M rows per table and the other does deletes at the same rate as the inserts. Each transaction modifies 50 rows (big transactions). This step is run for a fixed number of inserts, so the run time varies depending on the insert rate.
- l.i2
- like l.i1 but each transaction modifies 5 rows (small transactions) and 4M rows are inserted and deleted per table.
- Wait for X seconds after the step finishes to reduce variance during the read-write benchmark steps that follow. The value of X is a function of the table size.
- qr100
- use 3 connections/client. One does range queries and performance is reported for this. The second does does 100 inserts/s and the third does 100 deletes/s. The second and third are less busy than the first. The range queries use covering secondary indexes. This step is run for 1800 seconds. If the target insert rate is not sustained then that is considered to be an SLA failure. If the target insert rate is sustained then the step does the same number of inserts for all systems tested.
- qp100
- like qr100 except uses point queries on the PK index
- qr500
- like qr100 but the insert and delete rates are increased from 100/s to 500/s
- qp500
- like qp100 but the insert and delete rates are increased from 100/s to 500/s
- qr1000
- like qr100 but the insert and delete rates are increased from 100/s to 1000/s
- qp1000
- like qp100 but the insert and delete rates are increased from 100/s to 1000/s
When rQPS is > 1.0 then performance improved over time. When it is < 1.0 then there are regressions. When it is 0.90 then I claim there is a 10% regression. The Q in relative QPS measures:
- insert/s for l.i0, l.i1, l.i2
- indexed rows/s for l.x
- range queries/s for qr100, qr500, qr1000
- point queries/s for qp100, qp500, qp1000
- x10b with io_method=sync
- x10cw4 with io_method=worker and io_workers=4
- x10d with io_method=io_uring).
- initial load step (l.i0)
- 18 beta1 is 1% to 3% faster than 17.4
- This step is short running so I don't have a strong opinion on the change
- create index step (l.x)
- 18 beta1 is 1% to 3% slower than 17.4
- This step is short running so I don't have a strong opinion on the change
- write-heavy steps (l.i1, l.i2)
- 18 beta1 is 0% to 4% faster
- range query steps (qr100, qr500, qr1000)
- 18 beta1 and 17.4 have similar performance
- point query steps (qp100, qp500, qp1000)
- 18 beta1 is 0% to 2% faster
- initial load step (l.i0)
- rQPS for (x10b, x10cw4, x10d) was (1.01, 1.03, 1.02)
- create index step (l.x)
- rQPS for (x10b, x10cw4, x10d) was (0.99, 0.97, 0.97)
- write-heavy steps (l.i1, l.i2)
- for l.i1 the rQPS for (x10b, x10cw4, x10d) was (1.02, 1.04, 1.03)
- for l.i2 the rQPS for (x10b, x10cw4, x10d) was (1.00, 1.04, 1.01)
- range query steps (qr100, qr500, qr1000)
- for qr100 the rQPS for (x10b, x10cw4, x10d) was (1.00, 0.99, 1.01)
- for qr500 the rQPS for (x10b, x10cw4, x10d) was (1.00, 1.00, 1.01)
- for qr1000 the rQPS for (x10b, x10cw4, x10d) was (1.00, 0.99, 1.01)
- point query steps (qp100, qp500, qp1000)
- for qp100 the rQPS for (x10b, x10cw4, x10d) was (1.00, 1.00, 1.02)
- for qp500 the rQPS for (x10b, x10cw4, x10d) was (1.00, 1.00, 1.02)
- for qp1000 the rQPS for (x10b, x10cw4, x10d) was (1.00, 1.00, 1.01)