-
Notifications
You must be signed in to change notification settings - Fork 367
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
VmaBlockMetadata_Generic::FindAtOffest eats much cpu time when a large amout of object is freed #217
Comments
Thank you for reporting this issue. Regarding your first point: You are right. The parameter is now You are right that freeing allocations has O(n) time complexity due to traversal of the linked list of sub-allocations sorted by offset. This is an inefficiency that we are aware of and we will fix in the future. In the meantime, I recommend to allocate bigger buffers and sub-allocate parts of them e.g. using VMA's Virtual Allocator feature instead of creating many small buffers. |
With new commit 88510e9 we switched to the new TLSF algorithm, which is much faster and should not express bad performance when freeing large number of allocations. Can you please test it and see if it solves the problem? |
i have try the latest version, it solves the problem better than BUDDY algorithm ! and another question how to implement the following function using the new version of vma void vk_calculateMemoryUse(Renderer* pRenderer, uint64_t* usedBytes, uint64_t* totalAllocatedBytes)
{
assert(false);
// the following can no compile
/*VmaStats stats;
pRenderer->mVulkan.pVmaAllocator->CalculateStats(&stats);
*usedBytes = stats.total.usedBytes;
*totalAllocatedBytes = *usedBytes + stats.total.unusedBytes;*/
// then how to implement the equivalent of CalculateStats
//.......
} thank you for your efforts |
Thank you for checking this. I'm glad to hear that the new algorithm is fast and saves memory. Regarding the new statistics API, following should work: void vk_calculateMemoryUse(Renderer* pRenderer, uint64_t* usedBytes, uint64_t* totalAllocatedBytes)
{
VmaTotalStatistics stats;
pRenderer->mVulkan.pVmaAllocator->CalculateStatistics(&stats);
*usedBytes = stats.total.statistics.allocationBytes;
*totalAllocatedBytes = stats.total.statistics.blockBytes;
} However, please note that:
So I recommend to use I'm closing this ticket as the slowness of |
I just pushed a change to D3D12 Memory Allocator that switched to TLSF as the default algorithm. |
is 'false' should be VMA_POOL_CREATE_LINEAR_ALGORITHM_BIT according to the comment '// linearAlgorithm' ??
VulkanMemoryAllocator/include/vk_mem_alloc.h
Line 15109 in 7c48285
so: VmaBlockMetadata_Generic is used here, witch cause vmaDestoryBuffer very slow. see ConfettiFX/The-Forge#243
VulkanMemoryAllocator/include/vk_mem_alloc.h
Lines 11110 to 11118 in 7c48285
reason: the for loop of VmaBlockMetadata_Generic::FindAtOffest eats much cpu time
VulkanMemoryAllocator/include/vk_mem_alloc.h
Lines 6631 to 6645 in 7c48285
The text was updated successfully, but these errors were encountered: