Skip to content

gh-100758: Refactor initialisation of frame headers into a single function (_PyFrame_Initialize) #100759

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
merged 5 commits into from
Jan 6, 2023

Conversation

iritkatriel
Copy link
Member

@iritkatriel iritkatriel commented Jan 4, 2023

Fixes #100758.

This is version 1 (with an arg telling where to start NULLing).

@carljm
Copy link
Member

carljm commented Jan 5, 2023

This looks OK to me, pending benchmarking. It means we will do one or two extra NULL writes to localsplus entries that are about to get written again with a value, in some hot paths that use . (This could be avoided with an extra integer argument.) Will wait and see what Mark thinks.

Copy link
Member

@markshannon markshannon left a comment

Choose a reason for hiding this comment

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

I like @carljm 's suggestion of passing in the index of the first local to NULL out.

I'd like to see the benchmarks.
If benchmarking shows no difference, then go with this approach as it is the cleanest.

@iritkatriel iritkatriel changed the title gh-100758: Refactor initialisation of frame headers into a single function (_PyFrame_InitializeHeader) gh-100758: Refactor initialisation of frame headers into a single function (_PyFrame_Initialize) Jan 5, 2023
@iritkatriel
Copy link
Member Author

iritkatriel commented Jan 5, 2023

These are benchmarking results from before I changed to pass the int arg:
https://github.com/faster-cpython/benchmarking-public/blob/main/results/bm-20230104-3.12.0a3%2B-e73d0cf/bm-20230104-linux-x86_64-iritkatriel-InitializeHeader-3.12.0a3+-e73d0cf-vs-base.md

(overall x0 faster).

I will rerun with the last change.

Copy link
Member

@carljm carljm left a comment

Choose a reason for hiding this comment

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

Looks great to me, presuming the second benchmark run will also show no impact.

@iritkatriel
Copy link
Member Author

iritkatriel commented Jan 5, 2023

@markshannon
Copy link
Member

Might as well go with the faster version.

@iritkatriel
Copy link
Member Author

You don't think this is noise?

@iritkatriel
Copy link
Member Author

I created #100775 with the arg removed, will run the benchmark one more time.

@iritkatriel
Copy link
Member Author

I created #100775 with the arg removed, will run the benchmark one more time.

Now that one came 0x0% slower as well. I think this is noise, we should just go with whichever.

I'm off to my humus fest soon. Feel free to merge this or #100775 and close the other.

@iritkatriel
Copy link
Member Author

@markshannon
Copy link
Member

I'm merging this, as the performance difference with this and #100775 is in the noise, and this seems the more efficient design.

@markshannon markshannon merged commit 15c4478 into python:main Jan 6, 2023
@iritkatriel iritkatriel deleted the InitializeHeader branch July 25, 2023 18:07
@iritkatriel iritkatriel restored the InitializeHeader branch July 25, 2023 18:08
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.

Refactor initialisation of frame headers into a single function
4 participants