Skip to content

gh-148906: fix scaling of descriptors on free-threading#148915

Open
kumaraditya303 wants to merge 2 commits intopython:mainfrom
kumaraditya303:descriptor-scaling
Open

gh-148906: fix scaling of descriptors on free-threading#148915
kumaraditya303 wants to merge 2 commits intopython:mainfrom
kumaraditya303:descriptor-scaling

Conversation

@kumaraditya303
Copy link
Copy Markdown
Contributor

@kumaraditya303 kumaraditya303 commented Apr 23, 2026

On this PR:

./python.exe Tools/ftscalingbench/ftscalingbench.py --threads=10 descriptor
Running benchmarks with 10 threads
descriptor                 4.1x faster

@kumaraditya303 kumaraditya303 added performance Performance or resource usage topic-free-threading labels Apr 23, 2026
Comment thread Objects/typeobject.c

PyObject *res_obj = PyStackRef_AsPyObjectBorrow(*out);
#if Py_GIL_DISABLED
// Optimistically enable deferred refcounting on descriptors
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we do this in type_setattro? That seems like a more logical place to me, and it's where we enable deferred reference counting on function objects.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Wouldn't that only work when the descriptor is assigned to the class after class is already created?

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants