Hi,
Me and my team are noticing quite a significant performance degradation from Percona 5.7 to 8.0 in terms of INSERTs/UPDATEs. Here is a test I’m using (straight from bash):
- Create a test DB and a test table
mysql -sN -u root -e "DROP DATABASE IF EXISTS test; CREATE DATABASE test;"
mysql -sN -u root test -e "CREATE TABLE test (signature varbinary(767) NOT NULL DEFAULT '', id bigint NOT NULL AUTO_INCREMENT, count int NOT NULL, PRIMARY KEY (id), UNIQUE KEY idx_signature (signature)) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb3"
- Run 10000 samples of INSERTs with increasing signature 1-10000. Then sum all “update” results from the profiling and divide them to the samples amount (10000) to get the average processing (bash):
(single node Percona Cluster 8.0.29)
for c in $(seq 1 10000); do mysql -sN -u root test -e "set global profiling_history_size=100;set profiling=1;INSERT INTO test VALUES ('signature$c', 0, 1) ON DUPLICATE KEY UPDATE count = count + 1;set profiling=0;SHOW PROFILE FOR QUERY 1"; done | grep update | awk 'BEGIN{sum=0;cnt=0;}{sum+=$2;cnt++;}END{printf(strftime("%Y-%m-%d %H:%M:%S")" %.6f\n", (sum/cnt))}'
2022-09-12 09:36:45 0.000084
- The first loop uses only the INSERTs. The second run on the same loop is to trigger ON DUPLICATE KEY UPDATE:
for c in $(seq 1 10000); do mysql -sN -u root test -e "set global profiling_history_size=100;set profiling=1;INSERT INTO test VALUES ('signature$c', 0, 1) ON DUPLICATE KEY UPDATE count = count + 1;set profiling=0;SHOW PROFILE FOR QUERY 1"; done | grep update | awk 'BEGIN{sum=0;cnt=0;}{sum+=$2;cnt++;}END{printf(strftime("%Y-%m-%d %H:%M:%S")" %.6f\n", (sum/cnt))}'
2022-09-12 09:38:32 0.000120
- The same on single node Percona Cluster 5.7.39 - INSERTs:
for c in $(seq 1 10000); do mysql -sN -u root test -e "set global profiling_history_size=100;set profiling=1;INSERT INTO test VALUES ('signature$c', 0, 1) ON DUPLICATE KEY UPDATE count = count + 1;set profiling=0;SHOW PROFILE FOR QUERY 1"; done | grep update | awk 'BEGIN{sum=0;cnt=0;}{sum+=$2;cnt++;}END{printf(strftime("%Y-%m-%d %H:%M:%S")" %.6f\n", (sum/cnt))}'
2022-09-12 09:42:36 0.000051
- ON DUPLICATE KEY UPDATE:
for c in $(seq 1 10000); do mysql -sN -u root test -e "set global profiling_history_size=100;set profiling=1;INSERT INTO test VALUES ('signature$c', 0, 1) ON DUPLICATE KEY UPDATE count = count + 1;set profiling=0;SHOW PROFILE FOR QUERY 1"; done | grep update | awk 'BEGIN{sum=0;cnt=0;}{sum+=$2;cnt++;}END{printf(strftime("%Y-%m-%d %H:%M:%S")" %.6f\n", (sum/cnt))}'
2022-09-12 09:44:06 0.000086
There is about 0.000030s degradation in the performance. We have tried a lot of different options - to disable/lower fsyncs, different flush methods, disable-log-bin, but none helped.
In the InnoDB engine statuses we see a significant (double) increase of the file reads/writes:
5.7.39:
641 OS file reads, 20966 OS file writes, 20392 OS fsyncs
0.22 reads/s, 16384 avg bytes/read, 240.10 writes/s, 219.65 fsyncs/s
8.0.29:
1602 OS file reads, 43182 OS file writes, 24269 OS fsyncs
0.00 reads/s, 0 avg bytes/read, 158.70 writes/s, 47.10 fsyncs/s
Has anyone tackled this issue? Any suggestions are warmly welcomed.
Thanks,
Avgustin