GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — gh-89279: In ceval.c, redefine some macros for speed by gvanrossum · Pull Request #32387 · python/cpython Conversation
|
And yet, in I've done the rest you've asked, and merged origin/main. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
PS. Any suggestion on how to handle the The compiler says there are 24 separate places where this fails to inline just in |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
I took care of this, it was relatively straightforward since the invocations in ceval.c all go through macros that in the end call |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
So that the assert() in the macro will be checked in debug mode.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The Python/ceval.c changes LGTM, but I cannot review the 2 other modified files.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| // bpo-45116: The MSVC compiler fails to inline these in PGO build, | ||
| // and they're kind of important for performance. |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
You might explain that MSVC can inline them, but it's just an arbitrary limit which cannot be configured.
neonene wrote "PR25244 told me the amount of code in _PyEval_EvalFrameDefault() is over the limit of PGO."
I suggest something like:
| // bpo-45116: The MSVC compiler fails to inline these in PGO build, | |
| // and they're kind of important for performance. | |
| // bpo-45116: The MSVC compiler does not inline these 3 static inline functions in PGO build | |
| // in _PyEval_EvalFrameDefault(), because this function is over the limit of PGO, | |
| // and these limits which cannot be configured. Define them as macro to make sure that | |
| // there are always inlined by the preprocessor. |
Maybe tomorrow, MSVC PGO limits will change or become configurable, and it will become possible to remove these macros on more recent MSVC versions.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
I would prefer to not redefine _Py_atomic_load_relaxed() in ceval.c. PEP 7 was updated to require C11 to build Python 3.11, but C11 without optional features: without atomatic functions/variables. Python still requires pycore_atomic.h with an implementation which depends on the C compiler and on the platform. Maybe tomorrow we will be able to use C11 atomic variables, but I don't think that it's possible right now :-( |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Oh, I see. The simple version of |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Using the techniques I developed in faster-cpython/ideas#321 I couldn't find any uses of Py_INCREF in |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
When we take a inlining log at profiling time (PGInstrument):
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thanks for explaining what I have a new slight mystery. I write a script that scans build.log and prints the top-10 most common non-inlined functions (in my 'inline' branch): Looking at the last one, This seems rather silly, especially since we're obviously freeing something and there's a code path that allocates. I am at a loss where exactly |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Hm, address sanitizer doesn't like |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I'm running out of time today. I will apply @vstinner's improvement of the macros later this week. (If you create a comment with a suggestion I can do it quicker.) @sweeneyde I'm not sure that it matters much whether |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Sounds reasonable to me, and it would be nice to not have to worry about different casting between the function and the macro, but I don't fully understand what |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Me neither, but I'm guessing it might have been caused by a shortcut I took where instead of running |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
A full run where I had restored the so I conclude that I should keep that expanded. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
With I conclude that the macro is still a good idea. So the only thing left on my to-do list for this PR is Victor's beatification of the macros. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
With this PR as is, I just see: |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
My suggestion to reformat macro on mutliple lines, now as a GitHub suggestion (and with _Py_DECREF_SPECIALIZED).
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Co-authored-by: Victor Stinner <[email protected]>
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
LGTM, even if I didn't understand everything. But I trust the ones who ran extensive tests on Python benchmarks with different compiler options.
There are many compiler warnings. Are they related to the change?
GitHub Actions / Address sanitizer
Python/ceval.c#L2408
function called through a non-compatible type
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Co-authored-by: Dennis Sweeney <[email protected]>
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
I took the liberty of fixing two obvious bugs. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
macOS failure is unrelated:
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
I now think that macrofying here is good only for stable APIs.
Maybe some pragma can fix this. I'll check the entries. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I don’t see the problem with …DECREF_SPECIALIZED. It’s semantics are very straightforward. @sweeneyde WDYT? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
I think it would be sufficient to add a comment with something like "if this changes, the macro version in ceval.c should change accordingly". |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Though I do agree that _Py_DECREF_SPECIALIZED is not likely to change semantics, particularly not the non-debug version. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Then, I'm fine. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thanks everyone for the help! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.