[Python-ideas] Save memory when forking with *really* immutable objects
Niki Spahiev
niki.spahiev at gmail.com
Tue Mar 13 11:57:02 CET 2012
On 13.03.2012 05:49, Gregory P. Smith wrote:
> Despite me really disliking anything that fork()s these days and generally
> not using fork anymore... I have been pondering this one on and off over
> the years as well, it could help with people using the fork()ing variant of
> multiprocessing (ie: its default today).
>
> If reference counts were moved out of the PyObject structure into a region
> of memory allocated specifically for reference counts, only those pages
> would need copying rather than virtually every random page of memory
> containing a PyObject. My initial thought was to do this by turning the
> existing refcount field into a pointer to the object's count or an array
> reference that code managing the reference count array would use to
> manipulate the count. Obviously either of these would have some
> performance impact and break the ABI.
>
> Some practical real-world-ish forking server and multiprocessing
> computation memory usage benchmarks need to be put together to measure the
> impact of any work on that.
This looks like dalvik VM in android. They do many things to preserve
memory when forking.
HTH
Niki
More information about the Python-ideas
mailing list