• Michael Widenius's avatar
    MDEV-4011 Added per thread memory counting and usage · a260b155
    Michael Widenius authored
    Base code and idea from a patch from by plinux at Taobao.
    
    The idea is that we mark all memory that are thread specific with MY_THREAD_SPECIFIC.
    Memory counting is done per thread in the my_malloc_size_cb_func callback function from my_malloc().
    There are plenty of new asserts to ensure that for a debug server the counting is correct.
    
    Information_schema.processlist gets two new columns: MEMORY_USED and EXAMINED_ROWS.
    - The later is there mainly to show how query is progressing.
    
    The following changes in interfaces was needed to get this to work:
    - init_alloc_root() amd init_sql_alloc() has extra option so that one can mark memory with MY_THREAD_SPECIFIC
    - One now have to use alloc_root_set_min_malloc() to set min memory to be allocated by alloc_root()
    - my_init_dynamic_array()  has extra option so that one can mark memory with MY_THREAD_SPECIFIC
    - my_net_init() has extra option so that one can mark memory with MY_THREAD_SPECIFIC
    - Added flag for hash_in...
    a260b155
events.cc 32.6 KB