Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

A-Dunstan
Copy link
Contributor

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
Copy link
Contributor Author

A-Dunstan commented Jun 17, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants