GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GH-115457: Support splitting and replication of micro ops. by markshannon · Pull Request #115558 · python/cpython

Conversation

@markshannon

@markshannon markshannon commented Feb 16, 2024 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Adds the split and replicate(N) annotations

split splits uops into two depending on the low bit of the oparg. This removes a few jumps from uops like _LOAD_ATTR_INSTANCE_VALUE.

replicate(N) replicates the original uop for each oparg in range(N). This is particularly valuable for uops that loop over oparg, but it is also useful to inline the oparg at build time rather than when patching.

  • Issue: Split micro-ops that have different behavior depending on low bit of oparg.  #115457

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
markshannon added 6 commits February 14, 2024 21:00
@markshannon
Split micro-ops if behavior depends on oparg&1
2e5a158
@markshannon
Don't generate C code for split uops
d879778
@markshannon
Add replicate annotation
472a3d6
@markshannon
Do not emit abstract interpreter code for replica uops
97cf57e
@markshannon
Address review comments
f99858c
@markshannon
Merge branch 'main' into split-on-oparg-1
9ec72e5
@markshannon
markshannon requested review from Fidget-Spinner and gvanrossum as code owners February 16, 2024 12:07
@bedevere-app bedevere-app Bot added the awaiting core review label Feb 16, 2024
@bedevere-app bedevere-app Bot mentioned this pull request Feb 16, 2024
Split micro-ops that have different behavior depending on low bit of oparg. #115457
Closed
Fidget-Spinner
Fidget-Spinner reviewed Feb 16, 2024
View reviewed changes
Comment thread Python/tier2_redundancy_eliminator_cases.c.h Resolved

Uh oh!

There was an error while loading. Please reload this page.

@Fidget-Spinner

Fidget-Spinner commented Feb 16, 2024

Copy link
Copy Markdown
Member

Also, I like how clean this is in the DSL!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@markshannon

markshannon commented Feb 16, 2024

Copy link
Copy Markdown
Member Author

about 1% faster

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@markshannon markshannon added the skip news label Feb 16, 2024
mdboom
mdboom reviewed Feb 16, 2024
View reviewed changes
Comment thread Python/optimizer.c
else if (oparg < _PyUop_Replication[opcode]) {
buffer[pc].opcode = opcode + oparg + 1;
}
else if (opcode == _JUMP_TO_TOP || opcode == _EXIT_TRACE) {

@mdboom mdboom Feb 16, 2024

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Maybe use op_is_end here?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@markshannon markshannon Feb 16, 2024

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

It's a static function in another file.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@gvanrossum gvanrossum Feb 17, 2024

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

We'll leave it up to Ken Jin to turn it into a macro or static inline in a header. (Because he's adding another opcode that could end the list of opcodes, a new JUMP variant.)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Fidget-Spinner
Fidget-Spinner reviewed Feb 16, 2024
View reviewed changes

@Fidget-Spinner Fidget-Spinner left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Looks good in general, just one minor comment.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Tools/cases_generator/analyzer.py
properties=compute_properties(op),
)
if effect_depends_on_oparg_1(op) and "split" in op.annotations:
result.properties.oparg_and_1 = True

@Fidget-Spinner Fidget-Spinner Feb 16, 2024

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

For code consistency, shouldn't this be compute_properties?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@markshannon markshannon Feb 19, 2024

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Shouldn't what be compute_properties?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@Fidget-Spinner Fidget-Spinner Feb 19, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Woops I meant shouldn't this be computed in compute_properties ?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

markshannon reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

@markshannon markshannon Feb 19, 2024

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

The oparg_and_1 property only applies to the base uop, not the replicas as their behavior does not depend on oparg & 1. compute_properties computes the properties from the definition only, so we would need to modify oparg_and_1 anyway.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
gvanrossum
gvanrossum approved these changes Feb 17, 2024
View reviewed changes

@gvanrossum gvanrossum left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Cool!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Python/optimizer.c
else if (oparg < _PyUop_Replication[opcode]) {
buffer[pc].opcode = opcode + oparg + 1;
}
else if (opcode == _JUMP_TO_TOP || opcode == _EXIT_TRACE) {

@gvanrossum gvanrossum Feb 17, 2024

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

We'll leave it up to Ken Jin to turn it into a macro or static inline in a header. (Because he's adding another opcode that could end the list of opcodes, a new JUMP variant.)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Python/executor_cases.c.h Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Tools/cases_generator/tier2_generator.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting core review labels Feb 17, 2024
Fidget-Spinner
Fidget-Spinner approved these changes Feb 19, 2024
View reviewed changes
@markshannon
markshannon merged commit 626c414 into python:main Feb 20, 2024
@bedevere-app bedevere-app Bot removed the awaiting merge label Feb 20, 2024
@encukou encukou mentioned this pull request Feb 20, 2024
GH-112354: Initial implementation of warm up on exits and trace-stitching #114142
Merged
@encukou

encukou commented Feb 20, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

The refleaks buildbot failed on test.test_capi.test_opt.TestUops.test_confidence_score. Likely causes: GH-114142, GH-115558, or GH-115688
I'll investigate later if it's not fixed; you probably have more context.

Edit: it's likely to be fixed in #115728

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@encukou encukou mentioned this pull request Feb 20, 2024
gh-115687: Split up guards from COMPARE_OP #115688
Merged
@markshannon
markshannon deleted the split-on-oparg-1 branch February 21, 2024 16:19
woodruffw pushed a commit to woodruffw-forks/cpython that referenced this pull request Mar 4, 2024
@markshannon @woodruffw
pythonGH-115457: Support splitting and replication of micro ops. (pyt…
12ba88b
…honGH-115558)
diegorusso pushed a commit to diegorusso/cpython that referenced this pull request Apr 17, 2024
@markshannon @diegorusso
pythonGH-115457: Support splitting and replication of micro ops. (pyt…
567e3ca
…honGH-115558)
LukasWoodtli pushed a commit to LukasWoodtli/cpython that referenced this pull request Jan 22, 2025
@markshannon @LukasWoodtli
pythonGH-115457: Support splitting and replication of micro ops. (pyt…
c863aee
…honGH-115558)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@mdboom mdboom mdboom left review comments
@gvanrossum gvanrossum gvanrossum approved these changes
@Fidget-Spinner Fidget-Spinner Fidget-Spinner approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

skip news

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@markshannon @Fidget-Spinner @encukou @mdboom @gvanrossum
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.