C++11 memory accelerator. Simply add octane.cpp to your projects to increase performance of new/delete (array versions too). Standard memory manager considerations apply when using shared libraries. If the shared library deletes memory allocated by a call to new then it will also need octane.cpp otherwise octane will not work for you.
Status: Stable.
Version: 0.6
License: GPL v3
- MT-Safe
- Optimized for environments where threads are fighting for access to the memory manager.
- Can outperform the default memory manager by as much as 75% in testing.
- Tunable for your applications needs.
- Lock-free
- 16-byte aligned internally.
- Embedding octane in your dlls is difficult - missing source code, licensing conflicts, etc.
- Your app uses lots of threads - but not much heap allocation.
- Your app is single threaded - it probably won't benefit much.
- If you need a drop-in replacement for malloc this is not it.
With octane it is easy to construct classes on the heap with alignments of 32, 64 or even 128 bytes. First declare your class like:
class alignas(32) My32bytealignedClass : public ...
{
...
};
Then construct these classes aligned using new_aligned(Args...) defined in octane.hpp. Like:
My32bytealignedClass *ptr = new_aligned<My32bytealignedClass>(...);
The octane memory manager should be tuned to meet the needs of your application. This can be done by passing defines when compiling octane.cpp or by editing octane.hpp manually. The following defines are supported:
- Default pool size is 65400
- Larger pool sizes cause threads to hold more memory longer. If you find its holding too much memory consider lowering to 32700. It should not significantly impact performance.
- Maximum number of pools each thread will track.
- Default pool count is 256. Lower this value at your own risk.
- Number of bytes expressed as an integer
- Defaults to 128
- When pool pages become used up, they will be culled when their free space reaches this value.
- Tracks a few basic stats to make sure there are no leaks.
- To compile your application without octane.
With Octane:
g++ -O3 test.cpp --std=c++11 -pthread -o test
./test
My results were between 5300 ms and 6500 ms over several successive tests.
Without Octane:
g++ -O3 test.cpp --std=c++11 -pthread -o test -DOCTANE_DISABLE=1
./test
My results without octane were between 23700 ms and 35000 ms over several successive tests. The time spend resolving contentions varied widely but in no case did the result come close to what could be achieved using octane.
YMMV! Real world improvements will depend on how much time is being spent resolving thread contention in the memory manager.
- TODO: Add an API to allow threads to customize the memory manager attributes on a per thread basis.