Hi, Monty, On Dec 21, Michael Widenius wrote:
revision-id: 6c5c1d0bf00 (mariadb-10.6.20-57-g6c5c1d0bf00) parent(s): 671f80c7388 author: Michael Widenius committer: Michael Widenius timestamp: 2024-12-17 10:45:25 +0200 message:
MDEV-35469 Heap tables are calling mallocs to often
Heap tables are allocated blocks to store rows according to my_default_record_cache (mapped to the server global variable read_buffer_size). This causes performance issues when the record length is big (> 1000 bytes) and the my_default_record_cache is small.
Changed to instead split the default heap allocation to 1/16 of the allowed space and not use my_default_record_cache anymore when creating the heap. The allocation is also aligned to be just under a power of 2.
For some test that I have been running, which was using record length=633, the speed of the query doubled thanks to this change.
Other things: - Fixed calculation of max_records passed to hp_create() to take into account padding between records.
diff --git a/storage/heap/hp_create.c b/storage/heap/hp_create.c index c07a1e968c4..fcfcf607822 100644 --- a/storage/heap/hp_create.c +++ b/storage/heap/hp_create.c ... + of the block. + */ + records_in_block= + (my_round_up_to_next_power((uint32) + (records_in_block * recbuffer + + sizeof(HP_PTRS) + MALLOC_OVERHEAD)/2) / + recbuffer);
Strictly speaking, it should be (my_round_up_to_next_power(records_in_block * recbuffer + extra) - extra ) / recbuffer And why /2 ? Regards, Sergei Chief Architect, MariaDB Server and security@mariadb.org