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 — Dataflow analysis in the compiler to avoid runtime NULL checks · Issue #93143 · python/cpython

Dataflow analysis in the compiler to avoid runtime NULL checks #93143

New issue
Copy link
New issue
Copy link
Closed
#93498
Closed
Dataflow analysis in the compiler to avoid runtime NULL checks#93143
#93498
Copy link
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)performancePerformance or resource usagePerformance or resource usagetype-featureA feature request or enhancementA feature request or enhancement

Description

@sweeneyde
sweeneyde
opened on May 23, 2022
Issue body actions

LOAD_FAST accounts for 14.6% of all bytecodes executed. Including superinstructions brings this up to 14.6+4.7+4.6+2.4+0.9 = 27.1%

cpython/Python/ceval.c

Lines 1864 to 1872 in 202ed25

TARGET(LOAD_FAST) {
PyObject *value = GETLOCAL(oparg);
if (value == NULL) {
goto unbound_local_error;
}
Py_INCREF(value);
PUSH(value);
DISPATCH();
}

We can turn this NULL-check into an assertion in many cases, where we can determine at compile time that the local variable is already initialized. Preliminary tests show that almost all LOAD_FAST instructions can be statically analyzed to be loading already-initialized variables.

The one twist is handling del frame.f_locals["x"] or frame.f_lineno = 17, where previously-safe loads could become unsafe. For now, we can just replace all the LOAD_FAST (no null check) with LOAD_FAST_CHECK in that particular code object.

See also faster-cpython/ideas#306

  • PR: GH-93143: Don't turn LOAD_FAST into LOAD_FAST_CHECK #99075

Activity

  1. sweeneyde
    added
    type-featureA feature request or enhancementA feature request or enhancement
    performancePerformance or resource usagePerformance or resource usage
    interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)
    on May 23, 2022
  2. sweeneyde
    added a commit that references this issue on May 31, 2022

    gh-93143: Avoid NULL check in LOAD_FAST based on analysis in the comp…

    f425f3b
  3. sweeneyde commented on Jun 1, 2022

    @sweeneyde
    sweeneyde
    on Jun 1, 2022
    MemberAuthor
    More actions

    TODO: documentation

  4. sweeneyde
    closed this as completedin #93498on Jun 5, 2022
  5. brandtbucher
    added a commit that references this issue on Nov 8, 2022

    GH-93143: Don't turn LOAD_FAST into LOAD_FAST_CHECK (GH-99075)

    c7065ce
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

    interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)performancePerformance or resource usagePerformance or resource usagetype-featureA feature request or enhancementA feature request or enhancement

    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.