Commit 3392278c authored by Sergey Vojtovich's avatar Sergey Vojtovich

MDEV-7004 - Merge scalability fixes from 10.0-power

Preallocate dynamic array and bitmap on mem_root to avoid expensive malloc.
This reduces number of allocations from 39 to 31 per OLTP RO transaction.
parent eaa8c154
...@@ -1839,8 +1839,6 @@ QUICK_RANGE_SELECT::QUICK_RANGE_SELECT(THD *thd, TABLE *table, uint key_nr, ...@@ -1839,8 +1839,6 @@ QUICK_RANGE_SELECT::QUICK_RANGE_SELECT(THD *thd, TABLE *table, uint key_nr,
index= key_nr; index= key_nr;
head= table; head= table;
key_part_info= head->key_info[index].key_part; key_part_info= head->key_info[index].key_part;
my_init_dynamic_array(&ranges, sizeof(QUICK_RANGE*), 16, 16,
MYF(MY_THREAD_SPECIFIC));
/* 'thd' is not accessible in QUICK_RANGE_SELECT::reset(). */ /* 'thd' is not accessible in QUICK_RANGE_SELECT::reset(). */
mrr_buf_size= thd->variables.mrr_buff_size; mrr_buf_size= thd->variables.mrr_buff_size;
...@@ -1858,9 +1856,12 @@ QUICK_RANGE_SELECT::QUICK_RANGE_SELECT(THD *thd, TABLE *table, uint key_nr, ...@@ -1858,9 +1856,12 @@ QUICK_RANGE_SELECT::QUICK_RANGE_SELECT(THD *thd, TABLE *table, uint key_nr,
file= head->file; file= head->file;
record= head->record[0]; record= head->record[0];
/* Allocate a bitmap for used columns (Q: why not on MEM_ROOT?) */ my_init_dynamic_array2(&ranges, sizeof(QUICK_RANGE*),
if (!(bitmap= (my_bitmap_map*) my_malloc(head->s->column_bitmap_size, thd->alloc(sizeof(QUICK_RANGE*) * 16), 16, 16,
MYF(MY_WME | MY_THREAD_SPECIFIC)))) MYF(MY_THREAD_SPECIFIC));
/* Allocate a bitmap for used columns */
if (!(bitmap= (my_bitmap_map*) thd->alloc(head->s->column_bitmap_size)))
{ {
column_bitmap.bitmap= 0; column_bitmap.bitmap= 0;
*create_error= 1; *create_error= 1;
...@@ -1924,7 +1925,6 @@ QUICK_RANGE_SELECT::~QUICK_RANGE_SELECT() ...@@ -1924,7 +1925,6 @@ QUICK_RANGE_SELECT::~QUICK_RANGE_SELECT()
} }
delete_dynamic(&ranges); /* ranges are allocated in alloc */ delete_dynamic(&ranges); /* ranges are allocated in alloc */
free_root(&alloc,MYF(0)); free_root(&alloc,MYF(0));
my_free(column_bitmap.bitmap);
} }
my_free(mrr_buf_desc); my_free(mrr_buf_desc);
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment