Skip to content

anv: Improve the performance of vkResetDescriptorPool

In Bug 110497, the reporter not only claimed that Project CARS 2 started crashing but also that performance had recently gone down the drain. Doing a bit of poking about with perf, I found the culpret: vkResetDescriptorPool. Prior to enabling descriptor buffers, vkResetDescriptorPool didn't do anything all that interesting so it never showed up in perf traces. However, now that it's calling util_vma_heap_free(), it's doing some potentially expensive stuff on a hot-path. This MR fixes these performance issues in a three-step process:

  1. Make util_vma_heap_free() substantially cheaper by storing a red-black tree of holes
  2. Make all of util_vma_heap faster by recycling holes instead of calling calloc() and free() constantly.
  3. Make vkResetDescriptorPool() even faster by avoiding full per-set tear-down.

I have no perf numbers for the second one so if people think it makes util_vma_heap to complex for no reason, we can drop it. However, it is now on a hot path in Vulkan, so avoiding unnecessary alloc/free might be a good thing. One could argue that the third makes the first unnecessary and, while that may be free in the case of this one app, I don't think it's true in general and util_vma_heap_free() is likely to show up in perf traces somewhere anyway given how expensive it was.

Perf on master:

cars2-master.svg

Perf with util_vma_heap improvements:

cars2-fixes.svg

Perf with vkResetDescriptorPool() improvements:

cars2-anv-fixes.svg

Merge request reports

Loading