Re:Java garbage collection can be really slow
by CyberDildonics on Saturday April 23, 2016 @10:25AM
(#11555630)
> better than typical C++ because you avoid virtually all object allocation/deallocation costs that C++ has
So to have Java perform better than C++ you just have to avoid allocation in Java and leave it in in C++?
> If you want better I would not bother with C++ at all personally, but use C / assembly or even look at FPGA type setups.
There is nothing in C that gives it a speed advantage over C++. Basically you've discovered step 1 of 3 when optimizing software (step 0 is to profile) -
1. Minimize heap allocations
2. Rework memory access for cache locality
3. Use SIMD
1 and 2 can be done with C++. 3 really needs to be done with something like ISPC so that SIMD use isn't fragile and compiler dependent.
So to have Java perform better than C++ you just have to avoid allocation in Java and leave it in in C++?
> If you want better I would not bother with C++ at all personally, but use C / assembly or even look at FPGA type setups.
There is nothing in C that gives it a speed advantage over C++. Basically you've discovered step 1 of 3 when optimizing software (step 0 is to profile) -
1. Minimize heap allocations 2. Rework memory access for cache locality 3. Use SIMD
1 and 2 can be done with C++. 3 really needs to be done with something like ISPC so that SIMD use isn't fragile and compiler dependent.