Skip to content

Conversation

@FakeMichau
Copy link
Contributor

inspect.stack() is extremely slow. Using _getframe on cpython is way faster. Wasn't able to test pypy's _getframe but can't imagine it being slower than getting the entire stack.

This change lowered real life CPU usage in ax-shell in idle from about 3% to 1.5% on my system. Could avoid using this function in ax-shell but fabric itself uses it in many places so fixing it upstream would be perfect.

Used Austin to find the bottleneck if someone wants to confirm the issue.

@its-darsh its-darsh self-assigned this Oct 11, 2025
@its-darsh its-darsh added the enhancement New feature or request label Oct 11, 2025
@its-darsh
Copy link
Contributor

Needs extensive testing....
Will test it locally once I get some free time.

One more thing. @Axenide, excuse me, but what the actual fuck?

@Axenide
Copy link
Contributor

Axenide commented Oct 11, 2025

🤔

@amansxcalibur
Copy link
Contributor

While testing I noticed a significant improvement (almost 20x). Took only 0.1s for 100k calls compared to the current implementations 2s.

@its-darsh
Copy link
Contributor

Okay, that's it.
image

@its-darsh its-darsh merged commit 0f3d317 into Fabric-Development:main Oct 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants