I have MariaDB 10.5 on my desktop with multiple disks (SSD and HDD) for write-intensive projects. Writing to a single table is fast and the percentage of dirty pages remains close to zero with 1000-3000 writes/s
.
However, when I actively write to multiple tables at the same time, the percentage of dirty pages quickly goes up. The problem is that flush to the disk drops to the level of 100 writes/s
and remains at that level.
This behaviour remains until a restart.
I think the problem is somehow related (not exactly) to that identified by Percona 10 years ago.
Is there any trick to keep the speed of flushing?
key_buffer_size = 20M
max_allowed_packet = 5G
thread_stack = 256K
thread_cache_size = 8
innodb_buffer_pool_size = 70G
innodb_log_buffer_size = 512M
innodb_log_file_size = 20G
innodb_thread_concurrency = 0
innodb_flush_log_at_trx_commit = 0
innodb_compression_level = 6
innodb_io_capacity=2000
innodb_io_capacity_max=30000
innodb_max_dirty_pages_pct=0
innodb_doublewrite = 0
innodb_flush_method = O_DIRECT
innodb_lru_scan_depth=128
innodb_purge_threads=8
innodb_purge_batch_size=600
innodb_flush_neighbors=0
innodb_change_buffer_max_size=50
innodb_buffer_pool_load_at_startup=OFF
innodb_buffer_pool_dump_at_shutdown=OFF
innodb-ft-result-cache-limit=4G
innodb_fatal_semaphore_wait_threshold=7200
innodb_compression_default=ON
innodb_random_read_ahead=1
UPDATE: Possible Solution
I do not post this, as I am not sure if it is the real solution. After much experimentations, I found the problem is adaptive flushing. I tackled the problem by
innodb_adaptive_flushing=0
innodb_adaptive_flushing_lwm=70
Apparently, when adaptive flushing is triggered to avoid high I/O, it stays for a long time.
UPDATE2: page vs column compression
I identified the problem to be
innodb_compression_default=ON
Following a suggestion by Rick James, I created similar tables with column compression instead of page compression. The compression is about 300% for both methods (10-20% better with page compression, as applies to the whole table rather than selective columns), but the performance was significantly different on HDD.
I think the problem is when writing to multiple sparse files created by page compression at the same time on an HDD (it should not be an issue on SSD).
I need to recreate all the tables to be sure, and the process is painfully time-consuming.