
On Wed, Feb 16, 2022 at 12:37 AM Inada Naoki <songofacandy@gmail.com> wrote:
+1 for overall idea.
Great!
Also note that "fork" isn't the only operating system mechanism that uses copy-on-write semantics.
Could you elaborate? mmap, maybe? [snip[ So if you know how to get benefit from CoW without fork, I want to know it.
Sorry if I got your hopes up. Yeah, I was talking about mmap.
There will likely be others we have not enumerated here.
How about interned strings?
Marking every interned string as immortal may make sense.
Should the intern dict be belonging to runtime, or (sub)interpreter?
If the interned dict is belonging to runtime, all interned dict should be immortal to be shared between subinterpreters.
Excellent questions. Making immutable objects immortal is relatively simple. For the most part, mutable objects should not be shared between interpreters without protection (e.g. the GIL). The interned dict isn't exposed to Python code or the C-API, so there's less risk, but it still wouldn't work without cleverness. So it should be per-interpreter. It would be nice if it were global though. :)
If the interned dict is belonging to interpreter, should we register immortalized string to all interpreters?
That's a good point. It may be worth doing something like that. -eric