hk: limit the number of free BOs in each cmd pool
hk: limit the number of free BOs in each cmd pool
Some clients like to have long living command pools, each one with multiple command buffers, and trigger bursts of BO allocations on them. This leads to the an ever increasing number of BOs allocated on each command pool, easily reaching over a couple thousand BOs per pool.
The visible effect is an ever increasing amount of VRAM consumption, which has been observed to easily get over 700MB for a workload consuming around 4GB of heap.
Here we limit the number of free BOs in each pool to 32. The rest are dereferenced when the command buffer is reset. In practice, with workloads triggering bursts of BO allocations on command buffers, those BOs aren't really released, keeping them in the BO cache and getting reused shortly after. This has the nice size effect of doing bookkeeping on the BO cache, trimming it up when needed.
With this change, the tested workloads present a significant reduction of VRAM, combined with an stabilization of BO allocations.