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

Get the add-opcodes branch ready to merge upstream. #185

Closed
3 tasks done
gvanrossum opened this issue Dec 15, 2021 · 7 comments
Closed
3 tasks done

Get the add-opcodes branch ready to merge upstream. #185

gvanrossum opened this issue Dec 15, 2021 · 7 comments
Assignees

Comments

@gvanrossum
Copy link
Collaborator

gvanrossum commented Dec 15, 2021

The branch is here (a bit stale): https://github.com/gvanrossum/cpython/tree/add-opcodes

There's also this PR (also stale): python/cpython#25090

@brandtbucher The note said "convert to issue and assign to Brandt" so that's what I'm doing. But somehow I've forgotten context from our meeting -- do you recall? IIRC someone (@markshannon?) said "actually we should probably do that even though it didn't seem to move the benchmark numbers." But this version seems to only add an ADD_INT opcode, which seems redundant given your work on BINARY_OP. So maybe I'm just making a mess?

@gramster gramster moved this to In Progress in Fancy CPython Board Jan 10, 2022
@brandtbucher brandtbucher moved this from In Progress to Todo in Fancy CPython Board Jan 31, 2022
@markshannon
Copy link
Member

Our current stats show that the LOAD_CONST BINARY_OP_ADD_INT pair (which is equivalent to AD_INT) is about 0.6% of the execution count.

So, while there might be some benefit to this, it wouldn't be much.
I'm inclined to abandon this.

@brandtbucher
Copy link
Member

I have a branch laying around somewhere. Let me catch it up with main and benchmark to confirm your intuition.

@markshannon
Copy link
Member

I assume that this isn't happening.

We should probably implement ADD_INT, if only to shrink the code object size, but let's make a separate issue that.

@gvanrossum gvanrossum closed this as not planned Won't fix, can't repro, duplicate, stale Mar 17, 2023
@github-project-automation github-project-automation bot moved this from Todo to Done in Fancy CPython Board Mar 17, 2023
@brandtbucher
Copy link
Member

Update: the benchmarking results are underwhelming.

Branch here, for anyone curious.

@gvanrossum
Copy link
Collaborator Author

Sorry, the thing that Mark and I agreed on wasn't happening was a much older version of this idea (the branch is deleted).

We might actually revive part of it if we get serious about reducing the code object size, since this would remove the need to have small ints in co_consts.

Regarding your branch, maybe the benchmark is slower because it has several conditional branches? I assume in the vast majority of cases where the code says x + 1, x is an int, so at the very least the check for PyLong ought to be first, and probably the float code isn't worth it (or could be done using a specialization).

@brandtbucher
Copy link
Member

Good observation! I'll re-run with just the int fast-paths. Maybe if we like the results, we could then explore adding proper specializations.

@brandtbucher
Copy link
Member

A little better, but not much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

No branches or pull requests

3 participants