4 ms·
> Throughput reduction is predictable, and it's easy to plan for that — if your program runs 10% slower, bring up ~10% more servers; that's about it. But long G
by abalone 7y ago
> Throughput reduction is predictable, and it's easy to plan for that — if your program runs 10% slower, bring up ~10% more servers; that's about it. But long GC pauses are rapid and volatile; you can't "autoscale" out of them, so in order to not fall over, you must allot extra resources to handle them.
Exactly. Long tail latency is often a more important server metric than throughput.
This is why I’m excited about Swift on the server. Unlike most other languages it uses automatic reference counting instead of pause the world garbage collection. That means consistent latency.
- chrisseaton 7y agoHow does it collect cyclic data structures with consistent latency?
- mpweiher 7y agoWith programmer support and weak references.
- chrisseaton 7y agoWell it’s easy to make a GC with consistent latency if your attitude is ‘don’t collect things that need inconsistent latency to collect.’
- fpoling 7y agoWith a good architecture and right tools to detect cycles due to bugs the reference counting works even for complex applications. Essentially this is a trade off between development time versus headache at deployment.
- mpweiher 7y agoIt's not a GC (in the now common vernacular). Easy is good, particularly if it works well. Which it does. Also much more frugal with memory than typical tracing GCs.
- abalone 7y agoI doubt cyclical references are the only cause of inconsistent latency in mark and sweep.
- chrisseaton 7y agoThey aren’t in mark and sweep but they are in reference counting.
- ghusbands 7y agoThere exist runtimes that use reference counting and mark/sweep together. Mark/sweep is used to collect cycles that reference counting misses. PHP and Firefox's XPCOM both turn up in a google search for Cycle Collector. Maybe Swift will gain it, one day.
- chrisseaton 7y agoAll serious GCs end up being a combination of reference counting and tracing, given enough time.
- abalone 7y ago> Maybe Swift will gain it, one day. Maybe not. “We have discussed in the passed using hybrid approaches like introducing a cycle collector, which runs less frequently than a GC would. The problem with this is that if you introduce a cycle collector, code will start depending on it. In time you end up with some libraries/packages that works without GC, and others that leak without it (the D community has relevant experience here). As such, we have come to think that adding a cycle collector would be bad for the Swift community in the large.”[1] [1] https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160208/009422.html https://lists.swift.org/pipermail/swift-evolution/Week-of-Mo...
- ehaliewicz2 7y ago> That means consistent latency Does it? Based on my admittedly limited knowledge of refcounting, either freeing an object can take an non-predictable amount of time (decrementing the reference counters of all the objects pointed to by a freed object), or allocating new memory can take a non-predictable amount of time (by lazily deferring the above mentioned decrements until that memory is needed upon allocation).
- ghusbands 7y agoThe amount of effort required when a refcount reaches zero is unpredictable in general, yes, but at any particular site, the shape and lifetime of objects tend to follow a pattern. So if a particular bit of code drops a refcount to zero and takes a long time deallocating objects, it will with high probability always do so and is hence still fairly predictable/consistent.
- greglindahl 7y agoI've worked on a couple of million-line codebases that used reference counting. They were a joy, and their latency behavior was beautiful. These days my smallish async Python crawler runs for 24 hours and then starts having 5 second gc-related delays once every couple of minutes. Diagnostics says it's during gc of the longest-lived generation. Sucks to be me. I probably need to stop keeping my long-lived queues as Python objects.
- pjmlp 7y agoThere are plenty of reasons why reference counting keeps losing to tracing GC since the 70s. Swift is not doing any breakthrough to any of the variants that came before it.