3 ms·
So this is a lot of gibberish but let me sum up to you the RC vs. GC: GC advantages: * Scales better when done right - cheap allocations simplified code etc.
by invalidname 4y ago
So this is a lot of gibberish but let me sum up to you the RC vs. GC:
GC advantages:
* Scales better when done right - cheap allocations simplified code etc.
* Can be heavily concurrent and use multicore
RC advantages:
* Predictable performance
* Uses less RAM
For GUI RCs smaller memory footprint and predictable performance are great. Hence swift uses ARC which is also faster than most RC implementations (which typically have a lot of overhead).
For servers where overall performance matters more than 100% smooth consistency and RAM is cheaper... GCs have some advantages. A GC can run on idle and clean a huge amount of garbage without a problem. It can do so concurrently and leverage the multicore nature of modern CPUs.
This is one of those, right tool for the right case.
- jandrewrogers 4y ago> For servers where overall performance matters more than 100% smooth consistency and RAM is cheaper... GCs have some advantages. I am having a difficult time parsing this in a way that makes sense. Generally speaking, overall performance on servers is a direct product of being able to take strict control of when things happen and minimizing RAM footprint. That "smooth consistency" is how performance happens because there are important classes of software optimization that don't work if this is not a property of your runtime. Similarly, high-performance server architectures are usually not heavily concurrent even on massively multicore systems for good reasons that a GC doesn't address. The only advantage a GC has in this context that I can think of is that it might reduce some types of bugs in some types of code.
- invalidname 4y agoI come from the world of JVM so here we do have multicore servers and you might see a peek where a particular request takes longer but overall the performance will be amazing. This isn't OK for GUI but is great if you have a HUGE server that can chug through tons of data with a huge amount of RAM/cache.
- panick21_ 4y agoBut this problem has technically mostly been fixed by Azul and is making its way into open as well, we have ZGC and so on now. Pauses are rather short even with large heaps.
- jandrewrogers 4y agoI used to write a lot of performance-optimized server code in Java. Even with heroic effort, it is difficult to make the JVM perform even half as fast as not-that-optimized C or C++ -- other languages I wrote the same kinds of code in. And highly optimized C++ is many times higher throughput than the JVM equivalent on the same hardware, pretty much always. The reasons why are well-understood technically. This cannot be blamed entirely on the GC. The JVM makes many other choices which make optimization difficult, and its original theories about what is important for optimization haven't stood up over time. It was not designed to be performant, just good enough for most applications that are not that performance sensitive. Programming languages often have many objectives and priorities aside performance. I use Python quite a lot and it is usually much slower than the JVM.
- invalidname 4y agoWhen you say "used" how long ago are you talking about and for what types of loads? I saw Java rewrites running circles around C++ code it replaced. It's a matter of tuning and picking the right configurations/tasks. Some things Java does really well, others it sucks at. If you need near memory access and have constant loops over arrays of objects then Java will be slower than that when compared to C++ because of the memory layout (Valhalla will improve that). Network throughput is another weak point which amazingly NodeJS does better. Loom resolves that problem. There's also a lot of choices when it comes to GCs nowadays. Java used to be a dog on large memory heaps. This is no longer the case with Z, G1 etc. but it's very possible you hit a problematic spot. One of the nice things about GC performance is that you can connect a monitoring tool to a production server and optimize memory performance by viewing actual usage. Monitoring and observability in Java is at another level entirely.
- 4y ago
- KerrAvon 4y agoDon’t know why you’re getting downvoted, you are completely correct. I will add that optimizing for memory usage is hugely important to system performance on Apple’s devices. I do wonder about the idea that it isn’t universally important; all computers are RAM/cache constrained except maybe HPC equipment.
- erik_seaberg 4y agoComputers are constrained in bus bandwidth as well, and it’s harder to add more. RC tends to require strongly consistent counter bumps on the bus even for objects whose exact lifetimes you might not care about so much. The costs of GC are amortized over more work, though the pauses can hurt.