Skip to content

MIN_OFFSET strategy is very slow #96

Description

@bazhenovc

Hi,

We were using the MIN_OFFSET strategy for allocating persistent GPU objects and noticed that it's approximately 120x slower than the default mode in release builds, I was wondering if there's any way to improve it?

Context: we have a GPU driven rendering system that needs to handle millions of small mesh instances that can be constantly loaded and unloaded, these instances are "handles" allocated out of a global buffer. We use a bitmask to track what is allocated and needs processing, the compute shader is then dispatched over the bitmask (64 threads, each thread checks 1 bit).

MIN_TIME is very fast, but it produces a ton of empty pages and causes very low GPU utilization at times, so it both requires some kind of indirection and extra complexity to reduce the memory usage, MIN_OFFSET is much easier in that regard.

For the time being I rolled out an ad-hoc "handle allocator" with a 2 level bitmask and a simple acceleration structure to circumvent the issue, but I'd rather not maintain it myself and rely on D3DMA support.

We still use MIN_TIME for all other GPU memory allocations, but would really benefit from MIN_OFFSET being faster.

Benchmark code: https://gist.github.com/bazhenovc/4b527b1912288184ca7f35c0aefb259a
My implementation: https://github.com/BobbyAnguelov/Esoterica/blob/main/Code/Base/Render/HandleAllocator.h
More docs / ramblings: https://github.com/BobbyAnguelov/Esoterica/blob/main/Docs/Rendering/HandleAllocator.md

Thanks a lot for the amazing library!

Debug results

HandleAllocator D3D12MA MIN_OFFSET D3D12MA MIN_TIME
Small allocs 1.07 ms 12.70 ms 0.30 ms
Large allocs 1.82 ms 5.30 ms 0.15 ms
Total 2.88 ms 17.99 ms 0.46 ms

Release results

HandleAllocator D3D12MA MIN_OFFSET D3D12MA MIN_TIME
Small allocs 0.41 ms 7.41 ms 0.06 ms
Large allocs 0.61 ms 3.76 ms 0.03 ms
Total 1.01 ms 11.16 ms 0.09 ms

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions