If you plan on having a large visual range, you are basically stuck with 2 options:
#1: Geo Clipmaps
#2: Geo Mipmaps
Geo Clipmaps provides the best performance but Geo Mipmaps is easier to implement. Plenty of information is available online about these systems.
My own engine is intended to be easy to use by a large audience, so my memory managers have to take a performance hit in order to serve all usage cases.
On the other hand, our work engine memory manager is about 6 times faster than my personal memory manager because it is used only in-house, and thus we can be more strict on how it is used.
Our in-house memory manager forces people to be more conscientious about how they allocate memory, and the blatant fact is that this is the way it should be. A huge amount of performance can be gained by simply planning your allocations better.
Your major hiccup here is apparently in your allocation system. You didn’t explain why you need to allocate in this manner, but generally a bit of planning with a mixture of allocation options helps to eliminate this type of overhead.
I will assume that you do not want to remake an entire allocation system that fully replaces malloc() and free(), so my following points are about alternative allocation methods that are easy to implement and yet heavily out-perform malloc() and free().
#1: Stack allocators. These have no ability to “realloc()”, so if you want to use these you have to know how much memory you need before you allocate. Luckily this is often easy to discover. Many routines can be rewritten as a 2-pass routine, 1 pass to determine how much memory to allocate and a 2nd pass to actually fill in the values for that memory. 2 passes may seem like overhead, but in practice it is usually over 50 times faster than using standard realloc() and malloc(), partially because the cost of free() is entirely eliminated. When objects created on a stack allocator disappear, their distructors are called but any memory they allocated on that same stack allocator is not freed.
To put this into practical-use perspective, this reduced model loading times in some situations from 13 seconds to 0 seconds in my own engine.
#2: Trashable heaps. These are the same as above except that only free() is optimized away. malloc() and realloc() are valid options and the heap is resizable (unlike with stack allocators), but all of the allocations made on that heap are freed in one call. Again, destructors of objects are called, but nothing is actually freed from the heap. After all the objects are destructed, the memory for the heap is cleared in an instant, and this again can save you literally seconds of free() calls in places where you called malloc() many times. Note that this can also apply to new and delete.
With more allocation systems in place you have more options when allocating, and as my office engine proves this can be a significant asset in your allocation speed even if you are just using standard malloc() and free().
With more allocation systems, you have even more options, all of which can gain you huge amounts of savings in performance when used with proper planning and care.
L. Spiro
Show differencesHistory of post edits
#1L. Spiro
Posted 18 July 2012 - 07:35 AM
If you plan on having a large visual range, you are basically stuck with 2 options:
#1: Geo Clipmaps
#2: Geo Mipmaps
Geo Clipmaps provides the best performance but Geo Mipmaps is easier to implement. Plenty of information is available online about these systems.
My own engine is intended to be easy to use by a large audience, so my memory managers have to take a performance hit in order to serve all usage cases.
On the other hand, our work engine memory manager is about 6 times faster than my personal memory manager because it is used only in-house, and thus we can be more strict on how it is used.
Our in-house memory manager forces people to be more conscientious about how they allocate memory, and the blatant fact is that this is the way it should be. A huge amount of performance can be gained by simply planning your allocations better.
Your major hiccup here is apparently in your allocation system. You didn’t explain why you need to allocate in this manner, but generally a bit of planning with a mixture of allocation options helps to eliminate this type of overhead.
I will assume that you do not want to remake an entire allocation system that fully replaces malloc() and free(), so my following points are about alternative allocation methods that are easy to implement and yet heavily out-perform mallo() and free().
#1: Stack allocators. These have no ability to “realloc()”, so if you want to use these you have to know how much memory you need before you allocate. Luckily this is often easy to discover. Many routines can be rewritten as a 2-pass routine, 1 pass to determine how much memory to allocate and a 2nd pass to actually fill in the values for that memory. 2 passes may seem like overhead, but in practice it is usually over 50 times faster than using standard realloc() and malloc(), partially because the cost of free() is entirely eliminated. When objects created on a stack allocator disappear, their distructors are called but any memory they allocated on that same stack allocator is not freed.
To put this into practical-use perspective, this reduced model loading times in some situations from 13 seconds to 0 seconds in my own engine.
#2: Trashable heaps. These are the same as above except that only free() is optimized away. malloc() and realloc() are valid options and the heap is resizable (unlike with stack allocators), but all of the allocations made on that heap are freed in one call. Again, destructors of objects are called, but nothing is actually freed from the heap. After all the objects are destructed, the memory for the heap is cleared in an instant, and this again can save you literally seconds of free() calls in places where you called malloc() many times. Note that this can also apply to new and delete.
With more allocation systems in place you have more options when allocating, and as my office engine proves this can be a significant asset in your allocation speed even if you are just using standard malloc() and free().
With more allocation systems, you have even more options, all of which can gain you huge amounts of savings in performance when used with proper planning and care.
L. Spiro
#1: Geo Clipmaps
#2: Geo Mipmaps
Geo Clipmaps provides the best performance but Geo Mipmaps is easier to implement. Plenty of information is available online about these systems.
My own engine is intended to be easy to use by a large audience, so my memory managers have to take a performance hit in order to serve all usage cases.
On the other hand, our work engine memory manager is about 6 times faster than my personal memory manager because it is used only in-house, and thus we can be more strict on how it is used.
Our in-house memory manager forces people to be more conscientious about how they allocate memory, and the blatant fact is that this is the way it should be. A huge amount of performance can be gained by simply planning your allocations better.
Your major hiccup here is apparently in your allocation system. You didn’t explain why you need to allocate in this manner, but generally a bit of planning with a mixture of allocation options helps to eliminate this type of overhead.
I will assume that you do not want to remake an entire allocation system that fully replaces malloc() and free(), so my following points are about alternative allocation methods that are easy to implement and yet heavily out-perform mallo() and free().
#1: Stack allocators. These have no ability to “realloc()”, so if you want to use these you have to know how much memory you need before you allocate. Luckily this is often easy to discover. Many routines can be rewritten as a 2-pass routine, 1 pass to determine how much memory to allocate and a 2nd pass to actually fill in the values for that memory. 2 passes may seem like overhead, but in practice it is usually over 50 times faster than using standard realloc() and malloc(), partially because the cost of free() is entirely eliminated. When objects created on a stack allocator disappear, their distructors are called but any memory they allocated on that same stack allocator is not freed.
To put this into practical-use perspective, this reduced model loading times in some situations from 13 seconds to 0 seconds in my own engine.
#2: Trashable heaps. These are the same as above except that only free() is optimized away. malloc() and realloc() are valid options and the heap is resizable (unlike with stack allocators), but all of the allocations made on that heap are freed in one call. Again, destructors of objects are called, but nothing is actually freed from the heap. After all the objects are destructed, the memory for the heap is cleared in an instant, and this again can save you literally seconds of free() calls in places where you called malloc() many times. Note that this can also apply to new and delete.
With more allocation systems in place you have more options when allocating, and as my office engine proves this can be a significant asset in your allocation speed even if you are just using standard malloc() and free().
With more allocation systems, you have even more options, all of which can gain you huge amounts of savings in performance when used with proper planning and care.
L. Spiro