Skip to content

Automatically defer heavily shared objects in free-threading. #134821

Open
@Fidget-Spinner

Description

@Fidget-Spinner

Feature or enhancement

Proposal:

@corona10 asked if it would be possible to automatically apply deferred refcounting on objects if we notice they're heavily shared in the interpreter through some heuristic. The problem in #134762 (comment) is that we need to defer basically anything shared as it would perform badly in a microbenchmark otherwise.

I think it should be possible. We could rely on biased refcounting to give us a rough estimate on when something is shared, once it's past a certain threshold, we automatically defer the object. Does anyone have a better heuristic to suggest?

Also I'm not going to take this up, as I have too much work on my plate already, so let me know if you'd like to work on it, I can collaborate and provide guidance.

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

No response

Linked PRs

Activity

ZeroIntensity

ZeroIntensity commented on May 28, 2025

@ZeroIntensity
Member

I'd be happy to try this.

corona10

corona10 commented on May 28, 2025

@corona10
Member

I will happily track the issue or try to help.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Automatically defer heavily shared objects in free-threading. · Issue #134821 · python/cpython

      Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!

      Check out: eBank.nz (Art Generator) | Netwrck.com (AI Tools) | Text-Generator.io (AI API) | BitBank.nz (Crypto AI) | ReadingTime (Kids Reading) | RewordGame | BigMultiplayerChess | WebFiddle | How.nz | Helix AI Assistant