Skip to content

Conversation

@pgdr
Copy link

@pgdr pgdr commented Nov 3, 2025

Adds a benchmark reproducing the Python 3.14 garbage collector regression described in cpython/#140175.

This real-world case uses pickletools to demonstrate the performance issue.

Fixes #437.

@pgdr
Copy link
Author

pgdr commented Nov 3, 2025

Python version Running time (sec)
3.13 1.59
3.14 6.47
3.15a 1.55

These tests (and the PR) has N = 1'000'000. The downside is that running the benchmark (with Python 3.14) takes almost 10 minutes.

I could reduce the size of the instance to lower the overall running time, but it seems like the garbage collector bug doesn't "kick in" until we reach a certain size.

With N = 100'000, the slowdown is not as noticable:

Python version Running time (ms)
3.13 162
3.14 197
3.15a 154

@pgdr
Copy link
Author

pgdr commented Nov 5, 2025

@sergey-miryanov Thanks for the review. I have fixed all issues you pointed out.

@pgdr
Copy link
Author

pgdr commented Nov 5, 2025

@sergey-miryanov Something strange happens here. Even though I use the context manager (tempfile.TemporaryDirectory), occasionally when I kill pyperformance, the directory remains not cleaned up.

I am not able to reproduce this behavior when not running with pyperf, though, so it might be related to the way pyperf sets up (parallel?) runners.

It sounds like a bug, but I can't tell where.

Copy link

@sergey-miryanov sergey-miryanov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good to me.

@sergey-miryanov
Copy link

@pgdr Thanks! It is up to pyperformance maintainers now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add additional GC related benchmark

2 participants