[erlang-questions] Reference counting instead of GC?
Thu Jul 3 17:47:51 CEST 2008
Message don't copy for example Termite (http://toute.ca/) and this is of
course faster for big messages. But there is many good reasons why Erlang is
as is. Counting GC is in some cases slower than generating GC especially on
multi core. For example, when you do walking tree, in current GC schema you
can copy after 1000 reduces small resulting tree and during those reduction
you don't GC anything. Contrary counting GC every change of tree and each GC
step can take unpredictable different long time. Current GC occurs once
after longer period and depend only on size off current data. In result it
is faster on single core. There is more fun with multi core. When processes
share data (don't copy message), counter for each structure can be accessed
by many processes running possibly on many CPU cores. CPU cache don't work
well in this case and operation is slow. So counting GC is slow in
concurrent environment. Counting GC is not as good as looks in first sight.
When there is possibility to pack big messages into binary which is not
copied, you are able solve pitfalls of Erlang implementation. And share
anything between processes also impact reliability, of course. I don't
believe change GC is good idea except you want just try it.
On Thu, Jul 3, 2008 at 2:16 PM, Alpár Jüttner <> wrote:
> Did anyone consider replacing the garbage collection with reference
> counting in the Erlang emulator? How difficult would it be to do?
> Probably, it isn't worth changing in general, but reference counting has
> some advantages which are important in some special use cases:
> * Per process memory pools is not necessary.
> * Message passing (of large data) will be more efficient as
> messages don't have to be physically copied.
> * There is no need for garbage collection. GC is for example a
> major pitfall in hard real time systems (see e.g.
> http://www.erlang.se/workshop/2007/proceedings/05nicosi.pdf )
> Here are the drawbacks I can see now:
> * Higher memory overhead.
> * However the memory is less fragmented, so we get back
> something in return.
> * It is said to be slower. I'm not absolutely convinced about it
> * In general, the highest problem with reference counting is that
> in case of cross/circular referencing, dead objects will be left
> in the memory. However, this cannot happen in Erlang due to the
> immutability of the data.
> erlang-questions mailing list
--Hynek (Pichi) Vychodil
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions