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 — Lower `BEFORE_WITH` and `BEFORE_ASYNC_WITH` to attribute lookups and calls. · Issue #120507 · python/cpython

Lower BEFORE_WITH and BEFORE_ASYNC_WITH to attribute lookups and calls. #120507

New issue
Copy link
New issue
Copy link
Closed
Closed
Lower BEFORE_WITH and BEFORE_ASYNC_WITH to attribute lookups and calls.#120507
Copy link

Description

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

With the JIT and better tier 2 optimizations, effective specialization is becoming more important that plain speed in tier 1.

BEFORE_WITH and BEFORE_ASYNC_WITH could be specialized, but they are bulky and won't optimize well in tier 2.
Instead, we should lower them to attribute lookups and calls which can then be optimized.
We should add a LOAD_SPECIAL instruction for loading dunder methods and replace BEFORE_WITH as follows:

    COPY 1
    LOAD_SPECIAL __enter__ + NULL|self
    SWAP 3
    LOAD_SPECIAL __exit__
    SWAP 3
    CALL 0

Likewise for BEFORE_ASYNC_WITH.

Even without any specialization of LOAD_SPECIAL, the CALL will be specialized and the JIT can eliminate the COPY and SWAPs.

Linked PRs

  • GH-120507: Lower the BEFORE_WITH and BEFORE_ASYNC_WITH instructions. #120640
  • gh-120507: Double WASI memory #120648

Activity

  1. markshannon commented on Jun 17, 2024

    @markshannon
    markshannon
    on Jun 17, 2024
    MemberAuthor
    More actions

    No performance impact
    https://github.com/faster-cpython/benchmarking-public/tree/main/results/bm-20240617-3.14.0a0-68df0a5

  2. vstinner
    added 2 commits that reference this issue on Jun 17, 2024

    pythongh-120507: Double WASI memory

    24bb60d

    gh-120507: Double WASI memory (#120648)

    6acf777
  3. markshannon
    added a commit that references this issue on Jun 18, 2024

    GH-120507: Lower the `BEFORE_WITH` and `BEFORE_ASYNC_WITH` instructio…

    9cefcc0
  4. brandtbucher
    closed this as completedon Jun 18, 2024
  5. picnixz
    added a commit that references this issue on Jun 19, 2024

    pythonGH-120507: Lower the `BEFORE_WITH` and `BEFORE_ASYNC_WITH` inst…

    d3107d4
  6. mrahtz
    added 2 commits that reference this issue on Jun 30, 2024

    pythongh-120507: Double WASI memory (python#120648)

    c565073

    pythonGH-120507: Lower the `BEFORE_WITH` and `BEFORE_ASYNC_WITH` inst…

    81ea6ea
  7. estyxx
    added 2 commits that reference this issue on Jul 17, 2024

    pythongh-120507: Double WASI memory (python#120648)

    7b46d07

    pythonGH-120507: Lower the `BEFORE_WITH` and `BEFORE_ASYNC_WITH` inst…

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      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.