> On 15 Jun 2020, at 20:48, Christopher Barker <python...@gmail.com> wrote:
> 
> On Mon, Jun 15, 2020 at 9:21 AM Barry Scott <ba...@barrys-emacs.org 
> <mailto:ba...@barrys-emacs.org>> wrote:
> The problem is when you fork a python process.
> 
> Each of the child processes you would hope shared the state of the
> parent that is not being changed. But because of ref counting
> even unchanging objects get modified by a ref count inc/dec cycle
> and then the page that the object is in is copy-on-write'ed.
> 
> End result is that a children share no pages with the parent.
> 
> I'm out of my depth here, but:
> 
> how many immortal objects are there? Quite a few, but they are small, yes? 
> (None, False, True, small integers, ....) and the copy-on-write happens at 
> the page scale (~4096k ???). So would having a bunch of small immortal 
> objects that don't get altered really help? Maybe if they were organised to 
> be all together.

The PR that Guido pointed to works by no longer doing INC/DEC on objects after 
a special call that marks all existing objects as immortal.

This has the effect of allowing all the code and data that has been loaded to 
shared pages of memory.
This can be 100s of MiB of ram in the interesting cases.

> 
> It seems this could make a much more substantial difference if the user could 
> mark certain objects immortal. But that would be pretty tricky -- as Python 
> typically has a lot of small objects in containers -- how would you mark them 
> all?


Only if they are on a page of memory that is not shared by objects that does 
not contain object mortal objects.

That was a discussion on moving the ref counts out of the objects and into 
separates pages so that the objects that do not
change are not Copy-On-Write (COW) un-shared. I think that if ref counts 
survive in CPython then this is a very interesting way out of the
COW problem.

Barry

_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/6SVBXWPMDV75VE6K6KUKH4G44XXA2245/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to