Maybe not the right place to discuss, but does any...
# development
f
Maybe not the right place to discuss, but does anyone here have a good idea of what is going on with PEP 703? I'm trying to read https://discuss.python.org/t/pep-703-making-the-global-interpreter-lock-optional-3-12-updates/26503/102 and I'm glazing over at the sheer volume of text
w
I think we have a few threads on it in random? I've seen a few in the past month or so https://pantsbuild.slack.com/archives/C046T6TA4/p1686856322190979
b
I commented my update on the second link
Why do you ask? Do you have an interest in it? Pants related or otherwise?
f
Pants-related mainly. Trying to get an idea of when we'd be able to realistically see what performance benefits a nogil fork gives us.
I fairly regularly hit hurdles at my day job where I legitimately wonder if Pants is the right tool for us. The perf stuff hurts, and I wish I had more time to devote to fixing it. I think there's a lot of finger-crossing here that removing GIL will fix these problems (which I understand)
b
I think the nogil fork is likely in a place where we could use it. I think the limitor right now is the PyO3 support. When I tried it it went 💥
f
Yeah I saw some threads over on the PyO3 GitHub
h
Figuring out which rules are giving you performance headaches would be excellent inputs to a "convert more rules to Rust" effort, which I for one would like to see/participate in
❤️ 1
f
The big one is still
dependents
(or really anything that ends up effectively doing dep inference on most or all targets). So my thinking is that most of the graph code is probably a good candidate https://github.com/pantsbuild/pants/blob/7c3270f3631d6540fd822deac0236703696f59af/src/python/pants/engine/internals/graph.py
But I do wonder how much gain you'd get starting there, since there'd still a lot of switching back and forth between python and rust. Anecdotally, I see a lot of low CPU usage but high-ish load when doing this.
h
Yeah, graph stuff is a great candidate because it's not backend-specific
And this user is also having issues with performance of graph stuff: https://pantsbuild.slack.com/archives/C046T6T9U/p1689589616273189
Although that case seems pathological for other reasons
f
yeah I've been in contact with them... but it does seem to come down to something in the graph code
given that the longest running task descriptions are "Resolve transitive targets", which is a single rule (with a ton of dependencies) in
graph.py
I took a whack at sampling stack frames with https://bloomberg.github.io/pystack/ with the hope that I might catch some condition that points me in the right direction, but it's hard to make it catch anything in particular. I probably need to figure how to run Pants in a debugger on my repo if I want to be able to set breakpoint conditions and look for issues
I also saw something surprising... I expected the GIL to leave multiple stacks going (but only one executing with the GIL at a time), but I only see one rule thread per capture with a stack. There are 1-2 other threads including the main thread that launches the scheduler, and sometimes a streaming workunit handler thread waiting on a lock
And... what's more, altering the number of rule threads has essentially zero impact on performance for me. Anything from 2 to 12 executes in roughly the same time, and with the same amount of memory.