Many thanks to all for your useful and interesting contributions. They've
helped me, and given me a lot to think about. It's clear that there are
several related or overlapping issues.

Here are some comments.

1. A major problem is to speed-up A, without slowing B. In other words, how
to avoid refcounting None, without slowing down other refcounts. (I'm
reminded of putting a sentinel at the end of a list, to speed up searching
for an item in the list.)

2. Which objects have busy refcounts? They are a potential target for
optimization, even at the cost of slowing refcounting for the other objects.

3. The pull request that Guido referenced is quite small, and gives me some
hope that I could code a patch that explores some aspect of the problem
(such as gathering refcount stats).

4. Keeping the refcounts separate from the objects is looking more
attractive. It would ease the CoW problem addressed in the pull request. It
also makes multi-core reference count garbage collection easier (see this
thread, which I started in July 2018,
https://mail.python.org/archives/list/python-ideas@python.org/message/54AIYMCM3UZI3QVTRLQQHRTGN2PXGI6M/
).

5. Even without removing the GIL, if a second core could do the garbage
collection reference counts, that would probably boost the performance of
the first core (the one that does the useful work).

6. I think that statistics about the hot-spots would reduce the role for
guessing and opinion. I think toy examples implemented and tested would
increase our understanding.

7. This problem is harder than I thought. To be successful, my suggestion
needs a cheap way to avoid unnecessary refcount operations.

8. If all objects are eternal, then we don't need any refcounts. But then
we don't have any garbage collection either! It seems to me that much of
the problem lies in the interface between eternal and transient objects.
Mutable eternals are particularly problematic.

9. Relevant here is https://en.wikipedia.org/wiki/Flyweight_pattern,
although the purpose is somewhat different.

10. Choosing the right problem to solve is very important. This could be
subtle. I seem to have leapt at an obvious, but difficult (and perhaps
insoluble) problem. (We can avoid the unnecessary refcounting, but perhaps
not cheaply enough.)

I've changed my opinion. I doubt that there's an easy win here. But I
suspect that there is a win that is worth having. I'll now go away and
think about things for a while.

Thank you all, for the useful contributions.

-- 
Jonathan
_______________________________________________
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/A2YZZ2GD4PBZVZPW3YCE4PGFJLIZ3B6V/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to