-
Notifications
You must be signed in to change notification settings - Fork 108
metric for heap fragmentation #14
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
Comments
@rhempel have you looked at this? It has been in our umm code base for a while and is very useful. With little heap and libs like bearssl which require large allocs, it is rather common to hit out of memory due to fragmentation, and this metric, together with the largest free block, serve to detect the case. |
I have now looked at this and I am curious - I am not sure that I see this in the current esp8266 code repo? |
@rhempel I hope you had a very Merry Christmas! Our umm code is here: The fragmentation metric is here: The fragmentation metric together with max contiguous block and total free heap give a pretty good measure of the heap health. |
Thanks for the link to the metric - that was the missing piece. If we do integrate this would it be OK if I moved that code (with credit) into a function within umm_malloc()? I am a bit wary of the 16 bit limit on heap size - there are some pretty cool Cortex-M devices where a 128k or even 256k heap is practical 😀 |
No problem if you integrate that code ! |
I am integrating the metric this weekend but I am having trouble with this comment: |
Am I missing something? Is sum(hole-size) the correct comment, or should it be sum(blocks*block_size). |
A possible speed improvement is to simplify the summing of squares. We can just sum the squares of the number of free blocks in a free section, then the Euclidean norm simplifies to: Block size * sqrt( sum of squares of blocks) Saves two multiplications per free block plus all the math fits into uint32_t |
Whatever the size of the block is, we'd have
We (at esp8266/arduino) should remove the block size from the equation. Also what do you think of maintaining these values
changes to
We'd have |
Created PR UMM-14 |
Thanks for #22 ! Do you think it is worth having a look to what's proposed above as an optimization ? That would allow to not call the-also-expensive |
That’s the plan - but my normal mode of operation is to implement the easy part along with test cases and then do the continuous calculation and use the same test case 😏 |
You may find some interest in esp8266/Arduino#5090 .
This could be useful to test the efficiency of
realloc()
.The text was updated successfully, but these errors were encountered: