Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mrs_realloc: avoid copies when space is available
When the passed pointer is valid and already has enough space, return it unless it's at least twice the requested size. Some software uses realloc to extend allocations by small, fixed amounts. In a naive implementation of realloc that blindly performs a new allocation, copies the data, and then frees the old allocation this is O(n^2). For small values of `n` this isn't too noticable, but asymptotically it's quite bad and revocation makes it much worse. With current mrs tuning, we eventually reach a point where approximately every 4th increment triggers a revocation pass. We can make this somewhat less visible (or fix it entirely for snmalloc with it's power-of-two sized buckets) by omitting unnecessary allocations and copies.
- Loading branch information