Bug #72068 Suggestion to add a static mem heap type to reduce memory dynamic allocation
Submitted: 18 Mar 2014 12:46 Modified: 29 May 2015 11:50
Reporter: Fangxin Flou (OCA) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S4 (Feature request)
Version:All OS:Any
Assigned to: CPU Architecture:Any
Tags: Memory, performance

[18 Mar 2014 12:46] Fangxin Flou
Description:
I tracked the dynamic memory allocation for each type of statement, found that there is too many memory dynamic allocation and deallocation in the InnoDB layer due to the memory heap allocation. If I did not use tcmalloc or jemalloc, it caused serious performance issue.

How to repeat:
N/A

Suggested fix:
We could add a new mem heap type, I called it mem_heap_static, the first block is a buffer allocaed in the thread stack space, however the next block (if needed) will be treated as mem_heap_dynamic.
[18 Mar 2014 15:13] MySQL Verification Team
Verified as described.

Indeed, reducing dynamic allocations from heap can improve matters. However, this is not kind of change that is doable in a GA release.
[7 Apr 2014 13:53] Fangxin Flou
It's worthy for this change in latest 5.7.x release, since it's not released. Most of the dynamic heap allocation can be removed by the static heap type.
[7 Apr 2014 14:18] MySQL Verification Team
I fully agree.
[10 Apr 2014 15:40] Fangxin Flou
It's easy to find out which dynamic memory allocation could be removed immediated,  just add a trace to the memory allocation, print the file name and line no, shoud I find them out for select, insert, update, delete operation? 

There is no so many code need to be changed, and all the code changes are totally under control.
[29 May 2015 2:39] Sunny Bains
The idea is sound, but the effort required to change all invocations to use the new "stack" heap is too much. If you can provide a patch against 5.7 with the changes where you think this new heap type will help along with some numbers to back up the performance claims makes it easier to accept the patch.
[29 May 2015 11:50] Fangxin Flou
Hi:

Thanks for the reply, without tcmalloc or jemalloc, it does help a lot.

If we run mysql with tcmalloc or jemalloc, it does't help much.

So please ignore this patch now, if I have time I will test it again.

Thanks.