Live data from Hacker News

Erlang/OTP: Garbage Collector

medium.com

11–20 of 79 posts

Re: Erlang/OTP: Garbage Collector

#11
post #10
post #2

The post glosses over the most important part of Erlang's GC: it collects process heaps separately. This transforms a hard problem (collecting a global heap with low latency despite concurrent mutators) to a _much_ simpler problem, at the price of more copying. Compare Java's G1 with Erlang's GC; the former hurts my head. For those problems that are amenable to Erlang's model, this is a fine solution. The only real i…

Wouldn't Erlang be much more efficient if it simply compiled to the JVM?

No.

Re: Erlang/OTP: Garbage Collector

#12
post #10
post #2

The post glosses over the most important part of Erlang's GC: it collects process heaps separately. This transforms a hard problem (collecting a global heap with low latency despite concurrent mutators) to a _much_ simpler problem, at the price of more copying. Compare Java's G1 with Erlang's GC; the former hurts my head. For those problems that are amenable to Erlang's model, this is a fine solution. The only real i…

Wouldn't Erlang be much more efficient if it simply compiled to the JVM?

Ha! Absolutely no

Re: Erlang/OTP: Garbage Collector

#14

Scaling up an MQTT webhook relay that I wrote in Elixir to 1000’s of long running connections, I found that I needed to manually trigger periodic GCs on my long lived processes. As binary strings work their way through the pipelines via messages, it leaves binaries on the binary heap that don’t go away because the ref count stays above 1. There are a number of GC parameters one can tune on a per process level that mi…

Is any part of that relay open-source by chance? If not, what libraries are you using?

Re: Erlang/OTP: Garbage Collector

#15
post #10
post #2

The post glosses over the most important part of Erlang's GC: it collects process heaps separately. This transforms a hard problem (collecting a global heap with low latency despite concurrent mutators) to a _much_ simpler problem, at the price of more copying. Compare Java's G1 with Erlang's GC; the former hurts my head. For those problems that are amenable to Erlang's model, this is a fine solution. The only real i…

Wouldn't Erlang be much more efficient if it simply compiled to the JVM?

Almost 10 years ago, i've tested erjang [1] using a medium sized application. Throughput was better than BEAM but latency was terrible.

[1] https://github.com/trifork/erjang/

Re: Erlang/OTP: Garbage Collector

#16
post #10
post #2

The post glosses over the most important part of Erlang's GC: it collects process heaps separately. This transforms a hard problem (collecting a global heap with low latency despite concurrent mutators) to a _much_ simpler problem, at the price of more copying. Compare Java's G1 with Erlang's GC; the former hurts my head. For those problems that are amenable to Erlang's model, this is a fine solution. The only real i…

Wouldn't Erlang be much more efficient if it simply compiled to the JVM?

JVM standard does not support isolates so it won't work. Java's father Gosling wanted to get isolation into the Java spec but he failed.

The modern GraalVM does have isolates but its a VM specific feature and not a java standard feature.

Re: Erlang/OTP: Garbage Collector

#17
post #13
post #12

Earlier quoted context omitted.

Ha! Absolutely no

Why not? JVM has a highly optimized concurrent GC.

It’s a GC tuned for imperative languages that prefer mutation over allocation, which is the exact inverse of what BEAM needs.

Re: Erlang/OTP: Garbage Collector

#18
post #2

The post glosses over the most important part of Erlang's GC: it collects process heaps separately. This transforms a hard problem (collecting a global heap with low latency despite concurrent mutators) to a _much_ simpler problem, at the price of more copying. Compare Java's G1 with Erlang's GC; the former hurts my head. For those problems that are amenable to Erlang's model, this is a fine solution. The only real i…

Another point is that due to erlang's immutability there cannot be pointers from oldgen into nursery and thus the GC does not need write barriers.

Re: Erlang/OTP: Garbage Collector

#19
post #13
post #12

Earlier quoted context omitted.

Ha! Absolutely no

Why not? JVM has a highly optimized concurrent GC.

Erlang has a highly optimized concurrent GC as well. It's just optimized for different things. And maybe the concurrency of the GC is different; Erlang has one heap per process (aka green thread), and no concurrency within a heap.

Erlang GC is also very simple and easy to understand because language features only allow references in one direction. Much of JVM GC complexity would be wasted as there's no need to look for reference loops and such, since they're not possible.

Re: Erlang/OTP: Garbage Collector

#20

Scaling up an MQTT webhook relay that I wrote in Elixir to 1000’s of long running connections, I found that I needed to manually trigger periodic GCs on my long lived processes. As binary strings work their way through the pipelines via messages, it leaves binaries on the binary heap that don’t go away because the ref count stays above 1. There are a number of GC parameters one can tune on a per process level that mi…

There was some work to try to make this use case work with normal GC (RefC binaries count as their size garbage, rather than just the size the reference is on the process heap). But if you know your process should be pretty clean at some point, manually triggering GC will do a better job. Off heap message passing might help this case too.
Post reply on HN