• CPython का tail-calling interpreter Windows x86-64 वातावरण में मौजूदा तरीके की तुलना में लगभग 15% बेहतर प्रदर्शन दिखाता है
  • macOS AArch64(XCode Clang) पर भी लगभग 5% का performance improvement देखा गया है, और Windows में MSVC 2026 की experimental functionality का उपयोग किया गया है
  • pyperformance benchmark में ज़्यादातर tests में speed improvement देखा गया, और कुछ में अधिकतम 78% तक सुधार
  • performance improvement का मुख्य कारण compiler optimization heuristics reset और inlining improvement माना गया है
  • Python 3.15 की आधिकारिक रिलीज़ पर, Visual Studio 2026 आधारित build में इसे डिफ़ॉल्ट रूप से लागू किया जाएगा

tail-calling interpreter का performance improvement

  • CPython का tail-calling interpreter, मौजूदा switch-case interpreter की तुलना में Windows x86-64 पर लगभग 15% तेज़ मापा गया
    • pyperformance के अनुसार, geometric mean में 15~16% सुधार
    • कुछ benchmarks में अधिकतम 78% speed improvement, जबकि बहुत कम मामलों में 60% धीमापन
  • macOS AArch64(XCode Clang) पर लगभग 5% performance improvement की पुष्टि हुई
  • यह परिणाम इस शर्त पर मान्य है कि Python 3.15 development cycle के दौरान इसमें कोई बदलाव न हो

interpreter संरचना की तुलना

  • C-आधारित interpreter implementation को तीन तरीकों में बाँटा जाता है: switch-case, computed goto, tail-call threaded
    • switch-case: हर instruction के लिए branch handling
    • computed goto: GCC/Clang extension, जिसमें branch address पर सीधे jump किया जाता है
    • tail-call threaded: हर bytecode handler को function में अलग करना और अगले function को tail call करना
  • पहले C compiler tail call optimization की गारंटी नहीं देते थे, इसलिए stack overflow का जोखिम था
  • Clang के __attribute__((musttail)) और MSVC के [[msvc::musttail]] attribute से forced tail call संभव हो गया

Windows के लिए MSVC 2026 build results

  • MSVC की experimental functionality का उपयोग करने वाले CPython build में ज़्यादातर benchmarks तेज़ हुए
    • उदाहरण परिणाम:
      • spectralnorm: 1.48x
      • nbody: 1.35x
      • bm_django_template: 1.18x
      • xdsl: 1.14x
  • इसे Python 3.15 के “What’s New” दस्तावेज़ में आधिकारिक रूप से शामिल किया गया
    • Visual Studio 2026(MSVC 18) build में tail-calling interpreter उपलब्ध
    • pure Python libraries में लगभग 15%, और छोटे scripts में अधिकतम 40% speed improvement

performance improvement के कारण

  • tail calling, compiler की optimization heuristics को reset करके अधिक efficient code generation को बढ़ावा देता है
  • मौजूदा CPython interpreter loop लगभग 12,000 lines के एक single function से बना है, जिससे inlining optimization failure अक्सर होती है
    • compiler code size बढ़ने से बचने के लिए कई बार inlining से इनकार करता है
  • tail-calling approach में functions अलग हो जाते हैं, जिससे simple functions inline किए जा सकते हैं
    • उदाहरण के तौर पर PyStackRef_CLOSE_SPECIALIZED जैसे simple function inline हो जाते हैं
  • PGO(profile-guided optimization) build में भी यही phenomenon रिपोर्ट किया गया

build और उपयोग का तरीका

  • फिलहाल केवल source build संभव है
    • Visual Studio 2026 वातावरण में निम्न command से build करें
      $env:PlatformToolset = "v145"
      ./PCbuild/build.bat --tail-call-interp -c Release -p x64 --pgo
      
  • आगे Python 3.15 development स्थिर होने पर official binary distribution जारी की जाएगी

अभी कोई टिप्पणी नहीं है.

अभी कोई टिप्पणी नहीं है.