[Python-Dev] GIL removal question

Sturla Molden sturla at molden.no
Fri Aug 12 20:59:42 CEST 2011


Den 12.08.2011 18:51, skrev Xavier Morel:
> * Erlang uses "erlang processes", which are very cheap preempted 
> *processes* (no shared memory). There have always been tens to 
> thousands to millions of erlang processes per interpreter source 
> contention within the interpreter going back to pre-SMP by setting the 
> number of schedulers per node to 1 can yield increased overall 
> performances) 

Technically, one can make threads behave like processes if they don't 
share memory pages (though they will still share address space). Erlangs 
use of 'process' instead of 'thread' does not mean an Erlang process has 
to be implemented as an OS process. With one interpreter per thread, and 
a malloc that does not let threads share memory pages (one heap per 
thread), Python could do the same.

On Windows, there is an API function called HeapAlloc, which lets us 
allocate memory form a dedicated heap. The common use case is to prevent 
threads from sharing memory, thus behaving like light-weight processes 
(except address space is shared). On Unix, is is more common to use 
fork() to create new processes instead, as processes are more 
light-weight than on Windows.

Sturla









More information about the Python-Dev mailing list