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 — Split micro-ops that have different behavior depending on low bit of oparg. · Issue #115457 · python/cpython

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

New issue
Copy link
New issue
Copy link
Closed
Closed
Split micro-ops that have different behavior depending on low bit of oparg. #115457
Copy link
Assignees
markshannon
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)performancePerformance or resource usagePerformance or resource usage

Description

@markshannon
markshannon
opened on Feb 14, 2024
Issue body actions

Splitting these micro-ops will improve performance by reducing the number of branches, the size of code generated, and the number of holes in the JIT stencils. There is no real downside; the increase in complexity at runtime is negligible and there isn't much increased complexity in the tooling.

Taking _LOAD_ATTR_INSTANCE_VALUE as an example, as it is the dynamically most common.

    op(_LOAD_ATTR_INSTANCE_VALUE, (index/1, owner -- attr, null if (oparg & 1))) {
        ...

can be split into

    op(_LOAD_ATTR_INSTANCE_VALUE_0, (index/1, owner -- attr)) {
        assert((oparg & 1) == 0);
        ...

and

    op(_LOAD_ATTR_INSTANCE_VALUE_1, (index/1, owner -- attr, null)) {
        assert((oparg & 1) == 1);
        ...

Each of these is simpler, thus smaller and faster than the base version.
We can always choose one of the two split version when projecting the trace, so we don't need an implementation of the base version at all. This means that the tier 2 interpreter and stencils aren't much bigger than before.

Linked PRs

  • GH-115457: Support splitting and replication of micro ops.  #115558

Activity

  1. markshannon
    added
    performancePerformance or resource usagePerformance or resource usage
    on Feb 14, 2024
  2. erlend-aasland
    added
    interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)
    on Feb 14, 2024
  3. markshannon
    self-assigned this
    on Feb 15, 2024
  4. markshannon commented on Feb 16, 2024

    @markshannon
    markshannon
    on Feb 16, 2024
    MemberAuthor
    More actions

    It makes sense to do replication at the same time as splitting.

    By replication, I mean creating a copy of the replicated uop for each oparg in a given set.
    This is not such an obvious win, as we need multiple stencils, but each stencil can be significantly smaller than the original.

    The best example is _INIT_CALL_PY_EXACT_ARGS which has a stencil of 753 bytes, whereas the stencil for _INIT_CALL_PY_EXACT_ARGS_0 is only 308 bytes, a ~60% saving.

    _LOAD_FAST shows a smaller saving, from 45 bytes down to 31 for LOAD_FAST_0.

    Reacted by stonebig and Sergey Miryanov
  5. markshannon
    added a commit that references this issue on Feb 20, 2024

    GH-115457: Support splitting and replication of micro ops. (GH-115558)

    626c414
  6. markshannon
    closed this as completedon Feb 21, 2024
  7. woodruffw
    added a commit that references this issue on Mar 4, 2024

    pythonGH-115457: Support splitting and replication of micro ops. (pyt…

    12ba88b
  8. diegorusso
    added a commit that references this issue on Apr 17, 2024

    pythonGH-115457: Support splitting and replication of micro ops. (pyt…

    567e3ca
  9. LukasWoodtli
    added a commit that references this issue on Jan 22, 2025

    pythonGH-115457: Support splitting and replication of micro ops. (pyt…

    c863aee
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @markshannon
    markshannon

Labels

interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)performancePerformance or resource usagePerformance or resource usage

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402520 — 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.