vulkan-renderer icon indicating copy to clipboard operation
vulkan-renderer copied to clipboard

Implement an allocator for cube nodes

Open IAmNotHanni opened this issue 2 years ago • 1 comments

Is your feature request related to a problem?

Allocating large amounts of cube nodes can take some time. In addition, we just throw them away by calling the destructor of the cube nodes. It would be much better to allocate a large amount of cube nodes ahead, and to have some sort of request system when we need new cube nodes. When no longer needed, the nodes can be "given back" to the allocator, instead of calling the destructor. Given the fact we want to have multiple octrees (cube root nodes), we should aim for one allocator for all the worlds.

Description

Here is some more info about allocators:

https://www.youtube.com/watch?v=nZNd5FjSquk https://www.youtube.com/watch?v=CFzuFNSpycI https://www.youtube.com/watch?v=l14Zkx5OXr4 https://www.youtube.com/watch?v=Ctfbs6UVJ9Y

Lucky for us, we could use the new C++ features for writing the allocator:

https://badlydrawnrod.github.io/posts/2021/12/30/monotonic_buffer_resource/

Alternatives

Do not use an allocator, but accept the fact we will probably be dealing with a lot of memory in an unoptimized way in the future.

Affected Code

The octree code

Operating System

All operating systems

Additional Context

None

IAmNotHanni avatar Dec 05 '22 18:12 IAmNotHanni

A book by John Lakos called "C++ Allocators for the Working Programmer" will be released this year. This will help us a lot.

IAmNotHanni avatar May 11 '23 09:05 IAmNotHanni