4 ms·
In C++ with a thread-local allocator or a memory pool you can effectively skip the global allocator (or at least amortize it to 0). C++ gives you the tools to f
by snovv_crash 5y ago
In C++ with a thread-local allocator or a memory pool you can effectively skip the global allocator (or at least amortize it to 0). C++ gives you the tools to fix these kinds of bottlenecks if you need to, even if it is added complexity.
- moonchild 5y agoYes, and you can similarly preallocate memory in java (though you will be unable to do type punning). Java gets used in high-frequency trading which has very tight latency and overall performance requirements, to great effect.
- snovv_crash 5y agoWriting a pool in Java doesn't necessarily give you memory locality guarantees though, making you much more sensitive to cache:data size ratios. In Java you end up rewriting your algorithms as AoS instead of SoA just so that you can work with cache-aware layouts of primitives.