Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a direct port of the umm_malloc a version of malloc meant for embedded systems. By having a proper free list, we are able to track allocations much faster and avoid the performance bottlenecks that come from scanning bitset.
On top of that, this allocator will allocate to the space of best fit instead of the first location with enough space (this reduces fragmentation and memory pressure). Lastly, the allocator has a proper realloc algorithm that avoids a lot of problems with the naive implemention of malloc, copy, free. Overall, it should be a large perf and memory usage win.
It does add 4 bytes of overhead to each allocation. The old allocator had 1 bit of overhead for every 8 bytes allocated. So there is definitely more overhead. That said, the fragmentation and perf gains outweigh the costs in my opinion. Also, for wasm4, really only lists and large strings are allocated. Those tend to be large enough to pay for the overhead.