Swap meta allocators with much more reserve. #202
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 the core of the meta allocator swapping change: swap a little bit earlier, but always swap only when _freed is much larger than _avail.
From my observations I can see that without this change, both allocators bleed slowly to empty without either of them regaining enough over time to continue work. In effect, we never recover from ENOSPC. Everything grinds to a halt, the allocators just swap endlessly and transactions take forever to complete.
With this change we avoid all that - we purposely let our _avail allocator go much lower than _freed before we swap. This assures that whenever we swap we let enough blocks recycle post transactions into _freed so that it gets us out of ENOSPC again, and into a healthy state again.
I think.