cores icon indicating copy to clipboard operation
cores copied to clipboard

don't set do_zero flag when initializing extmem heap (improve performance when allocating)

Open A-Dunstan opened this issue 1 year ago • 1 comments

Currently when the extmem_smalloc_pool is created, the do_zero flag is set which causes smalloc to always zero out allocated memory. This reduces allocation performance since it's only required by calls to calloc, not malloc.

This patch unsets the do_zero flag, manually clears any statically allocated EXTMEM memory (which wasn't being done before in violation of C spec - uninitialized static data should be zeroed) and makes extmem_calloc() call sm_calloc_pool() instead of sm_malloc_pool().

A-Dunstan avatar Jan 18 '24 00:01 A-Dunstan

Updated the patch; with do_zero==false smalloc only clears smalloc_hdr contents when memory is free'd. This makes allocations persist across reboots unless the pool is cleared at startup. So the entire extmem must be zeroed, not just the static allocations between _extram_start and _extram_end.

A-Dunstan avatar Jun 17 '24 01:06 A-Dunstan