Skip to content

freelist feature causes slowdowns universally #6133

Description

@Zaczero

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 #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

  1. Use freelist
  2. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Fields

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions