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 — bpo-46841: Move the cache for `LOAD_GLOBAL` inline. by markshannon · Pull Request #31575 · python/cpython

Conversation

@markshannon

@markshannon markshannon commented Feb 25, 2022 •
edited by bedevere-bot
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

Also removes duplication of the _PyOpcode_InlineCacheEntries table.

https://bugs.python.org/issue46841

Sorry, something went wrong.

Uh oh!

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

All reactions
markshannon added 7 commits February 18, 2022 14:50
@markshannon
Experiment: Make 'inline' cache for LOAD_GLOBAL actually inline.
a209634
@markshannon
Emit cache entry space in assembler.
8ceabb5
@markshannon
Merge main and fix duplication of _PyOpcode_InlineCacheEntries table.
c8e38a3
@markshannon
Use native endianness for 32 bit cache entries.
98f73a1
@markshannon
Remove unused code.
87b63f9
@markshannon
Add news
cca4d6b
@markshannon
Fix up test_dis
26d0d70
@bedevere-bot bedevere-bot added the awaiting core review label Feb 25, 2022
@the-knights-who-say-ni the-knights-who-say-ni added the CLA signed label Feb 25, 2022
@markshannon markshannon added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Feb 25, 2022
@bedevere-bot

bedevere-bot commented Feb 25, 2022

Copy link
Copy Markdown

🤖 New build scheduled with the buildbot fleet by @markshannon for commit 26d0d70 🤖

If you want to schedule another build, you need to add the ":hammer: test-with-buildbots" label again.

All reactions

Sorry, something went wrong.

Uh oh!

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

@bedevere-bot bedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Feb 25, 2022
markshannon added 3 commits February 25, 2022 15:34
@markshannon
Restore specialization of LOAD_GLOBAL.
c49f156
@markshannon
Turn off test_dis test output generation.
f65ae9f
@markshannon
Merge branch 'main' into inline-cache-load-globals
054fcf6
@markshannon

markshannon commented Feb 25, 2022

Copy link
Copy Markdown
Member Author

Performance is underwhelming.
Not surprising, given that we are duplicating the cache and still having to handle the old caches.

What is notable is that the number of EXTENDED_ARG instructions more than doubles from ~0.3% to ~0.7%.

All reactions

Sorry, something went wrong.

Uh oh!

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

@brandtbucher

brandtbucher commented Feb 25, 2022

Copy link
Copy Markdown
Member

Performance is underwhelming.
Not surprising, given that we are duplicating the cache and still having to handle the old caches.

Yeah, I suspect we may not see a ton of payoff until we convert most/all of the caches.

All reactions

Sorry, something went wrong.

Uh oh!

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

brandtbucher
brandtbucher requested changes Feb 25, 2022
View reviewed changes

@brandtbucher brandtbucher 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.

A few things:

  • The magic number needs to be bumped every time we do this.
  • I thought we decided to use _Py_CODEUNIT everywhere you're using uint16_t now (it may also be worth adding _Py_TWOCODEUNITS and _Py_FOURCODEUNITS aliases for uint32_t and uintptr_t, respectively).

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread Include/internal/pycore_code.h Resolved

Uh oh!

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

Comment thread Tools/scripts/generate_opcode_h.py Resolved

Uh oh!

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

Comment thread Python/ceval.c Resolved

Uh oh!

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

Comment thread Python/ceval.c Resolved

Uh oh!

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

Comment thread Python/specialize.c Resolved

Uh oh!

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

Comment thread Python/specialize.c Resolved

Uh oh!

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

@bedevere-bot bedevere-bot removed the awaiting core review label Feb 25, 2022
@bedevere-bot

bedevere-bot commented Feb 25, 2022

Copy link
Copy Markdown

When you're done making the requested changes, leave the comment: I have made the requested changes; please review again.

All reactions

Sorry, something went wrong.

Uh oh!

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

@bedevere-bot bedevere-bot added the awaiting changes label Feb 25, 2022
@markshannon
Clean up messy merge.
c6c0527
@markshannon

markshannon commented Feb 28, 2022

Copy link
Copy Markdown
Member Author

A few things:

* The magic number needs to be bumped every time we do this.

👍

* I thought we decided to use `_Py_CODEUNIT` everywhere you're using `uint16_t` now (it may also be worth adding `_Py_TWOCODEUNITS` and `_Py_FOURCODEUNITS` aliases for `uint32_t` and `uintptr_t`, respectively).

Hmm, I'd prefer not. Versions, for example, are 32 bit value, not 2 code units. If the size of the _Py_CODEUNIT were to change, we would still want versions to be 32 bit numbers.
So, the structs should be defined in terms of code units, but the read/write helpers should be in terms of width.

Maybe we should give up on the pretense that the size of the code unit can be easily changed, and replace _Py_CODEUNIT with the standard type uint16_t?

All reactions

Sorry, something went wrong.

Uh oh!

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

markshannon added 3 commits February 28, 2022 11:25
@markshannon
Address review comments.
0a853af
@markshannon
Bump version number.
92a4b04
@markshannon
Merge branch 'main' into inline-cache-load-globals
138b2d6
@markshannon
markshannon merged commit 4558af5 into python:main Feb 28, 2022
@bedevere-bot bedevere-bot removed the awaiting changes label Feb 28, 2022
brandtbucher
brandtbucher reviewed Feb 28, 2022
View reviewed changes
Comment thread Lib/importlib/_bootstrap_external.py
Comment on lines -390 to +391
# Python 3.11a5 3481 (Use inline CACHE instructions)
# Python 3.11a5 3482 (Use inline caching for UNPACK_SEQUENCE)
# Python 3.11a5 3481 (Use inline cache for BINARY_OP)
# Python 3.11a5 3482 (Use inline caching for UNPACK_SEQUENCE and LOAD_GLOBAL)

@brandtbucher brandtbucher Feb 28, 2022 •
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.

Hm, looks like the magic number wasn't actually changed... bad merge?

Sorry, something went wrong.

Uh oh!

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

All reactions

@markshannon markshannon Feb 28, 2022

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.

I figured we didn't need more than one version number per day.

Sorry, something went wrong.

Uh oh!

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

All reactions

@markshannon markshannon Feb 28, 2022

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.

#31618 has another version number bump.

Sorry, something went wrong.

Uh oh!

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

All reactions

@brandtbucher brandtbucher Feb 28, 2022

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.

Ah, I see what you did now. Thanks for clarifying.

Sorry, something went wrong.

Uh oh!

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

All reactions
@brandtbucher brandtbucher mentioned this pull request Mar 2, 2022
Inline caching faster-cpython/ideas#310
Closed
21 of 26 tasks
@brandtbucher brandtbucher mentioned this pull request Apr 10, 2022
Inline bytecode caches #90997
Closed
@markshannon
markshannon deleted the inline-cache-load-globals branch September 26, 2023 12:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@brandtbucher brandtbucher brandtbucher requested changes

Uh oh!

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

Assignees

No one assigned

Labels

None yet

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.

4 participants

@markshannon @bedevere-bot @brandtbucher @the-knights-who-say-ni
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.