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 — Tail calling interpreter for MSVC · Issue #139922 · python/cpython

Tail calling interpreter for MSVC #139922

New issue
Copy link
New issue
Copy link
Closed
Closed
Tail calling interpreter for MSVC#139922
Copy link
Labels
OS-windowsinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-featureA feature request or enhancementA feature request or enhancement

Description

@Fidget-Spinner
Fidget-Spinner
opened on Oct 10, 2025
Issue body actions

Feature or enhancement

Proposal:

We should get tail calling interpreter support for MSVC.
The latest up-to-date figures for the tail calling interpreter are:

  • 1-3% pyperformance faster on Ubuntu x64
  • 4-5% pyperformance faster on macOS AArch64
  • The last benchmarks for the tail calling interpreter on Windows MSVC reported a 17% speedup on pyperformance.

On Windows, the performance isn't easy to measure because pyperf system tune doesn't work on there. However, on a best-effort quiet system and some benchmarks from pyperformance on my system, these are my results:

Mean +- std dev: [spectralnorm_tc_no] 146 ms +- 1 ms -> [spectralnorm_tc] 98.3 ms +- 1.1 ms: 1.48x faster
Mean +- std dev: [nbody_tc_no] 145 ms +- 2 ms -> [nbody_tc] 107 ms +- 2 ms: 1.35x faster
Mean +- std dev: [bm_django_template_tc_no] 26.9 ms +- 0.5 ms -> [bm_django_template_tc] 22.8 ms +- 0.4 ms: 1.18x faster
Mean +- std dev: [xdsl_tc_no] 64.2 ms +- 1.6 ms -> [xdsl_tc] 56.1 ms +- 1.5 ms: 1.14x faster

Note that I had to apply a 2-line patch to fix xDSL for Python 3.15.

Nbody and spectralnorm are toy shootout benchmarks. xDSL is a new benchmark added that is a MLIR DSL library with written almost entirely in pure Python. I consider it a pure-Python large library not too far off from mypy (though it's obviously smaller). 14% faster for xDSL is massive. It's roughly half of the speedup we got in 3.11 with the specializing interpreter, and that was thousands of lines of code. This change in contrast will be just one PR. Django templating shows a big speedup too -- 18% faster.

This could not have been possible without help from the MSVC team. Specifically, I'd like to give a shoutout to Hulon Jenkins and the MSVC team in the patch notes when I land this.

I've discussed this during the Wednesday CHIPS meetings, and there was no opposition to the new set of changes required to get this working. The changes are minimal and mostly just involve adding correct restrict and scoping to things to tell MSVC a local variable doesn't escape. This should also benefit GCC and Clang in some fashion.

We require working CI before this is merged, so I am now waiting on GitHub actions or some other CI to get this working.

Very special shoutout as well to @chris-eibl who has been helping me with this on Windows.

Some other benefits: the TC on MSVC actually correctly "resets" the inlining heuristic on MSVC. This means eventually we can get rid of all the macros and ugly hacks we have to make the current interpreter faster on MSVC once we distribute the builds with tail calling. Example of a hack where we use macros over static inlines on MSVC just because of the interpreter loop breaking the inliniing heuristics of MSVC #121263

Possibility of a compiler bug this time

I doubt it, as MSVC has no computed goto, so it can't have the same bug as Clang that we bumped into the previous time.

Where are the perf gains coming from?

It's mainly the better inlining that we get from the tail calling interpreter, and elimination of double jumps vs the switch-case interpreter.

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

No response

Linked PRs

  • gh-139922: Tail calling for MSVC (VS 2026) #139962
  • GH-139922: Tail calling for MSVC (VS 2026) #143068
  • gh-139922: Add tail call for MSVC for whats new in 3.15 #143087
  • gh-139922: Link to results in MSVC tail calling 3.15 #143242
  • GH-139922: update 3.15 whatsnew: Windows 64-bit binaries now use the tail-calling interpreter #146391
  • gh-139922: always run MSVC 64-bit tail-calling CI #146570
  • GH-139922: add interpreter types to InternalDocs/interpreter.md #148035
  • GH-148047: Check early whether tail-calling is possible for MSVC builds on Windows #148036
Reacted by Sergey Miryanov
Reacted by Sergey Miryanov, Emma Smith, Mikhail Efimov, Daniel Hollas, Wulian233, Peter Bierma, Chris Eibl, Denis, Semyon Moroz and Sacul

Activity

  1. Fidget-Spinner
    added
    type-featureA feature request or enhancementA feature request or enhancement
    on Oct 10, 2025
  2. picnixz
    added
    OS-windows
    interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)
    on Oct 10, 2025
  3. winapiadmin
    marked Fail to build with tail cail optimization on Windows #141937 as a duplicate of this issue on Nov 25, 2025
  4. Fidget-Spinner
    added 2 commits that reference this issue on Dec 22, 2025

    GH-139922: Tail calling for MSVC (VS 2026) (GH-143068)

    be3c131

    gh-139922: Add tail call for MSVC for whats new in 3.15 (GH-143087)

    714037b
  5. chris-eibl commented on Dec 28, 2025

    @chris-eibl
    chris-eibl
    on Dec 28, 2025
    Member
    More actions

    Updated data for the final commit be3c13164 on Windows 11, AMD Ryzen 7 5800X:

    • MSC v.1950 from Visual Studio 2026 (18.1.1)
    • clang-cl 21.1.4
    • all builds are PGO builds
    • tc denotes tail calling builds
    Benchmark msvc.pgo2 msvc.pgo.tc
    Geometric mean (ref) 1.18x faster
    Benchmark msvc.pgo.tc clang.pgo.tc
    Geometric mean (ref) 1.06x faster
    Plot msvc.pgo2 vs msvc.pgo.tc

    Image

    Plot msvc.pgo.tc vs clang.pgo.tc

    Image

    Raw data and additional plots and tables for Haswell i5-4570 (Windows 10) and Ryzen 5 5500U (Windows 11) can be found here:

    https://gist.github.com/chris-eibl/fade55faaad97e2cd12f5587ac1f4aa0

  6. Fidget-Spinner
    added a commit that references this issue on Dec 28, 2025

    gh-139922: Link to results in MSVC tail calling in What's New 3.15 (G…

    23abbf1
  7. Fidget-Spinner
    closed this as completedon Jan 12, 2026
  8. thunder-coding
    added a commit that references this issue on Feb 15, 2026

    pythongh-139922: Link to results in MSVC tail calling in What's New 3…

    6854ce3
  9. hugovk
    added a commit that references this issue on Mar 27, 2026

    GH-139922: update 3.15 whatsnew: Windows 64-bit binaries now use the …

    2e64e36
  10. Fidget-Spinner
    added a commit that references this issue on Mar 30, 2026

    gh-139922: always run MSVC 64-bit tail-calling CI (GH-146570)

    76c554b
  11. maurycy
    added a commit that references this issue on Mar 30, 2026

    Merge remote-tracking branch 'upstream/main' into tachyon-ndjson-kole…

    6a0ea81
  12. Fidget-Spinner
    added a commit that references this issue on Apr 5, 2026

    GH-139922: add interpreter types to InternalDocs/interpreter.md (GH-1…

    668c572
  13. clin1234
    added 2 commits that reference this issue on Apr 16, 2026

    pythonGH-139922: update 3.15 whatsnew: Windows 64-bit binaries now us…

    2b530a3

    pythongh-139922: always run MSVC 64-bit tail-calling CI (pythonGH-146570

    3d0edcf
  14. ljfp
    added 3 commits that reference this issue on Apr 25, 2026

    pythonGH-139922: update 3.15 whatsnew: Windows 64-bit binaries now us…

    891bc4a

    pythongh-139922: always run MSVC 64-bit tail-calling CI (pythonGH-146570

    d91c828

    pythonGH-139922: add interpreter types to InternalDocs/interpreter.md (…

    c15f27b
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

    OS-windowsinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-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.