Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-111786: Turn off optimize for speed for _PyEval_EvalFrameDefault on MSVC#111794

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
gvanrossum merged 8 commits intopython:mainfrommdboom:optimize-off
Nov 9, 2023

Conversation

@mdboom
Copy link
Contributor

@mdboommdboom commentedNov 6, 2023
edited by bedevere-appbot
Loading

Copy link
Member

@gvanrossumgvanrossum left a comment

Choose a reason for hiding this comment

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

LGTM.@markshannon or@brandtbucher can merge if they agree.

Copy link
Member

@markshannonmarkshannon left a comment

Choose a reason for hiding this comment

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

3-10% fasterand fixes the build. Sounds good to me 🙂
I'd like@zooba's approval though, in case we missed something.

@mdboommdboom requested a review fromzoobaNovember 7, 2023 13:18
@zooba
Copy link
Member

My only question would be whether weknow that turningt off implicitly turnss (size) on, or if it leaves us with no optimisations at all.

The results seem to be okay for PGO builds, but regular builds may suffer a regression if optimisation is just turned off. (For debug builds we have it off deliberately, and would want to avoid turning it on.)

@mdboommdboom marked this pull request as draftNovember 7, 2023 17:48
@mdboom
Copy link
ContributorAuthor

Converting to draft -- I'm seeing some non-determinacy to this fix, so we should hold off on merging until I get to the bottom of it.

@mdboommdboom marked this pull request as ready for reviewNovember 7, 2023 18:38
@brandtbucher
Copy link
Member

I see this has been re-opened. Did you figure out the issue?

If so, it looks like it's ready to merge (assuming we aren't seeing a regression on non-PGO builds).

@mdboom
Copy link
ContributorAuthor

My only question would be whether we know that turning t off implicitly turns s (size) on, or if it leaves us with no optimisations at all.

I couldn't find a way to directly introspect this. However, I decided to try to forcibly turn "s" on after turning "t" off and compare the results to this PR, e.g.:

#  pragma optimize("t", off)#  pragma optimize("s", on)

UsingSizeBench, I was able to confirm that both that and this PR generate the same size code for_PyEval_EvalFrameDefault (it's in two blocks: 37,951 bytes of hot code and 28,104 bytes of cold code).

So that (might be) indirect evidence at least that we still get size optimization this way.

brandtbucher and zooba reacted with thumbs up emoji

@mdboom
Copy link
ContributorAuthor

I see this has been re-opened. Did you figure out the issue?

Yes, it was entirely me not seeing the difference betweenoptimize("", on) andoptimize("", "on"). (I blame insufficient coffee).

If so, it looks like it's ready to merge (assuming we aren't seeing a regression on non-PGO builds).

I just fired off some benchmarking runs to test the effect of this on non-PGO builds. It will take a few hours to get the results back.

@brandtbucher
Copy link
Member

brandtbucher commentedNov 7, 2023
edited
Loading

Yes, it was entirely me not seeing the difference betweenoptimize("", on) andoptimize("", "on"). (I blame insufficient coffee).

I blame "that's a rough API design".

zooba reacted with thumbs up emoji

@zooba
Copy link
Member

So that (might be) indirect evidence at least that we still get size optimization this way.

Unoptimised code will be huge by comparison - 2x or more. Sounds like we're still getting the optimization.

@mdboom
Copy link
ContributorAuthor

Unoptimised code will be huge by comparison - 2x or more. Sounds like we're still getting the optimization.

And some level of PGO is still happening, as evidenced by the split into hot and cold paths.

If so, it looks like it's ready to merge (assuming we aren't seeing a regression on non-PGO builds).

Unfortunately, itseems this causes an 11% regression on non-PGO builds. (This is comparing non-PGO or this PR vs. a non-PGO build of its base 9f33ede).

If we care about this (I'm not sure we do -- that's a question for someone with more knowledge of the history of Windows builds). We can probably disable this#pragma when doing a non-PGO build, but I don't see an obvious way to do it. I don't think the compiler gives us a preprocessor variable with the info (at least I can't find one), so we'd probably have to inject a variable from the build system. Anyway, that's a problem for tomorrow for me.

@zooba
Copy link
Member

FYI,pyproject.props is where you'll want to add it. You'll see examples of conditionalPreprocessorDefinition forPy_NOGIL, and the condition should beCondition="$(SupportPGO) and ($(Configuration) == 'PGInstrument' or $(Configuration) == 'PGUpdate')".

I'd suggest_Py_USING_PGO as a name, unless there's something already being used via configure, in which case copy that.

@mdboommdboom requested a review froma team as acode ownerNovember 8, 2023 13:25
@mdboom
Copy link
ContributorAuthor

mdboom commentedNov 8, 2023
edited
Loading

I have updated this to only disable the optimization when doing a PGO build.

@zooba's suggestion of only doing this during the PGInstrument and PGUpdate phases doesn't work. It's actually the final Release phase that fails, and having them behave differently reintroduces the original compiler error. So in this case_Py_USING_PGO is true for all of the phases of a PGO build.

EDIT: I take that back -- with a clean build this works, and is simpler.

Copy link
Member

@gvanrossumgvanrossum left a comment

Choose a reason for hiding this comment

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

LGTM. Let me know when you're ready for this to be merged.

@mdboom
Copy link
ContributorAuthor

@gvanrossum: As far as I know this is ready, but maybe@zooba should have one more quick look.

@gvanrossum
Copy link
Member

I'm just going to merge it, it looks great.

@gvanrossumgvanrossumenabled auto-merge (squash)November 9, 2023 18:30
@gvanrossumgvanrossum merged commitbc12f79 intopython:mainNov 9, 2023
aisk pushed a commit to aisk/cpython that referenced this pull requestFeb 11, 2024
…SVC for PGO (python#111794)In PGO mode, this function caused a compiler error in MSVC.It turns out that optimizing for space only save the day, and is even faster.However, without PGO, this is neither necessary nor slower.
Glyphack pushed a commit to Glyphack/cpython that referenced this pull requestSep 2, 2024
…SVC for PGO (python#111794)In PGO mode, this function caused a compiler error in MSVC.It turns out that optimizing for space only save the day, and is even faster.However, without PGO, this is neither necessary nor slower.
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@markshannonmarkshannonmarkshannon left review comments

@gvanrossumgvanrossumgvanrossum approved these changes

@zoobazoobaAwaiting requested review from zooba

Assignees

No one assigned

Labels

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

5 participants

@mdboom@zooba@brandtbucher@gvanrossum@markshannon

[8]ページ先頭

©2009-2026 Movatter.jp