News for hackers. Stuff that matters.
Re:Erlang Garbage Collector by weberc2 on Thursday November 30, 2017 @06:33PM (#15820650)
How valuable is the property that other threads' GCs won't stop your thread if your thread bears its own full stop? It seems like a concurrent collector with a very small STW phase would be preferable. Lastly, the lack of shared memory certainly enables simpler GC schemes like this one, and it precludes all sorts nefarious bugs, but it also makes efficient parallelism impossible in many cases. Depending on your application, that may not be suitable.
Re:Erlang Garbage Collector by ramchip on Thursday November 30, 2017 @07:19PM (#15820916)
On Erlang 20 long GCs run on the thread pool for “dirty” (blocking) tasks, they don’t block a scheduler, so the real-time properties are nice.

There have been implementations of Erlang with shared heap in the past, before BEAM became heavily multi-threaded: https://www.researchgate.net/publication/2371933_A_Case_for_...

I think it would be nice to see this tried again. Perhaps the issue is scaling to future systems with potentially hundreds of cores?

Re:Erlang Garbage Collector by toast0 on Thursday December 07, 2017 @01:43PM (#15872751)
> How valuable is the property that other threads' GCs won't stop your thread if your thread bears its own full stop?

GC on a small heap is fast; especially since the language does not allow for circular references in the heap. Almost always, if you're you've got a large heap in your Erlang process, you're doing it wrong; large data generally belongs somewhere else like ETS, the in memory term storage.

Re:Erlang Garbage Collector by imtringued on Friday December 01, 2017 @04:01AM (#15822777)
The heaps are smaller. The problems with gcs start when you have multi gigabyte heaps. If every heap is only a gigabyte it will take at worst 10ms per collection. (Anecdote) If that is too large then you split your heaps into smaller ones until the pauses are acceptable.

Also remember malloc isn't free either it takes time to execute.

Re:Erlang Garbage Collector by hyperpape on Thursday November 30, 2017 @07:00PM (#15820801)
These are good questions.

Concurrent compacting collectors are pretty tough however, and a single process STW should be much faster than a global one, since it will be (at worst) proportional in time to the per process heap size.

Re:Erlang Garbage Collector by weberc2 on Thursday November 30, 2017 @07:45PM (#15821049)
I suppose it would need to be compacting; Go seems to get along okay without compaction, presumably because it has value types?
Re:Erlang Garbage Collector by aidenn0 on Friday December 01, 2017 @01:56AM (#15822416)
Go has traded throughput for latency. The throughput of a semispace copying collector is very high for most workloads, but can suffer latency issues. There is literally zero cost to collecting garbage in the nursery with the algorithm described in TFA (a nursery collection has a cost proportional only to the live data), and the cost of allocating in the nursery is just incrementing a single value. However eventually you need to collect the entire heap, and it's still proportional to the size of the live data, which is usually the majority of the heap (since you've already collected the nursery at that point).
Re:Erlang Garbage Collector by weberc2 on Friday December 01, 2017 @10:27AM (#15824332)
Sorry, I'm confused. Is Go's GC the semispaced copying collector or the TFA? Or neither? Or both?
Re:Erlang Garbage Collector by aidenn0 on Friday December 01, 2017 @02:57PM (#15826814)
TFA == "The Fine Article" so refers specifically to the Erlang Garbage Collector.

"Semispace" is one term to refer to the family of garbage collectors that Erlang's derives from. The heap is divided into two spaces, hence "semispace"

So Go's GC is neither. Go's gc is tuned for lower latencies, and that tends to rule out moving collectors (there are ways of having incremental moving collectors, but they complicate the runtime a bit).

Re:Erlang Garbage Collector by weberc2 on Friday December 01, 2017 @09:50PM (#15829825)
Ah, thanks for the information and clarification!
Re:Erlang Garbage Collector by tychver on Thursday November 30, 2017 @09:07PM (#15821389)
Go trades the complexity of a compacting GC for forcing you to restart the app regularly if you have a workload with plenty of heap allocation.
Re:Erlang Garbage Collector by weberc2 on Thursday November 30, 2017 @11:45PM (#15821980)
Really? I've never heard anyone mention this and I've followed Go for years.
Re:Erlang Garbage Collector by tychver on Friday December 01, 2017 @08:36AM (#15823683)
Yeah, it mostly happens when you have a server which runs an abnormally large task or payload, causes the heap to grow, and does it in a way that Go can't release the memory back to the OS due to heap fragmentation.

I haven't looked at this for a while but I believe it's still an issue.

https://github.com/cockroachdb/cockroach/issues/2007 https://github.com/golang/go/issues/18896 https://github.com/golang/go/issues/14045

Re:Erlang Garbage Collector by ori_b on Thursday November 30, 2017 @07:08PM (#15820847)
Even incremental GC is easier to write if you only have one thread you need to collect for.