3 ms·
I'm skeptical that cpu usage is really the problem with multicore CPUs. I would think it is much more about concurrency. I'm also a bit surprised there isn't m
by BubRoss 7y ago
I'm skeptical that cpu usage is really the problem with multicore CPUs. I would think it is much more about concurrency.
I'm also a bit surprised there isn't more of a transition to modern C++ for problems where so much time is spent fighting the garbage collection. Ownership and memory management in C++11 and up really isn't a big deal. Keep your allocations to a minimum, make sure you are moving instead of copying. Shared pointers are there, but I actually never use them.
- weberc2 7y agoYou would have to spend an awful lot of time fighting garbage collection to make C++ worthwhile in an organization that isn't already well-versed in C++ development. The learning curve is massive, the builds are slow, the errors are terrible (although better than they once were), and the tooling fights you every step of the way (CMake still makes me shudder).
- shereadsthenews 7y agoEven if you use C++ you can still benefit from hardware allocator acceleration. Here's a paper on hardware acceleration of tcmalloc. http://www.samxi.org/papers/kanev_asplos2017.pdf http://www.samxi.org/papers/kanev_asplos2017.pdf
- mruts 7y agoIsn’t that the same with as C? You can use alloca to allocate on the stack, giving you the same benefit as RAII (I think?). I haven’t used C++ so maybe I’m speaking out of my ass though. But regardless, you could use the Boehm GC for objects you don’t feel like tracking the lifetime of.
- monocasa 7y agoRAII can help you protect heap memory (and other resources besides memory) because it's more about registering code to run on the end of object lifetimes rather than just the memory being deallocated. Alloca isnt really a great option for async flows for instance, to say nothing of file descriptors, or abstract concepts like 'the idea of this mutex being locked'. Alloca is also terrible for memory passed on to other threads obviously.. Albeit most of that is moot when compared to a GCed language like the global discussion.
- BubRoss 7y agoStack memory doesn't need to be managed regardless. With boehm gc you are going to run into the same problems of gc. RAII works well for lots of things - heap memory, mutex locks, reference counts, files, io, etc.
- nullwasamistake 7y agoThe new garbage collector on Java 12 is fine for almost every case. Hardly ever pauses more than a few milliseconds. Shenandoah looks promising as well. At least in Java land, within in the few years GC will be something you don't have to think about unless you need sub ms promise