Commit bce42eda by Shahbaz Youssefi

M92: Vulkan: Free DynamicBuffer buffers after dip in allocation size

In a pattern like this: - allocate 100 bytes - allocate 200 bytes - allocate 50 bytes - allocate 100000000 bytes - allocate 100 bytes - allocate 200 bytes - allocate 50 bytes The DynamicBuffer class switches to making 100MB allocations even if that allocation was a one-off. A small future allocation would then tie up 100MB in memory for future allocations. Another 100MB is also left tied up in the free list. With this change, if an allocation is made that's less than a quarter of the DynamicBuffer's current allocation size, it's taken as a sign that the previous large allocation was a one-off and the size is moved back to the DynamicBuffer's original initial size. Bug: b/187757166 Bug: chromium:1224952 Change-Id: Icb69bfa3196daa1ee8e6c38ef9513730f9afacfa Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2991915Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 6bbd095a
...@@ -2053,11 +2053,12 @@ angle::Result DynamicBuffer::allocateWithAlignment(ContextVk *contextVk, ...@@ -2053,11 +2053,12 @@ angle::Result DynamicBuffer::allocateWithAlignment(ContextVk *contextVk,
ASSERT(!mBuffer); ASSERT(!mBuffer);
} }
if (sizeToAllocate > mSize) const size_t sizeIgnoringHistory = std::max(mInitialSize, sizeToAllocate);
if (sizeToAllocate > mSize || sizeIgnoringHistory < mSize / 4)
{ {
mSize = std::max(mInitialSize, sizeToAllocate); mSize = sizeIgnoringHistory;
// Clear the free list since the free buffers are now too small. // Clear the free list since the free buffers are now either too small or too big.
ReleaseBufferListToRenderer(contextVk->getRenderer(), &mBufferFreeList); ReleaseBufferListToRenderer(contextVk->getRenderer(), &mBufferFreeList);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment