Monday, October 30, 2023

Perf regressions in MySQL from 5.6.21 to 8.0.35 using sysbench and a medium server, part 1

This post has results from sysbench for all releases of MySQL 8.0 and 5.7 along with some releases of 5.6. All tests used InnoDB. I previously shared results from a small server and here I share results for both the medium and small servers -- they are similar. The goal is to document where things get faster or slower over time for a medium-concurrency and CPU-bound workload. The focus is on CPU regressions. 

Because I include graphs from the medium and small servers there are more graphs so I will split my report into several blog posts. This post has results comparing some releases from each of 5.6, 5.7 and 8.0.

tl;dr

  • Results like this are motivation for using changepoint detection as part of the upstream dev cycle
  • Bug 102037 was fixed in 8.0.31. This arrived in 8.0.22 and was reported by me with help from sysbench. With the fix, QPS is doubled for SELECT statements with large inlists. See the results below in Point queries, part 2
  • MySQL 8.0 uses more CPU/operation than MySQL 5.6
    • For point queries, MySQL 8.0 gets ~75% of the QPS vs MySQL 5.6
    • For range queries without aggregation, MySQL 8.0 gets 60% to 70% of the QPS vs MySQL 5.6
    • For range queries with aggregation, MySQL 8.0 and 5.6 get similar QPS. Perf for MySQL 5.7 is much better than 5.6, but with new CPU overheads in 8.0 that benefit is fading.
    • For writes, MySQL 8.0 gets up to 4X more QPS than MySQL 5.6 but the perf improvements for writes. are degrading as new releases add new CPU overhead

Builds

It isn't easy to build older code on newer systems, compilers, etc. Notes on that are here for 5.6, for 5.6 and 5.7, for 5.7 and for 8.0. A note on using cmake is here. The rel builds were used -- everything was compiled using CMAKE_BUILD_TYPE=Release.

Tests were done for:
  • 5.6 - 5.6.21, 5.6.31, 5.6.41, 5.6.51
  • 5.7 - all point releases from 5.7.10 to 5.7.43
  • 8.0 - all point releases from 8.0.13 to 8.0.35
I used the cy10a22_gcp_c2s30 config and it is here for 5.6, 5.7 and 8.0 (pre-8.0.30, post 8.0.30). 

Benchmarks

I used sysbench and my usage is explained here. Tests were run on a c2-standard-30 server from GCP with 15 cores, hyperthreads disabled, 120G RAM and 1.5T of local SSD via 4 NVMe devices with XFS and SW RAID 0. The test tables are cached by InnoDB.

The benchmark was run via: bash r.sh 4 20000000 600 1200 md127 1 1 8

Results

For the results below I split the benchmark steps into 5 groups -- 2 for point queries, 2 for range queries, 1 for writes. For the range query groups part 1 has queries that don't do aggregation while part 2 has queries that do aggregation. The spreadsheet with all data and charts is here and is easier to read. A spreadsheet with all results for the small server is here.

All of the charts have relative throughput on the y-axis where that is (QPS for $me) / (QPS for $base), $me is a version (for example 5.7.24) and $base is the base version. The base version is the oldest version being compared and the goal is to see whether QPS is better or worse over time. The y-axis doesn't start at zero to improve readability.

The results here include some releases from each of MySQL 5.6, 5.7 and 8.0. The goal is to show how performance has changed over time. Each section has two graphs -- one from the medium server, one from the small server.

Point queries, part 1

Summary
  • MySQL 8.0 gets ~75% of the throughput relative to MySQL 5.6
  • Ignoring bug fixes, like the benefit  from fixing bug 102037 in MySQL 8.0.31, the perf regressions are mostly slow and steady with new new release.
Point queries, part 2

Summary
  • MySQL 8.0 gets ~75% of the throughput relative to MySQL 5.6
  • Ignoring bug fixes, like the benefit  from fixing bug 102037 in MySQL 8.0.31, the perf regressions are mostly slow and steady with new new release.
Range queries, part 1

Summary
  • MySQL 8.0 gets 60% to 70% of the throughput relative to MySQL 5.6
  • Perf regressions are mostly slow and steady with new new release
Range queries, part 2

Summary
  • MySQL 8.0 and 5.6 get similar throughput
  • Perf regressions are mostly slow and steady with new new release. Perf for MySQL 5.7 is much better than 5.6 but that benefit is slowly fading in 8.0 because there is new CPU overhead.
Writes

Summary
  • MySQL 8.0 gets up to 4X more QPS than MySQL 5.6
  • Perf regressions are mostly slow and steady with new new release and the difference between modern MySQL and MySQL 5.6 is shrinking.


Monday, October 23, 2023

Perf regressions for MySQL/InnoDB vs the Insert Benchmark: 8.0.28 to 8.0.30

This post tries to explain a ~10% drop in the insert rate from MySQL 8.0.28 to 8.0.30 during the initial load done by the Insert Benchmark. It is a follow up to my previous post that shared results for all MySQL 8.0 releases.

tl;dr

  • MySQL needs to start using changepoint detection to find perf regressions
  • The largest threat to MySQL's future is perf regressions - Postgres doesn't have this problem
  • Most of the perf regressions during the initial load are from changes to code in the record layer (rec_get_offsets, rec_init_offsets, rec_get_nth_field). The problem is new CPU overheads.
  • On the bright side most of the regression is from InnoDB and the workaround is to use MyRocks
Updates

From my sysbench results, there are significant performance regressions in MySQL 8.0.28 and 8.0.30.

Percona has bug PS-8822 open for this.

The problem

The previous post has links to reports including this one that includes results for all 8.0 releases. The problem is visible in the Summary and the l.i0 benchmark step. The insert rate drops from 61896/s for 8.0.20 to 56726/s for 8.0.30 and then continues dropping to 54866/s for 8.0.34. The l.i0 benchmark step does the initial load of benchmark tables by inserting rows in PK order before secondary indexes are created.

From the vmstat and iostat metrics there is a small increase in CPU overhead (cpupq is CPU/insert) and context switches (cspq is context switches /insert).

I started by looking at the flamegraphs (see here) and then writing down the percentage of samples for parts of the flamegraph. My hard to decipher notes on those differences are here. At a high level, 8.0.30 spends more time in btr_cur_optimistic_insert and btr_cur_search_to_nth_level and their callees.
  • btr_cur_optimistic_insert accounts for ~11.8% of samples in 8.0.28 vs ~14.1% in 8.0.30
  • btr_cur_search_to_nth_level accounts for ~13.5% of samples in 8.0.28 vs ~15% in 8.0.30
At a low level, most of that difference appears to come from changes to record layer code, especially functions and/or macros like rec_get_offsets, rec_init_offsets, rec_init_offsets_comp_ordinary, rec_get_nth_field and rec_get_coverted_size_comp.
  1. A few macros were changed to functions, and might be harder to inline
  2. More code was added to a few macros and functions
The solution

Use changepoint detection to spot these problems before shipping a release.

Thursday, October 19, 2023

Checking RocksDB 7.x and 8.x for performance regressions on a large server

Yes we have no (or few) regressions seems to be as true for RocksDB as it is for Postgres. This isn't a big surprise for me but I am happy to document the result of so many other people working hard.

tl;dr

  • There are no, or few, regression in RocksDB from version 7.3.2 to 8.7.0. For most of the tests the QPS stays constant from 7.3.2 to 8.7.0.
  • Throughput for fillseq (insert in key order) improved by ~2X
  • Throughput for overwrite improved by ~1.2X
  • There is too much variance for fwdrange. The workaround is to use Hyper Clock.
Builds

For these tests I must use a special compiler toolchain and wasn't able to compile RocksDB 7.3.0, 7.3.1 or 7.3.2. For that reason I didn't even consider compiling RocksDB 6.x, 5.x or 4.x versions.

I was able to build RocksDB 7.4.5, 7.5.4, 7.6.0, 7.7.8, 7.8.3, 7.9.3, 7.10.2, 8.0.0, 8.1.1, 8.2.1, 8.3.3, 8.4.4, 8.5.4, 8.6.7 and 8.7.0 which are the latest patch releases. While I ran tests for builds that were done with clang and gcc, the results here are from the clang builds.

Benchmark

All tests used a server with 40 cores, 80 HW threads, 2 sockets, 256GB of RAM and many TB of fast NVMe SSD with Linux 5.1.2, XFS and SW RAID 0 across 6 devices.

Everything used the LRU block cache and nothing used Hyper Clock.

I used my fork of the RocksDB benchmark scripts that are wrappers to run db_bench. These run db_bench tests in a special sequence -- load in key order, read-only, do some overwrites, read-write and then write-only. The benchmark was repeated using 12, 24 and 48 client threads. At 12 the CPU is undersubscribed and at 48 it can be oversubscribed depending on IO latency. How I do benchmarks for RocksDB is explained here and here.

The benchmark was repeated in three setups:
  • cached - database fits in the RocksDB block cache
  • iobuf - IO-bound, working set doesn't fit in memory, uses buffered IO
  • iodir - IO-bound, working set doesn't fit in memory, uses O_DIRECT

Results: 12 threads

The improve readability the y-axis starts at 0.9 and stops at 1.30. Some results are larger than 1.30 and will be truncated. A spreadsheet with all results is here. The charts show the QPS for a given release relative to the QPS for RocksDB 7.3.2 using: (QPS for $version) / (QPS for RocksDB 7.3.2). A value larger than 1 means that the version gets more QPS than RocksDB 7.3.2. A value equal to 1 means they get similar QPS.

Summary:

  • There is a big improvement for IO-bound fillseq and overwrite
  • There is too much variance for fwdrange
  • Otherwise modern RocksDB is >= older RocksDB

Results: 24 threads

The improve readability the y-axis starts at 0.9 and stops at 1.30. Some results are larger than 1.30 and will be truncated. A spreadsheet with all results is here. The charts show the QPS for a given release relative to the QPS for RocksDB 7.3.2 using: (QPS for $version) / (QPS for RocksDB 7.3.2). A value larger than 1 means that the version gets more QPS than RocksDB 7.3.2. A value equal to 1 means they get similar QPS.

Summary:

  • There is a big improvement for IO-bound fillseq and overwrite
  • There is too much variance for fwdrange
  • Otherwise modern RocksDB is >= older RocksDB

Results: 48 threads

The improve readability the y-axis starts at 0.9 and stops at 1.30. Some results are larger than 1.30 and will be truncated. A spreadsheet with all results is here. The charts show the QPS for a given release relative to the QPS for RocksDB 7.3.2 using: (QPS for $version) / (QPS for RocksDB 7.3.2). A value larger than 1 means that the version gets more QPS than RocksDB 7.3.2. A value equal to 1 means they get similar QPS.

Summary:
  • There is a big improvement for IO-bound fillseq and overwrite
  • There is too much variance for fwdrange
  • Otherwise modern RocksDB is >= older RocksDB


Tuesday, October 10, 2023

Variance in RocksDB benchmarks

This post is about variance that occurs in some of the RocksDB benchmark tests. I run tests on small, medium and large servers and the problems only occur on the large server. The problems also only occur on benchmarks that use range queries. I spend much time looking for performance regressions and variance makes it harder to spot them.

While I have been aware of this issue for more than a year, I ignored it until recently. While I have yet to explain the root cause, the workaround is simple -- use Hyper Clock rather than LRU for the block cache. See my previous post that hypes the Hyper Clock cache. 

tl;dr

  • with the LRU block cache the QPS can vary by ~2X for read-only range query tests
  • use Hyper Clock cache instead of LRU for the block cache to avoid variance
  • the QPS from Hyper Clock for read-only range query tests can be 2X to 3X larger than for the LRU block cache
  • the signal that this might be a problem is too much system CPU time
  • pinning threads to one socket improves throughput when using the LRU cache but does not avoid the variance for range queries on read-only tests
Updates

Aggregated thread stacks from PMP are here for the fwdrange test with 24 threads and 48 threads. These are computed over ~10 call-stack samples. From the call stacks there isn't a significant difference between the runs where the result was bad (too much system CPU time, too much mutex contention) and where the result was good. But it is clear there is a lot of mutex contention.

A hypothesis

My theory at this point is that there is non-determinism in how the block cache is populated and the block cache ends up in one of two states - bad and good. The benchmarks are read-only and the block cache is large enough to cache the entire database. So once the block cache gets into one state (bad or good) it remains in that state. This is a risk of a read-only benchmark. If there were some writes, then the state of the LSM tree and in-memory structures would change over time and not get stuck.

Alas, this is just a theory today.

Hardware

I use three server types that I call small, medium and large:
  • small - 8 cores, 16G RAM, a Beelink (see here)
  • medium - 15 cores with hyperthreads disabled, c2-standard-30 from Google (GCP)
  • large - 2 sockets, 80 HW threads, 40 cores with hyperthreads enabled
Benchmark

I used the RocksDB benchmarks scripts and my usage is explained here and here. The benchmark client is named db_bench. The benchmark runs a sequence of tests in a specific order:
  1. initial load
  2. read-only tests for point and range queries
  3. write-only tests to fragment the LSM tree (results are ignored)
  4. read-write tests
  5. write-only tests
For this post I stopped the benchmark after step 2 because the variance occurs during the read-only tests. A spreadsheet with all results is here. I focus on results for the fwdrange and readrandom tests. Both are read-only, fwdrange does range queries and readrandom does point queries.

The benchmark was repeated for 12, 24 and 48 threads. For each number of threads it was repeated 3 times thus the graphs below have 3 clusters of bars for base, 3 for hyper, 3 for cpu0 and 3 for cpu0.mem0.. And then each run was done for RocksDB 8.0, 8.1, 8.2, 8.3, 8.4, 8.5, and 8.6. So in the graphs below each clusters of 7 bars has results for RocksDB 8.0 to 8.6.

The benchmark was run by the following. It loads 100M KV pairs and the database is ~40G. The RocksDB block cache is large enough to cache the database. 

dop=$1
secs=600
comp=clang

for i in $( seq 1 3 ); do
  bash x3.sh $dop no $secs c40r256bc180 100000000 4000000000 byrx
  mv res.byrx res.byrx.t${dop}.${secs}s.$comp.$i
done

Configurations

I tested four configurations. From the results below, while pinning threads to one sockets improves performance the only way to avoid the variance is to use the Hyper Clock cache.
  • base
    • use the LRU block cache and numactl --interleave=all
  • hyper
    • use the Hyper Clock block cache and numactl --interleave=all
  • cpu0
    • use the LRU block cache and numactl --cpunodebind=0 --interleave=all to pin all threads to one socket but allocate memory from both sockets
  • cpu0.mem0
    • use the LRU block cache and numactl --cpunodebind=0 --localalloc to pin all threads to one socket and allocate memory from that socket
Range queries: QPS

The graphs show the average QPS for fwdrange tests (read-only, point queries) using 12, 24 and 48 threads.
  • At 12 threads the variance is best for hyper, not bad for cpu0 and cpu0.mem0 and worst for base
  • At 24 and 48 threads the variance is best for hyper, bad for cpu0 and cpu0.mem0 and lousy for base
  • For base the QPS increases from 12 to 24 threads, but not from 24 to 48. See the spreadsheet.
  • For hyper the QPS increases from 12 to 24 to 48 threads
  • The QPS from hyper is up to 3X larger than from base


Range queries: system vs user CPU time

The graphs here have the ratio: system CPU time / user CPU time for the fwdrange tests (read-only, range queries). Based on the graphs, I will guess that the problem is mutex contention because the ratio is large for the LRU block cache (base, cpu0, cpu0.mem) and small for the Hyper Clock cache (hyper).

It is also interesting that the ratio for the LRU block cache is smaller when all threads are pinned to one socket (cpu0, cpu0.mem) vs not pinning them (base).
Range queries: vmstat

This adds some output form vmstat from fwdrange with 24 threads for the base configuration that uses the LRU block cache. The good result gets 456762 QPS from RocksDB 8.0 and the bad result gets 315960 QPS from RocksDB 8.5. Note that the same RocksDB can get good and bad results.
  • The CPU utilization (us + sy columns) is similar but the sy/us ratio is much larger in the bad result
  • The average context switch rate is similar (cs column)
  • Given that the QPS with the good result is ~1.45X larger than with the bad result, the amount of CPU/query and number of context switches / query are much larger in the bad result.

The good result

procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
25  0      0 58823196 406932 154263328    0    0     0    36 221215 848850 22  7 71  0  0
24  0      0 58822520 406932 154263328    0    0     0   340 221711 847153 23  7 71  0  0
23  0      0 58824152 406940 154263392    0    0     0   352 231440 854547 24  7 70  0  0
23  0      0 58821568 406940 154263424    0    0     0    44 224095 847201 23  7 71  0  0
24  0      0 58822080 406940 154263472    0    0     0     4 221711 845231 22  7 71  0  0
25  0      0 58823344 406940 154263456    0    0     0   156 220700 842168 22  7 71  0  0
24  0      0 58823148 406948 154263552    0    0     0   364 221957 841721 23  7 71  0  0
21  0      0 58826844 406948 154263600    0    0     0   288 220392 842787 23  6 71  0  0
24  0      0 58824240 406948 154263648    0    0     0   112 223243 845933 23  7 71  0  0
25  0      0 58805068 406948 154263680    0    0     0     4 222477 842962 23  6 71  0  0

The bad result

procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
23  0      0 55562296 444928 156854032    0    0     0     4 174564 836501 18 12 70  0  0
23  0      0 55503180 444928 156854224    0    0     0     4 175928 852824 18 13 70  0  0
23  0      0 55595540 444928 156854176    0    0     0    60 175285 833147 18 13 70  0  0
26  0      0 55518432 444928 156854432    0    0     0    52 174733 851865 18 13 70  0  0
27  0      0 55743232 444940 156854464    0    0     0   296 175891 834044 18 13 70  0  0
26  0      0 55724756 444940 156854624    0    0     0    60 174582 828127 18 13 70  0  0
24  0      0 55741960 444940 156854624    0    0     0     4 173324 828154 18 12 70  0  0
24  0      0 55722464 444940 156854768    0    0     0   100 172768 824844 18 12 70  0  0
25  0      0 55718576 444940 156853888    0    0     0   416 173330 828159 18 12 70  0  0
23  0      0 55692152 444948 156860352    0    0     0  2136 176929 832113 18 12 70  0  0

Point queries: QPS

This shows the average QPS for the readrandom test (read-only, point queries). Variance is not a problem.

Monday, October 9, 2023

Perf regressions in MySQL from 5.6.21 to 8.0.34 using the Insert Benchmark and a small server, part 2

This post has results from the Insert Benchmark for some MySQL 5.6 releases, all 5.7 releases and all 8.0 releases using a small server and an IO-bound workload. The previous post has results from a cached workload.

tl;dr

  • There are significant regressions from 8.0.28 to 8.0.30 that I hope to explain in the future
  • There are significant regressions from 5.6 to 8.0 but they are smaller here for an IO-bound workload than for a cached workload
  • InnoDB perf would be easier to debug if there were counters for time (CPU seconds, wall clock) spent by InnoDB background threads, foreground threads doing single-page flushing, and foreground threads stalled on writeback while waiting for clean buffers.

Builds

It isn't easy to build older code on newer systems, compilers, etc. Notes on that are here for 5.6, for 5.6 and 5.7, for 5.7 and for 8.0. A note on using cmake is here. The rel builds were used as everything was compiled using CMAKE_BUILD_TYPE=Release.

Tests were done for:
  • 5.6 - 5.6.21, 5.6.31, 5.6.41, 5.6.51
  • 5.7 - all point releases from 5.7.10 to 5.7.43
  • 8.0 - all point releases from 8.0.13 to 8.0.34
I used the cy10a_bee config and it is here for 5.6, 5.7 and 8.0. For 8.0 releases older than 8.0.19 I changed innodb_idle_flush_pct=1 to loose_innodb_idle_flush_pct=1.

Benchmark

The Insert Benchmark was run in one setup, IO-bound as the database was larger than memory, there are many reads from storage for user queries.

The benchmark used the Beelink server explained here that has 8 cores, 16G RAM and 1TB of NVMe SSD with XFS and Ubuntu 22.04. 

The benchmark is run with 1 client and 1 table. The benchmark is a sequence of steps.

  • l.i0
    • insert 800 million rows per table
  • l.x
    • create 3 secondary indexes. I usually ignore performance from this step.
  • l.i1
    • insert and delete another 5 million rows per table with secondary index maintenance. The number of rows/table at the end of the benchmark step matches the number at the start with inserts done to the table head and the deletes done from the tail. 
  • q100, q500, q1000
    • do queries as fast as possible with 100, 500 and 1000 inserts/s/client and the same rate for deletes/s done in the background. Run for 1200 seconds.
Results

The Summary sections linked below have tables for absolute and relative throughput. Absolute throughput is just the QPS per version. The relative throughput is (QPS for my version / QPS for base version). The base version is 5.6.21 for the 5.6-only report, 5.7.10 for the 5.7-only report, 8.0.13 for the 8.0-only report and 5.6.21 for the report that compares 5.6, 5.7 and 8.0.

Reports are here for
  • Some MySQL 5.6 releases
    • From the Summary - throughput drops by ~6% for the l.i0 benchmark step (initial load) from 5.6.21 to 5.6.51. Otherwise throughput doesn't change. 
    • The results here for IO-bound are better than the results for a cached workload that had regressions for more benchmark steps.
    • Results from vmstat/iostat metrics are similar across versions
  • All MySQL 5.7 releases
    • From the Summary throughput in 5.7.43 drops by (6%, 8%, 4%) for write-heavy (l.i0, l.x, l.i1) and (2%, 2%, 2%) for read-heavy (q100, q500, q1000) benchmark steps relative to the base case (5.7.10). 
    • The results here for IO-bound are similar to the results for a cached workload.
    • Results from vmstat/iostat metrics show there is a small increase in CPU/operation for the write-heavy steps (l.i0, l.x, l.i1).
  • All MySQL 8.0 releases
    • From the Summary throughput drops by ~17% for the l.i0 benchmark step (initial load) from 8.0.10 to 8.0.34. Otherwise throughput doesn't change. 
    • Comparing these results to a cached workload - both have the ~20% regression for l.i0 but the cached workload results also have ~20 regressions for the read-write steps (q100, q500, q1000).
    • Results from the vmstat/iostat metrics are interesting. They might show an 8% increase in CPU/operation (see cpupq). They definitely show a large decrease (more than half) in context switches per operation (see cspq). Write IO per operation (see wkbpi) doesn't change but MB written to IO/s (see wmbps) drops by ~25%. So it is possible that writeback got slower over time and that slowdown is the root cause for the regression in l.i0. Also, for both cached and IO-bound workloads the l.i0 throughput drops by ~7% from 8.0.28 to 8.0.30 (there is no 8.0.29). I would like to see counters for the time (wall clock, CPU seconds) for which InnoDB background threads are active but I have yet to find that in the PS or IS.
  • Comparing MySQL 5.6, 5.7 and 8.0
    • From the Summary throughput drops by ~50% for l.i0, increases by ~30% for l.x and l.i1 and drops by up to 10% for the read-write steps (q100, q500, q1000).
    • Comparing these results to a cached workload - both have the ~20% regression for l.i0 and ~20% improvement for l.x but they diverge for other benchmark steps. For l.i1 8.0.34 is ~30% faster than 5.6.21 with IO-bound vs ~20% slower with cached. For the read-write steps (q100, q500, q1000) 8.0.34 is up to 10% slower with IO-bound vs ~50% slower with cached.
    • Results from the vmstat/iostat metrics show
      • A ~1.5X increase in CPU/operation for l.i0. All of that is in 8.0.x.
      • A ~3X increase in CPU/operation for l.x that arrives between 8.0.20 and 8.0.27.
      • A ~1.5X increase in CPU/operaton for q100 that arrives in 5.7.10. That drops to ~1.1X for q500 and then doesn't repeat in q1000.














Monday, October 2, 2023

Variance in peak RSS with jemalloc 5.2.1, part 2

I previously shared results to show peak RSS by jemalloc version for the Insert Benchmark. This post has additional results. 

The problem is that peak RSS is larger during the l.x benchmark step when Hyper Clock Cache is enabled and the difference large enough that there might be OOM in production unless you are prepared for this.

The previous results were from an unmodified Insert Benchmark that has the l.x benchmark step to create secondary indexes after the database has been loaded by the l.i0 benchmark step. Here I changed the Insert Benchmark to create the secondary indexes at the start of the l.i0 benchmark step and skip l.x. The theory is that the large memory allocations done during create index contribute to the problem. One source of large allocations is determined by the value of rocksdb_merge_combine_read_size which I set to 64M for these tests -- so that is large but not huge.

tl;dr

  • The peak RSS problems with Hyper Clock Cache don't reproduce when the l.x step is skipped
  • Peak RSS is too large for jemalloc 4.4 and 4.5 and that gets fixed over several 5.x releases. Tobin Baker suggested these might be from changes to the usage of MADV_FREE and MADV_DONTNEED.
  • The je-5.2.1.prod configuration does better than the other jemalloc 5.2 configuration I tested. Perhaps this is from the usage of background_thread:true.
Benchmark and builds

The benchmark and test HW is explained here. The jemalloc versions, jemalloc configurations and MyRocks configurations are explained here. In this post I share results for the c7 MyRocks configuration that enables the Hyper Clock Cache.

The insert benchmark was run in one setup -- the database was larger than memory. The benchmark used a c2-standard-30 server from GCP with Ubuntu 22.04, 15 cores, hyperthreads disabled, 120G of RAM and 1.5T of storage from RAID 0 over 4 local NVMe devices with XFS.

The benchmark is run with 8 clients and 8 tables. The benchmark is a sequence of steps.

  • l.i0
    • insert 50 million rows per table
  • l.x
    • create 3 secondary indexes.
  • l.i1
    • insert and delete another 100 million rows per table with secondary index maintenance. The number of rows/table at the end of the benchmark step matches the number at the start with inserts done to the table head and the deletes done from the tail. 
  • q100, q500, q1000
    • do queries as fast as possible with 100, 500 and 1000 inserts/s/client and the same rate for deletes/s done in the background. Run for 1800 seconds.

jemalloc configurations

Output from stats_print:true is here for all versions tested. Output from grep to determine the value for muzzy_decay_ms per version is below. All of the configurations get the default except for stats.j521ub (je-5.2.1.ub) which sets it to zero (but zero is the default for 5.2.1).

je-5.0.1:      opt.muzzy_decay_ms: 10000 (arenas.muzzy_decay_ms: 10000)
je-5.1.0:      opt.muzzy_decay_ms: 10000 (arenas.muzzy_decay_ms: 10000)
je-5.2.0:      opt.muzzy_decay_ms: 0 (arenas.muzzy_decay_ms: 0)
je-5.2.1:      opt.muzzy_decay_ms: 0 (arenas.muzzy_decay_ms: 0)
je-5.2.1.prod: opt.muzzy_decay_ms: 0 (arenas.muzzy_decay_ms: 0)
je-5.2.1.prof: opt.muzzy_decay_ms: 0 (arenas.muzzy_decay_ms: 0)
je-5.2.1.ub:   opt.muzzy_decay_ms: 0 (arenas.muzzy_decay_ms: 0)
je-5.3.0:      opt.muzzy_decay_ms: 0 (arenas.muzzy_decay_ms: 0)

Results

A spreadsheet with results is here. The with_l.x sheet has results with the l.x benchmark step and these were explained in a previous blog post. The no_l.x sheet has results where the l.x benchmark step is skipped.

The first chart is from a previous blog post to show peak RSS with the Hyper Clock Cache when the l.x benchmark step is not skipped. I focus on the result for l.x where there is a spike for je-5.2.1.ub.
This chart is from the most recent tests where the l.x benchmark step is skipped. 
  • There are still spikes with jemalloc 4.4 and 4.5 that are fixed by 5.2
  • Within the 5.2 builds the best result is from je-5.2.1.prod and that might be from using background_thread:true


Postgres versions 11, 12, 13, 14, 15, and 16 vs sysbench with a medium server

This provides additional results for Postgres versions 11 through 16 vs Sysbench on a medium server. My previous post is here. The goal is to document how performance changes over time with a focus on CPU overheads.

tl;dr

  • Postgres avoids performance regressions from old to new versions. This is excellent.
  • Postgres 16.0 is mostly faster than 11.21 on read-only benchmark steps
  • Postgres 16.0 and 11.21 have similar throughput on read-write and write-only benchmark steps

Builds

I compiled Postgres 11.21, 12.16, 13.12, 14.9, 15.2, 15.3, 15.4 and 16.0. The builds are named o3_native_lto which is shorthand for using: -O3 -march=native -mtune=native -flto.

Benchmark

I used sysbench and my usage is explained here. Postgres was configured to cache all tables.

This benchmark used a c2-standard-30 server from GCP with 15 cores, hyperthreads disabled, 120G of RAM, Ubuntu 22.04 and 1.5TB of NVMe SSD with XFS (SW RAID 0 over 4 local devices).

The benchmark is run with 8 clients and 4 table with 20M rows per table. The read-only tests ran for 600 seconds each and the other tests ran for 1200 seconds each. The command line for my wrapper scripts is:

bash r.sh 4 20000000 600 1200 md127 1 1 8

The benchmark used the x7a28 config and for Postgres versions 11.21 and 12.16 I had to remove the usage of autovacuum_vacuum_insert_scale_factor as that arrives in version 14.

Results

There were two rounds of the benchmark. The first has results for 11.21, 12.16, 13.12, 14.9, 15.4 and then two sets of results for 16.0. The second has results for 11.21, 12.16, 13.12, 14.9, 15.2, 15.3 and 15.4.

A spreadsheet with results is here. The spreadsheet has 4 sheets, 2 for each round of the benchmark. And for each round there is one sheet with the absolute values (QPS) per benchmark step while the other has relative QPS -- (QPS for my version) / (QPS for Postgres 11.21).

There are ~42 tests and each can be called a benchmark step or microbenchmark. I will call them benchmark steps. These are put into one of 5 groups based on the workload:

  • point query, part 1 - point queries that don't use the random-points benchmark step
  • point query, part 2 - point query variants that use the random-points benchmark step
  • range query, part 1 - range queries without aggregation
  • range query, part 2 - read-only variants of the original sysbench workload that does range queries with aggregation
  • writes - benchmark steps that do insert, update and delete

The y-axis starts at 0.8 or 0.76 rather than 0 to make it easier to see the changes.

A summary

  • There are two benchmark steps that have too much variance which can look like a regression:
    • update-one_range=100 - this does updates, but all updates are to the same row
    • scan_range=100 - this does a full scan with a filter that no rows satisfy
  • Point queries, part 1 - Postgres 16.0 is as fast or faster than 11.21
  • Point queries, part 2 - Postgress 16.0 is as fast or faster than 11.21
  • Range queries, part 1 - Postgres 16.0 is as fast or faster than 11.21, ignoring scan_range
  • Range queries, part 2 - Postgress 16.0 is as fast or faster than 11.21
  • Writes - Postgres 16.0 and 11.21 have similar throughput, ignoring update-one
Point queries, part 1
Point queries, part 2
Range queries, part 1
Range queries, part 2
Writes

CPU-bound sysbench on a large server: Postgres 12 to 19 beta1

This has results from sysbench on a small server with Postgres versions 12 through 19 beta1. Sysbench is run with high concurrency (40 conne...