Skip to content

GH-102300: Reuse objects with refcount == 1 in float specialized binary ops. #102301

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

Merged

Conversation

markshannon
Copy link
Member

@markshannon markshannon commented Feb 27, 2023

About 0.5% faster:

https://github.com/faster-cpython/benchmarking/tree/main/results/bm-20230227-3.12.0a5%2B-c29d369

The results are quite noisy.
But the results seem good, as the most float heavy benchmark, nbody, does show a 7% speedup.

@Fidget-Spinner
Copy link
Member

I can't see the results. I think external parties can't view that repo.

@brandtbucher
Copy link
Member

I can't see the results. I think external parties can't view that repo.

Sorry, you can change the repo name from benchmarking to benchmarking-public in the URL:

https://github.com/faster-cpython/benchmarking-public/tree/main/results/bm-20230227-3.12.0a5%2B-c29d369

Copy link
Member

@brandtbucher brandtbucher left a comment

Choose a reason for hiding this comment

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

Looks good (like the clever use of _Py_DECREF_NO_DEALLOC). Do we want a helper function or macro to reduce duplication?

In the original approach (#30594), I only considered the LHS, and added a special case for in-place ops followed by some variant of LOAD_FAST (where the refcount is 2). Not sure if we want to consider adding something similar later.

@markshannon
Copy link
Member Author

An inline function is tricky without introducing extra branches, so I've added a macro.

The refcount == 2 variant probably wants support from the bytecode compiler to mark candidates operations in x = x + (complicated expression).

@markshannon markshannon merged commit 233e32f into python:main Mar 13, 2023
warsaw pushed a commit to warsaw/cpython that referenced this pull request Apr 11, 2023
@markshannon markshannon deleted the check-refcnt-in-binary-op-experimental branch September 26, 2023 12:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants