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 — Remove `eval_breaker` and `kwnames` local variables from interpreter definition. · Issue #104580 · python/cpython

Remove eval_breaker and kwnames local variables from interpreter definition. #104580

New issue
Copy link
New issue
Copy link
Closed
Closed
Remove eval_breaker and kwnames local variables from interpreter definition.#104580
Copy link
Assignees
brandtbucher
Labels
performancePerformance or resource usagePerformance or resource usage

Description

@markshannon
markshannon
opened on May 17, 2023
Issue body actions

Currently there are quite a few local variables in PyEval_EvalDefault().
Each of these is:

  • A candidate for register allocation, confusing the compiler.
  • Potentially adds extra state to the interpreter
  • Adds complexity to automatically generated interpreters and compilers

The local variables break down into three classes:

  • The state of the interpreter
  • Transient values
  • Values for gathering stats, debugging, etc.

The last category are not present in release builds, so we can ignore those.
The transient values, like opcode and oparg are an artifact of the dispatching mechanism and will be absent for compiled code, or different for a different interpreter.

It is the remaining values that matter.
Each of these will consume a register in compiled code, and need to kept in sync where there is redundancy.
The current values are:

  • next_instr -- The VM instruction pointer
  • frame -- Pointer to the current frame
  • stackpointer -- Pointer to the top of stack
  • tstate -- Pointer to the current thread
  • eval_break -- Pointer to the eval-breaker
  • kwnames -- Pointer to the keyword names, if any for the next call

next_instr and frame are fundamental to VM operation.

Hypothetically stackpointer can be eliminated by a compiler, and tstate can be eliminated by some clever stack arrangement, or using thread-local storage. However, these approaches are complex and may not be worthwhile.

eval_breaker can easily be eliminated, as it is redundant. eval_breaker == tstate->interp->eval_breaker

kwnames is logically transient, in that it is only valid between the KW_NAMES instruction and a CALL. However from the very local view of a single instruction it is effectively an interpreter-wide value.
It can removed by pushing the kwnames to the stack, but that is likely to cause a slowdown. We need to experiment.

Linked PRs

  • GH-104580: No local eval breaker #104581
  • GH-104580: Put eval_breaker back at the start of the interpreter state. #107383
Reacted by Maurice
Reacted by sunmy2019

Activity

  1. markshannon
    added
    performancePerformance or resource usagePerformance or resource usage
    on May 17, 2023
  2. markshannon
    assigned
    brandtbucher
    on May 17, 2023
  3. markshannon
    added a commit that references this issue on May 18, 2023

    GH-104580: Don't cache eval breaker in interpreter (GH-104581)

    68b5f08
  4. carljm
    added a commit that references this issue on May 18, 2023

    Merge branch 'main' into nestedcomps

    54095f0
  5. markshannon
    added a commit that references this issue on Jul 28, 2023

    GH-104580: Put `eval_breaker` back at the start of the interpreter st…

    a1b6795
  6. markshannon commented on Oct 24, 2023

    @markshannon
    markshannon
    on Oct 24, 2023
    MemberAuthor
    More actions

    Fixed by #109300

  7. markshannon
    closed this as completedon Oct 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @brandtbucher
    brandtbucher

Labels

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.