Saturday, April 13, 2024

The Insert Benchmark: MariaDB, MySQL, small server, cached workload

This post has results for the Insert Benchmark on a small server with a cached workload. The goal is to compare MariaDB and MySQL.

This work was done by Small Datum LLC and sponsored by the MariaDB Foundation.

The workload here has low concurrency and the database is cached. The results might be different when the workload is IO-bound or has more concurrency.

tl;dr

  • Modern MariaDB (11.4.1) is faster than modern MySQL (8.0.36) on all benchmark steps except for qr* (range query) and l.x (create index) where they have similar performance.
  • Modern MariaDB (11.4.1) was at most 15% slower than older MariaDB (10.2.44). MariaDB has done a great job of avoiding performance regressions over time.
  • There are significant performance regressions from older MySQL (5.6) to modern MySQL (8.0)
  • Performance with innodb_flush_method set to =O_DIRECT_NO_FSYNC is better than with =O_DIRECT is better than =fsync.

Build + Configuration

This report has results for InnoDB from:
  • MySQL - versions 5.6.51, 5.7.44 and 8.0.36
  • MariaDB - versions 10.2.44, 10.3.39, 10.4.33, 10.5.24, 10.6.17, 10.11.7, 11.4.1. Versions 10.2, 10.3, 10.4, 10.5, 10.6 and 10.11 are the most recent LTS releases and 11.4 will be the next LTS release.
All of the my.cnf files are here. I tried to use similar configurations across releases, but isn't always possible. And even when it was possible I favor setting fewer entries especially for options where the default value changes between releases.

I started with the my.cnf.cz11a_bee config and then began to make small changes. For all configs I set these values to limit the size of the history list which also keeps the database from growing larger than expected. I rarely did this in the past.
innodb_max_purge_lag=500000
innodb_max_purge_lag_delay=1000000

Some of the changes were challenging when trying to make things comparable. 
  • the InnoDB change buffer was removed in MariaDB 11.4. 
    • I disable it in all my.cnf files for all MariaDB versions except for the my.cnf.cz11d and my.cnf.cz11d1 configs.
    • I don't disable it for the MySQL configs named my.cnf.cz11[abc]_bee but I do disable it for the my.cnf.cz11d_bee config used by MySQL. The result is that for MariaDB the my.cnf.cz11d_bee config enables the change buffer while for MySQL it disables it. Sorry for the confusion.
  • innodb_buffer_pool_instances was removed in 10.5 (assume it is =1). 
    • I don't set it to =1 in the my.cnf.cz[abc]_bee configs for MariaDB 10.2, 10.3, 10.4
  • innodb_flush_method was removed in 11.4 and there is a new way to configure this.
    • In 11.4.1 there is an equivalent of =O_DIRECT but not of =O_DIRECT_NO_FSYNC
For MariaDB the typical my.cnf files were:
  • my.cnf.cz11a_bee - uses innodb_flush_method=O_DIRECT_NO_FSYNC
  • my.cnf.cz11a1_bee - like my.cnf.cz11a_bee but reduces the sizes of the buffer pool and redo log so that both fit in memory
  • my.cnf.cz11b_bee - uses innodb_flush_method=O_DIRECT
  • my.cnf.cz11b1_bee - like my.cnf.cz11b_bee but reduces the sizes of the buffer pool and redo log so that both fit in memory
  • my.cnf.cz11c_bee - uses innodb_flush_method=fsync
  • my.cnf.cz11d_bee - uses innodb_flush_method=O_DIRECT_NO_FSYNC and enables the InnoDB change buffer
  • my.cnf.cz11d1_bee - like my.cnf.cz11d_bee but reduces the sizes of the buffer pool and redo log so that both fit in memory
For MySQL the typical my.cnf files were:
  • my.cnf.cz11a_bee - uses innodb_flush_method=O_DIRECT_NO_FSYNC
  • my.cnf.cz11b_bee - uses innodb_flush_method=O_DIRECT
  • my.cnf.cz11c_bee - uses innodb_flush_method=fsync
  • my.cnf.cz11d_bee - uses innodb_flush_method=O_DIRECT_NO_FSYNC and disables the InnoDB change buffer. Note the my.cnf.cz11[abc]_bee configs for MySQL enabled it. This is the opposite of what is done for MariaDB.
The Benchmark

The benchmark is run with 1 client. It is explained here and was run in two setups with a cached workload. The initial load (l.i0) inserts 30M rows and the database fits in memory. I recently updated the Insert Benchmark to change how deletes are done and the new delete SQL is here.

The test server was named v4 here and is a Beelink SER4. It has 8 cores, 16G RAM, Ubuntu 22.04 and XFS using 1 m.2 device.

The benchmark steps are:

  • l.i0
    • insert 30 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 40M rows 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 10M rows are inserted and deleted.
    • 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
Results

The performance reports are here for:
The summary in each performance report has 3 tables. The first shows absolute throughput by DBMS tested X benchmark step. The second has throughput relative to the version from the first row of the table. The third shows the background insert rate for benchmark steps with background inserts and all systems sustained the target rates. The second table makes it easy to see how performance changes over time. The third table makes it easy to see which DBMS+configs failed to meet the SLA.

Below I use relative QPS to explain how performance changes. It is: (QPS for $me / QPS for $base) where $me is my version and $base is the version of the base case. When relative QPS is > 1.0 then performance improved over time. When it is < 1.0 then there are regressions. 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
Below I use colors to highlight the relative QPS values with red for <= 0.95, green for >= 1.05 and grey for values between 0.95 and 1.05.

Results: MariaDB vs MySQL

Modern MariaDB (11.4.1) is faster than modern MySQL (8.0.36) on all benchmark steps except for qr* (range query) and l.x (create index) where they have similar performance.
  • The base case is MariaDB 10.11.7 with the cz11a_bee config (ma101107_rel.cz11a_bee). It is compared with
    • MariaDB 11.4.1 with the cz11b_bee config (ma110401_rel.cz11b_bee)
    • MySQL 8.0.36 with the cz11a_bee config (my8036_rel.cz11a_bee)
  • Relative throughput per benchmark step
    • l.i0
      • relative QPS is 0.98 in MariaDB 11.4.1
      • relative QPS is 0.68 in MySQL 8.0.36
    • l.x - I ignore this for now
    • l.i1, l.i2
      • relative QPS is 0.930.97 in MariaDB 11.4.1
      • relative QPS is 0.880.78 in MySQL 8.0.36
    • qr100, qr500, qr1000
      • relative QPS is 1.03, 1.021.01 in MariaDB 11.4.1
      • relative QPS is 1.021.041.04 in MySQL 8.0.36
    • qp100, qp500, qp1000
      • relative QPS is 1.001.001.00 in MariaDB 11.4.1
      • relative QPS is 0.760.740.75 in MySQL 8.0.36
Results: MariaDB

Modern MariaDB (11.4.1) was at most 15% slower than older MariaDB (10.2.44). MariaDB has done a great job of avoiding performance regressions over time.

  • The base case is MariaDB 10.2.44 with the cz11a_bee config (ma100244_rel.cz11a_bee). It is compared with more recent LTS releases from 10.3, 10.4, 10.5, 10.6, 10.11 and 11.4.
  • Throughput per benchmark step for 11.4.1 relative to 10.2.44
    • l.i0
      • relative QPS is 0.86 in MariaDB 11.4.1
    • l.x - I ignore this for now
    • l.i1, l.i2
      • relative QPS is 1.081.07 in MariaDB 11.4.1
    • qr100, qr500, qr1000
      • relative QPS is 0.89, 0.86, 0.85 in MariaDB 11.4.1
    • qp100, qp500, qp1000
      • relative QPS is 0.91, 0.91, 0.88 in MariaDB 11.4.1
Results: MariaDB 10.11

  • The base case is MariaDB 10.11.7 with the cz11a_bee config (ma101107_rel.cz11a_bee) and 10.11.7 releases with other configs are compared to it.
  • Performance does not change with the cz11a1_bee config that uses a smaller size for the InnoDB redo log and buffer pool so that they fit in memory. In workloads that are more IO-bound I see that MariaDB 10.11+ does read IO for the redo log while MySQL does not. Shrinking the buffer pool and redo log isn't good for performance but avoids the read IO.
  • Performance is worse with the cz11b_bee config on the random write (l.i1, l.i2) benchmark steps. This indicates that setting innodb_flush_method to O_DIRECT_NO_FSYNC is better than setting it to O_DIRECT.
  • Performance is worse with the cz11c_bee config on the random write (l.i1, l.i2) benchmark steps. This indicates that setting innodb_flush_method to O_DIRECT_NO_FSYNC is better than setting it to fsync.
  • Performance does not change with the cz11d_bee config which enabled the InnoDB change buffer. Given that the working set fits in the InnoDB buffer pool the result is expected.
  • Performance is worse with the cz11d1_bee config on the random write (l.i1, l.i2) benchmark steps. See the comments above for cz11a1_bee.
Results: MariaDB 11.4
  • The base case is MariaDB 11.4.1 with the cz11b_bee config (ma110401.cz11b_bee) and 11.4.1 releases with other configs are compared to it. Note that 11.4.1 does not support the equivalent of O_DIRECT_NO_FSYNC for innodb_flush_method.
  • Performance is worse with the cz11b1_bee config on the random write (l.i1, l.i2) benchmark steps. See the comments in the previous section on the cz11a1_bee config.
  • Performance is slightly worse with the cz11c_bee config on the random write (l.i1, l.i2) benchmark steps. This indicates that setting innodb_flush_method to O_DIRECT_NO_FSYNC is better than setting it to fsync.
Results: MySQL

There are significant performance regressions from MySQL 5.6 to 8.0.

  • The base case is MySQL 5.6.51 with the cz11a_bee config (my5651_rel.cz11a_bee) and it is compared to MySQL 5.7.44 and 8.0.36.
  • Relative throughput per benchmark step
    • l.i0
      • relative QPS is 0.84 in MySQL 5.7.44
      • relative QPS is 0.57 in MySQL 8.0.36
    • l.x - I ignore this for now
    • l.i1, l.i2
      • relative QPS is 1.170.89 in MySQL 5.7.44
      • relative QPS is 1.070.73 in MySQL 8.0.36
    • qr100, qr500, qr1000
      • relative QPS is 0.73, 0.72, 0.71 in MySQL 5.7.44
      • relative QPS is 0.630.630.63 in MySQL 8.0.36
    • qp100, qp500, qp1000
      • relative QPS is 0.820.790.80 in MySQL 5.7.44
      • relative QPS is 0.620.600.62 in MySQL 8.0.36

No comments:

Post a Comment

Fixing some of the InnoDB scan perf regressions in a MySQL fork

I recently learned of Advanced MySQL , a MySQL fork, and ran my sysbench benchmarks for it. It fixed some, but not all, of the regressions f...