Does PyPy memory use benefit from preforking?

Hello! A little bit of context: roughly speaking, preforking is a technique where a (supervisor) process is started, the process performs some initialization and then forks off into child worker processes, which it then supervises. It's usually used to make several worker processes share a server TCP socket (which they inherit from the supervisor). In some runtimes preforking can also be used to save memory since the child processes get copy-on-write access to the supervisor memory pages. My understanding is this doesn't actually yield anything on CPython since essentially everything is reference counted and memory pages get copied quickly. PyPy doesn't use reference counting though, so I was wondering if preforking could be used with PyPy for memory saving purposes. All of this is a little low-level for me, and I would appreciate any insight from the resident experts :)

Hi Tin As far as I remember PyPy has GC headers that have various bits set and cleared when walking the heap for garbage collection, so while it does not use reference counting, it would not benefit really from pre-forking either. There are some ideas how to make that work, btu none of them have been implemented. Best, Maciej Fijalkowski On Sat, 18 Sept 2021 at 21:58, Tin Tvrtković <tinchester@gmail.com> wrote:

Hi Tin As far as I remember PyPy has GC headers that have various bits set and cleared when walking the heap for garbage collection, so while it does not use reference counting, it would not benefit really from pre-forking either. There are some ideas how to make that work, btu none of them have been implemented. Best, Maciej Fijalkowski On Sat, 18 Sept 2021 at 21:58, Tin Tvrtković <tinchester@gmail.com> wrote:
participants (2)
-
Maciej Fijalkowski
-
Tin Tvrtković