निष्कर्ष

Python 3.14 के free-threaded build में asyncio ने Global Interpreter Lock (GIL) को हटाकर और thread-per-state management में बदलाव करके वास्तविक parallel execution को संभव बनाया है। इसके कारण threads की संख्या के साथ परफ़ॉर्मेंस linear रूप से scale होती है, जिससे कई event loops को parallel में चलाना संभव हो गया है, और high-performance multi-threaded asyncio applications के लिए नई संभावनाएँ खुली हैं.


मुख्य बदलाव

  • GIL (Global Interpreter Lock) हटाना: CPython का free-threaded build GIL को हटाता है, जिससे कई threads एक साथ Python code चला सकते हैं।
  • thread safety सुनिश्चित करना: asyncio अब global data structures की जगह thread-specific state management का उपयोग करता है, जिससे thread safety सुनिश्चित होती है।
    • task storage: global WeakSet की जगह thread-specific circular doubly linked list का उपयोग किया गया है, जिससे lock contention और weak references का overhead हट गया।
    • current task storage: "current task" को thread state में store किया जाता है, जिससे तेज़ और lock-free access संभव होता है।

परफ़ॉर्मेंस सुधार

  • linear performance scaling: benchmark नतीजों से पता चला कि free-threaded build में threads की संख्या बढ़ने पर asyncio की परफ़ॉर्मेंस linear रूप से बेहतर होती है।
  • TCP benchmark: GIL-enabled build की तुलना में free-threaded build में throughput काफ़ी बढ़ा
  • web scraping benchmark: aiohttp का उपयोग करने वाले web scraping benchmark में free-threaded build पर कई workers के साथ परफ़ॉर्मेंस 2 गुना से अधिक बेहतर रही।

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

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