Skip to content

Commit

Permalink
MDEV-7004 - Merge scalability fixes from 10.0-power
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Sergey Vojtovich committed Dec 5, 2014
1 parent eaa8c15 commit 3392278
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions sql/opt_range.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1839,8 +1839,6 @@ QUICK_RANGE_SELECT::QUICK_RANGE_SELECT(THD *thd, TABLE *table, uint key_nr,
index= key_nr;
head= table;
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(). */
mrr_buf_size= thd->variables.mrr_buff_size;
Expand All @@ -1858,9 +1856,12 @@ QUICK_RANGE_SELECT::QUICK_RANGE_SELECT(THD *thd, TABLE *table, uint key_nr,
file= head->file;
record= head->record[0];

/* Allocate a bitmap for used columns (Q: why not on MEM_ROOT?) */
if (!(bitmap= (my_bitmap_map*) my_malloc(head->s->column_bitmap_size,
MYF(MY_WME | MY_THREAD_SPECIFIC))))
my_init_dynamic_array2(&ranges, sizeof(QUICK_RANGE*),
thd->alloc(sizeof(QUICK_RANGE*) * 16), 16, 16,
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;
*create_error= 1;
Expand Down Expand Up @@ -1924,7 +1925,6 @@ QUICK_RANGE_SELECT::~QUICK_RANGE_SELECT()
}
delete_dynamic(&ranges); /* ranges are allocated in alloc */
free_root(&alloc,MYF(0));
my_free(column_bitmap.bitmap);
}
my_free(mrr_buf_desc);
DBUG_VOID_RETURN;
Expand Down

0 comments on commit 3392278

Please sign in to comment.