[erlang-questions] A whole bunch of implementation details

Raimo Niskanen raimo+erlang-questions@REDACTED
Thu Sep 4 09:36:31 CEST 2008


On Wed, Sep 03, 2008 at 09:37:40PM -0500, Dennis Byrne wrote:
> Gave a presentation today to a very bright crowd.  Lots of these people 
> just wanted to ask questions rather than looks at slides.  Here's a 
> handful of questions I got, for which I was anywhere from half way to 
> completely clueless on. 
> 
> Does a process get pinned to one OS thread for it's entire existence? What 
> factors go into the VM's decision to pin a process to one OS thread or 
> another?  How do we prevent all the busiest processes from being tied to 
> one OS level thread? 

Today there is one run queue that all schedulers pick processes from.
Each scheduler is pinned to one OS thread. So running processes
move randomly betwheen OS threads between schedule out and schedule in.

This will be a near future problem since it is desirable to keep
processes in the same OS thread to utilize the CPU cache better.
The decision on when to move a process between schedulers will
be automatic by the scheduling algorithm, but it may be
possible for the programmer to hint. It is work in progress.

> How does stack memory grow?  Am told Prolog does this dynamically and I 
> was wondering if Erlang did the same.  Does heap memory contract? 

Stack and heap grows towards each other in a common memory block.
When they collide a larger block is allocated and the live
data is garbage collected over to the new block. That was
simplified. A garbage collect may free enough memory to
not need to allocate a new memory block too.

Heap/stack memory blocks will also shrink if overallocated
for too long, but it is easier to know when to grow than
when it is profitable to shrink, so shrinking is a bit slow
(conservative).

> Exactly what is the tipping point between what gets passed by value and 
> what gets passed by reference?  The large binary trick is common 
> knowledge, any other corner cases?

As Rickard O'Keefe answered. Whithin a process all is passed
by reference. It can be so since it is a functional language.
Data does not change.

When sending to another process all is copied. Except for
binaries (larger than 64 byte). And there is a VM variant
(experimental, the Hybrid Heap VM) that can share data
between processes making send non-copy in many cases.

> How does the VM differentiate between a node that is temporarily 
> unresponsive and one that is down?  In other words, at what point does a 
> node give up on a peer?

http://www.erlang.org/doc/man/kernel_app.html, read on net_ticktime.

> ____________________________________________
> Dennis Byrne
> ThoughtWorks - Chicago
> http://notdennisbyrne.blogspot.com/
> 312-505-7965
> 

> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions

-- 

/ Raimo Niskanen, Erlang/OTP, Ericsson AB



More information about the erlang-questions mailing list