They're comparing to an in-order CPU. Given that most CPUs are out-of-order (at least of the non-embedded variety, and GC is less used in such applications anyway), it would be better and more intellectually honest to actually compare to a typical CPU that performs GC. They kind of address this in the paper but only in a short aside: "Note that previous research [1] showed that out-of-order CPUs, while moderately fas…
For Better Computing, Liberate CPUs from Garbage Collection
391–400 of 460 posts
Re: For Better Computing, Liberate CPUs from Garbage Collection
#392Hasn't Rust basically solved that problem? But yeah, legacy stuff could profit from this.
Re: For Better Computing, Liberate CPUs from Garbage Collection
#393Objective-C ARC (automatic reference counting) solved the problem neatly for my iOS apps. Is there some overhead? Maybe, but it's neatly spread out through the entire application life time, so there is rarely[1] a UI-freezing stutter associated with GC. To reduce the overhead I turned off thread-safety and simply never access the same objects from more than one thread (object has to be "handed off" first if it comes…
ARC is just garbage collection that doesn't always work (circular references).
Re: For Better Computing, Liberate CPUs from Garbage Collection
#394IMO garbage collection is the epitome of sunk cost fallacy. Thirty years of good research thrown at a bad idea. The reality is we as developers choose not to give languages enough context to accurately infer the lifetime of objects. Instead of doing so we develop borderline self-aware programs to guess when we're done with objects. It wastes time, it wastes space, it wastes energy. If we'd spent that time developing…
What about Swift? Automatic Reference Counting avoids the typical problems of mark and sweep garbage collection. Has its own trade offs of course but the benefits include more consistent latency, efficient memory usage and cache friendliness. Like Rust it uses a smarter compiler (LLVM).
Really interesting stuff happing on the server side of Swift right now. It’s early days but I’d keep a close eye on it. Long tail latency is a big big server problem.
Re: For Better Computing, Liberate CPUs from Garbage Collection
#395Earlier quoted context omitted.
Almost but not quite. Clang has very special rules around ARC that allow it to perform additional optimizations that would otherwise be illegal [1]. [1] https://clang.llvm.org/docs/AutomaticReferenceCounting.html#...
That just lets it release earlier, not retain/release less often. ARC can't do anything magic here vs. something like really careful use of std::move & const references.
Re: For Better Computing, Liberate CPUs from Garbage Collection
#396Earlier quoted context omitted.
>retain & release are thread-safe That's optional tho, and I never use it that way.
Do you have a link to what you're referring to? Apple's docs clearly state retain/release are thread safe. Are you using your own implementation of retain & release or something?
@property (strong, nonatomic) UIView* unselectedTabsView;
"nonatomic" means avoid synchronization code. This code is not thread safe for that reason, but I never do cross-thread access anyways.Re: For Better Computing, Liberate CPUs from Garbage Collection
#397Earlier quoted context omitted.
doesn’t seem cool to admire Apple technologies, but ARC seems to work amazingly well with zero CPU overhead
It’s not zero — those -retain and -release calls still exist when necessary and have a small penalty — but it does minimize them well, and is lower overhead and vastly more predictable than GC.
Re: For Better Computing, Liberate CPUs from Garbage Collection
#398Objective-C ARC (automatic reference counting) solved the problem neatly for my iOS apps. Is there some overhead? Maybe, but it's neatly spread out through the entire application life time, so there is rarely[1] a UI-freezing stutter associated with GC. To reduce the overhead I turned off thread-safety and simply never access the same objects from more than one thread (object has to be "handed off" first if it comes…
> I do make an occasional slip, which is where I need to rely on Instruments, and I do wish I had better tools than that, something more automatic that would catch me in the act. Xcode's debug toolbar has a "debug memory graph" button that will visualize the object graph for your entire program. Reference cycles are automatically detected and listed in the issue navigator. https://developer.apple.com/library/archive/…
Re: For Better Computing, Liberate CPUs from Garbage Collection
#399Earlier quoted context omitted.
I don't see your point. Of course sometimes the lifetime of an object is not tied to code scope but actually to something dynamic. Let's say for instance when you close a tab in your browser you expect the resources to be freed (ignoring caching to simplify the argument). Clearly somewhere in your code you have to explicitly handle tab closing and break the references to allow the GC to do its job. Why not free the r…
> Why not free the resources here while you're at it? Because you do not have an exclusive reference to all of them; we could be freeing something that is still in use somewhere. So why not reference-count? Because reference counting is slow, and must be meticulously maintained (here, languages help with constructs like smart pointers), and doesn't handle cycles in the object structure. > I find RAII a lot easier to…
If an object with a smart pointer goes out of scope, then of course there's the overhead of the smart pointer, but the previous comment wasn't referring to that situation
Re: For Better Computing, Liberate CPUs from Garbage Collection
#400Earlier quoted context omitted.
Do you have a link to what you're referring to? Apple's docs clearly state retain/release are thread safe. Are you using your own implementation of retain & release or something?
For sure. It's entirely stock: @property (strong, nonatomic) UIView* unselectedTabsView; "nonatomic" means avoid synchronization code. This code is not thread safe for that reason, but I never do cross-thread access anyways.