-
Notifications
You must be signed in to change notification settings - Fork 56
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
Add reserved_bytes method for Allocator #266
Conversation
Thanks for the contribution, please don't forget to sign the commits. What's the intended use-case for this, and would it be OK to chose another name so it doesn't conflict with the Dx12 feature of reserved memory ( |
On 24.02.2025 05:39, Jasper Bekkers wrote:
Jasper-Bekkers left a comment (Traverse-Research/gpu-allocator#266)
Thanks for the contribution, please don't forget to sign the commits.
Sure, I'll figure this out shortly.
What's the intended use-case for this
In my application, (large 3D volume visualization/processing), I
basically expect to use the whole VRAM, however (at least Linux with
mesa vulkan drivers) the OS does not seem to report OOM when I just keep
allocating. I suspect that part of VRAM is swapped to RAM because
everything becomes very slow in that case.
My workaround so far has been to count the allocated memory on every
alloc/dealloc and clean up some of the allocations when I hit a
user-specified limit (e.g. 80% of physical VRAM). The problem is that
due to fragmentation this count is below the actual memory requested by
the allocator which results in sometimes causing swapping again if the
limit is not chosen very conservatively.
I tried to use the property `total_reserved_bytes` of `AllocatorReport`,
which works in principle, but is relatively slow to call due to the
detailed information collected about all subblocks which I'm not even
interested in, in this case.
Hence I moved this functionality of `generate_report` into a separate
function.
and would it be OK to chose another name so it doesn't conflict with
the Dx12 feature of reserved memory (`CreateReservedResource`)?
Sure! Do you have a preference? I picked this name due to the similar
name of the property of `AllocatorReport` and was not aware of the Dx12
feature.
Maybe `total_memory_block_size`?
|
How about picking the
Ouch, maybe we should update that as well in-line with this choice. |
Capacity would be the proper name here indeed. We should also update the reporting api in that case. |
The use of "reserved" may be confused with the concept of reserved memory in Dx12. Capacity is in line with the similar concept from (e.g.) std::vec::Vec.
This fills the use case where one needs the total capacity given by the sum of sizes of all device-allocated memory blocks, but compiling a complete report (in particular due to the calls to report_allocations from the SubAllocator) would be too costly.
b4111d5
to
c409c85
Compare
Alright, I've added a commit to change AllocatorReport, changed the name of the added method and signed the commits. |
This fills the use case where one needs the total number of reserved bytes from an Allocator, but compiling a complete report (in particular due to the calls to report_allocations from the SubAllocator) would be too costly.
I've encountered this in a (not yet open) project of mine and would be happy if you would accept this contribution. My workaround of just counting the allocation size myself underestimates the total allocated memory due to fragmentation.