Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PEP 703 Deferred reference counts #121459

Closed
Fidget-Spinner opened this issue Jul 7, 2024 · 3 comments
Closed

PEP 703 Deferred reference counts #121459

Fidget-Spinner opened this issue Jul 7, 2024 · 3 comments
Labels
topic-free-threading type-feature A feature request or enhancement

Comments

@Fidget-Spinner
Copy link
Member

Fidget-Spinner commented Jul 7, 2024

Feature or enhancement

Proposal:

PEP 703 proposes deferred reference counting to reduce contention between threads on shared objects' reference count fields.

This issue is not in conflict with Faster CPython's scheme of fully removing reference counts in the eval loop. In fact, some of the work runs parallel to it and will actually help it.

There are 3 wins I can observe right now:

  • deferring LOAD_GLOBAL
  • deferring LOAD_ATTR
  • deferring frames' strong references on the code object and function (this is the hardest of the three)

I shall proceed in this order.

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

No response

Linked PRs

@Fidget-Spinner Fidget-Spinner added type-feature A feature request or enhancement topic-free-threading labels Jul 7, 2024
Fidget-Spinner added a commit that referenced this issue Sep 13, 2024
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Sam Gross <655866+colesbury@users.noreply.github.com>
zware added a commit to zware/cpython that referenced this issue Sep 13, 2024
colesbury added a commit to colesbury/cpython that referenced this issue Sep 14, 2024
colesbury added a commit to colesbury/cpython that referenced this issue Sep 14, 2024
We need to return immediately if there's an error during dictionary
lookup.

Also avoid the conditional-if operator. The Windows 10 buildbot seems to
miscompile that for unknown reasons.
colesbury added a commit that referenced this issue Sep 14, 2024
We need to return immediately if there's an error during dictionary
lookup.

Also avoid the conditional-if operator. MSVC versions through v19.27 miscompile
compound literals with side effects within a conditional operator. This caused
crashes in the Windows10 buildbot.
savannahostrowski pushed a commit to savannahostrowski/cpython that referenced this issue Sep 22, 2024
…thon#124085)

We need to return immediately if there's an error during dictionary
lookup.

Also avoid the conditional-if operator. MSVC versions through v19.27 miscompile
compound literals with side effects within a conditional operator. This caused
crashes in the Windows10 buildbot.
mpage added a commit that referenced this issue Oct 21, 2024
…25711)

* Fix usage of PyStackRef_FromPyObjectSteal in CALL_TUPLE_1

This was missed in gh-124894

* Fix usage of PyStackRef_FromPyObjectSteal in _CALL_STR_1

This was missed in gh-124894

* Regenerate code
@Fidget-Spinner
Copy link
Member Author

This is implemented now.

@picnixz
Copy link
Member

picnixz commented Dec 14, 2024

What about #124101? should this one be considered as optional?

@Fidget-Spinner
Copy link
Member Author

@picnixz I'm waiting for the porting over the specializing intepreter to free threaded build to play out. If that works for LOAD_ATTR we wont need the PR anymore.

ebonnal pushed a commit to ebonnal/cpython that referenced this issue Jan 12, 2025
…l` (python#125711)

* Fix usage of PyStackRef_FromPyObjectSteal in CALL_TUPLE_1

This was missed in pythongh-124894

* Fix usage of PyStackRef_FromPyObjectSteal in _CALL_STR_1

This was missed in pythongh-124894

* Regenerate code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic-free-threading type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

2 participants