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

Specialize BINARY_OP by refcount and by type of operands #117581

Open
markshannon opened this issue Apr 6, 2024 · 1 comment
Open

Specialize BINARY_OP by refcount and by type of operands #117581

markshannon opened this issue Apr 6, 2024 · 1 comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement

Comments

@markshannon
Copy link
Member

markshannon commented Apr 6, 2024

Instead of the fairly limited ad-hoc specialization we currently use, we should specialize BINARY_OP by refcount and use table lookup to specialize by type.

Doing so would have the following advantages:

  • Increased specialization from ~70% to over 95%
  • Potential for large performance improvement in tier 2
  • Makes it easy to incorporate BINARY_SUBSCR into BINARY_OP freeing up several tier 1 opcodes
  • Can use similar techniques for CONTAINS_OP and COMPARE_OP to free up more tier 1 opcodes

I expect the overall performance impact on tier 1 will be negligible. Maybe a little bit faster, maybe a little bit slower.
The improved specialized will (I expect) largely cancel out the degraded performance for the most common operations.

See for faster-cpython/ideas#662 detailed analysis and faster-cpython/ideas#660 for the related tier 2 optimization

Linked PRs

@encukou
Copy link
Member

encukou commented Jan 23, 2025

The PR was abandoned in favour of #128722. Should this be closed?

@picnixz picnixz added type-feature A feature request or enhancement interpreter-core (Objects, Python, Grammar, and Parser dirs) labels Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

3 participants