freelist feature causes slowdowns universally
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.2k
- Forks
- 1k
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 66
Description
Bug Description
I've been naively enabling freelist to enhance performance of my applications. Turns out there's not a single case it helped the performance. Turns out the change https://github.com/PyO3/pyo3/pull/4902 caused a bottleneck that completely waives any benefits of using freelist - it's better to remove the feature altogether.
I digged deeper.
Fable 5 conclusion was: Short answer: because since PyO3 0.23.5 (Feb 2025), every freelist push and pop takes a std::sync::Mutex — on all builds, including GIL builds — and the locking overhead now exceeds what the freelist ever saved. I reproduced your observation in the container with a controlled experiment; the sign genuinely flipped.
Which makes sense to me and I think this observation is good.
Steps to Reproduce
- Use freelist
- Measure
Backtrace
Your operating system and version
Linux 6.18
Your Python version (python --version)
Python 3.14
Your Rust version (rustc --version)
rustc 1.96.0 (ac68faa20 2026-05-25)
Your PyO3 version
0.28.3
How did you install python? Did you use a virtualenv?
uv
Additional Info
Before Fable was restricted, I managed to ideate some ideas on potential ways forward: https://claude.ai/share/c18f23ad-b07e-4ffe-a285-bd40e92b81dd Do whatever you want with that information.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the slowdown with freelist enabled and measuring push and pop performance, then inspect the change in PyO3 pull request 4902. Compare the results across the reported PyO3, Python, and Rust versions; done requires an agreed change that restores a measurable benefit or removes the ineffective feature.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, rust
- Domain
- backend-api-design, performance
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100