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 — performance regression in `PyType_GetModuleByDef` on free-threaded build · Issue #148907 · python/cpython

performance regression in PyType_GetModuleByDef on free-threaded build #148907

New issue
Copy link
New issue
Copy link
Closed
Closed
performance regression in PyType_GetModuleByDef on free-threaded build#148907
Copy link
Labels
performancePerformance or resource usagePerformance or resource usagetopic-free-threading

Description

@kumaraditya303
kumaraditya303
opened on Apr 23, 2026
Issue body actions

Bug report

On the free-threaded build, thread_local_read in Tools/ftscalingbench/ftscalingbench.py regressed sharply between 3.15.0a8 and main. git bisect between v3.15.0a8 and 04fd103713a identifies 8923ca4 as the first bad commit.

Measurements (10 threads, Apple Silicon, free-threaded)

Python thread_local_read
3.14.4t 3.6× faster
3.15.0a8 3.7× faster
parent of 8923ca4 3.7× faster
8923ca4 11.9× slower
main @ 04fd103 10.8× slower

Root cause

The commit changed PyType_GetModuleByDef (Objects/typeobject.c:5892) which added a incref/decref which causes significant ref counting contention.

// before: genuinely borrowed, no refcount ops
return borrow_module_by_token(type, def);

// after: Py_NewRef inside PyType_GetModuleByToken, then immediate Py_XDECREF
PyObject *mod = PyType_GetModuleByToken(type, def);
Py_XDECREF(mod);
return mod;

Linked PRs

  • gh-148907: fix performance regression in PyType_GetModuleByDef on free-threading #148908

Activity

  1. kumaraditya303
    added
    performancePerformance or resource usagePerformance or resource usage
    topic-free-threading
    on Apr 23, 2026
  2. kumaraditya303
    added a commit that references this issue on Apr 23, 2026

    gh-148907: fix performance regression in `PyType_GetModuleByDef` on f…

    29917d5
  3. kumaraditya303
    closed this as completedon Apr 23, 2026
  4. ljfp
    added a commit that references this issue on Apr 25, 2026

    pythongh-148907: fix performance regression in `PyType_GetModuleByDef…

    71bd452
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

    performancePerformance or resource usagePerformance or resource usagetopic-free-threading

    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.