Live data from Hacker News

Reverting the incremental GC in Python 3.14 and 3.15

discuss.python.org

121–130 of 134 posts

Re: Reverting the incremental GC in Python 3.14 and 3.15

#121
post #61
post #50

Earlier quoted context omitted.

No we should write one of the many modern programming languages that handle certain projects way better, including kotlin, go, or Java. The only things python is best in class at are scripting and as a harness for high performance c++ or fortran.

What about the projects that python handles better?

I mentioned those explicitly. People are still using it as a backend language for projects like huge SaaS deployments though, with the hypothesis being that dev time is expensive. With modern languages like kotlin and go, I think that gap is much too narrow to justify using a slow and badly designed language with good syntax.

Re: Reverting the incremental GC in Python 3.14 and 3.15

#123
post #81
post #75

Earlier quoted context omitted.

The max pause time thing is a meme :) I have gotten multi second pause times with ZGC. It depends on what hardware you run it on.

The new generational ZGC? I'm sceptical.

So if I run it on a Pentium 3 you're telling me I can't get a long pause time? "1ms" means nothing

Re: Reverting the incremental GC in Python 3.14 and 3.15

#124
post #120

Earlier quoted context omitted.

Are you not confusing GC (freeing memory) with the memory allocator ? Memory allocator: tcmalloc, jemalloc, they are concerned with fetching (and releasing) pages of memory from the OS and allocating objects for the program GC is only responsible for saying to the memory allocator "this object is no longer used" (please stay focused on java)

> GC is only responsible for saying to the memory allocator "this object is no longer used" This is simply not true. Not only are Java's GCs responsible for allocation (which they do simply by bumping a pointer, similar to stack allocation), unlike Python's refcounting collector or Go's nonmoving tracing collector, they have no free operation of any kind and never free objects. Moving collectors don't even know when…

That's not true, shenadoah does decommit and will continue to in the new generational version.

Re: Reverting the incremental GC in Python 3.14 and 3.15

#125
post #78

Earlier quoted context omitted.

We've been chasing down similar aiohttp client creation issues (liked to ...aiobotocore usage) for months now. It's annoying that somehow talking to S3 etc requires so much churn. We have been trying to cache session objects and the like but clearly are still missing something. Chasing this down has also made me realize how little Python libs use `weakref`, and just will build up so many circular references. The othe…

It's really fascinating to read this, since I've encountered similar memory issues in other languages (ruby, go, etc.). Debugging these issues is a pain. Is there a way to make all this much easier to debug and to prevent memory issues in the first place? Is the abstraction level not quite right?

So with CPython's reference counting, if you're good at not building strong cycles, you really can avoid garbage pressure. It's not even that complicated, it's mostly a question of making a weak reference _somewhere_ along the chain. Often the ergonomics are not great, but Python @property's are nice here.

So for example

class Request

class Session

request.session exists, and the session is "part" of the request. but session.request often exists as a facility. That's a reference cycle which prevents the request (and anything it's pointed at!) from being deallocated at the end of a request.

But in this case, you could easily do something like:

session._request = weakref.ref(request) # on session creation

and then have session.request call session._request() (and maybe assert session._request() is not None if you want to be certain). If you're confident that the session is a "child" of the request, and that you would _never_ have a hold of the session after the request is done, this is a cheap trick that makes session.request cost a little bit more but not much.

I think most Python libraries just don't do memory perf analyses here, and also "believe" in the garbage collector. When GC runs, both request and session will get deallocated, after all! But the long term effects of everyone relying on the GC are that GC is expensive when it doesn't need to be, and when looking through memory you just have more stuff to dig through

Re: Reverting the incremental GC in Python 3.14 and 3.15

#126
post #95

Earlier quoted context omitted.

That doesn't matter for anything other then CLIs.

Some people are writing CLIs

Yes, of course, but I took the conversation to be centered around backend uses cases. What CLI is experiencing garbage collection issues like that in this discussion?

Re: Reverting the incremental GC in Python 3.14 and 3.15

#127
post #93

Earlier quoted context omitted.

Why are people still building systems on top of a language that continually undergoes fundamental changes nearly 40 years after release? Is this not the strongest indication that this language is not well designed, it is unstable, and encounters many issues that flat out don't exist in other high level languages?

What language that is actually used 40 years after release isn't undergoing big, fundamental changes? Java? Nope, you're getting a fundamental change in Valhalla C++? Nope, new language edition every few years with fundamental changes C? C23 has a number of fairly fundamental changes, expect more in the next language revision I think your sense of causality is backwards here. These languages are getting fundamental c…

> Languages with no users don't need to change.

That's fine, but that's clearly not what I'm talking about.

Languages like F#, Elixir, etc. don't undergo fundamental changes. Yes, every language evolves. But for Python, we're talking about grafting literally fundamental stuff on top of a language not designed for any of these things.

For example, if someone went and redesigned Python to solve its warts, you'd basically end up with F#.

Re: Reverting the incremental GC in Python 3.14 and 3.15

#128
post #86
post #65

Earlier quoted context omitted.

I like my programming language flame wars just as much as the next guy but Go is a really easy language to get started with, while also being very fast. It's not just luck

> The key point here is our programmers are Googlers, they’re not researchers. They’re typically, fairly young, fresh out of school, probably learned Java, maybe learned C or C++, probably learned Python. They’re not capable of understanding a brilliant language but we want to use them to build good software. So, the language that we give them has to be easy for them to understand and easy to adopt. -- Rob Pike

Exactly my point

Re: Reverting the incremental GC in Python 3.14 and 3.15

#129
post #123
post #81

Earlier quoted context omitted.

The new generational ZGC? I'm sceptical.

So if I run it on a Pentium 3 you're telling me I can't get a long pause time? "1ms" means nothing

Yes, on any hardware that ZGC supports and that your program otherwise runs with acceptable performance you won't get a long pause time, including (hypothetically) Pentium 3. The reason is that there is no work done inside the pause (no marking, no compacting, not even root scanning). It's just used to signal all threads that a new "epoch" is starting. On small hardware you have a small number of active threads, and so the pause will also be very short.

Re: Reverting the incremental GC in Python 3.14 and 3.15

#130
post #124
post #120

Earlier quoted context omitted.

> GC is only responsible for saying to the memory allocator "this object is no longer used" This is simply not true. Not only are Java's GCs responsible for allocation (which they do simply by bumping a pointer, similar to stack allocation), unlike Python's refcounting collector or Go's nonmoving tracing collector, they have no free operation of any kind and never free objects. Moving collectors don't even know when…

That's not true, shenadoah does decommit and will continue to in the new generational version.

What exactly of what I wrote is untrue, and while I'm not familiar with Shenandoah, what does decommitting have to do with any of it?
Post reply on HN