Skip to content

Commit 6d5636c

Browse files
[3.14] gh-137232: Update free-threading HOWTOs with up-to-date info for 3.14 (GH-140817) (#141129)
(cherry picked from commit 86ab7bb) Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
1 parent 8f0581c commit 6d5636c

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

Doc/howto/free-threading-extensions.rst

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ Memory Allocation APIs
203203
Python's memory management C API provides functions in three different
204204
:ref:`allocation domains <allocator-domains>`: "raw", "mem", and "object".
205205
For thread-safety, the free-threaded build requires that only Python objects
206-
are allocated using the object domain, and that all Python object are
206+
are allocated using the object domain, and that all Python objects are
207207
allocated using that domain. This differs from the prior Python versions,
208208
where this was only a best practice and not a hard requirement.
209209

@@ -344,12 +344,12 @@ This means you cannot rely on nested critical sections to lock multiple objects
344344
at once, as the inner critical section may suspend the outer ones. Instead, use
345345
:c:macro:`Py_BEGIN_CRITICAL_SECTION2` to lock two objects simultaneously.
346346

347-
Note that the locks described above are only :c:type:`!PyMutex` based locks.
347+
Note that the locks described above are only :c:type:`PyMutex` based locks.
348348
The critical section implementation does not know about or affect other locking
349349
mechanisms that might be in use, like POSIX mutexes. Also note that while
350-
blocking on any :c:type:`!PyMutex` causes the critical sections to be
350+
blocking on any :c:type:`PyMutex` causes the critical sections to be
351351
suspended, only the mutexes that are part of the critical sections are
352-
released. If :c:type:`!PyMutex` is used without a critical section, it will
352+
released. If :c:type:`PyMutex` is used without a critical section, it will
353353
not be released and therefore does not get the same deadlock avoidance.
354354

355355
Important Considerations
@@ -397,7 +397,8 @@ The wheels, shared libraries, and binaries are indicated by a ``t`` suffix.
397397
* `pypa/manylinux <https://github.com/pypa/manylinux>`_ supports the
398398
free-threaded build, with the ``t`` suffix, such as ``python3.13t``.
399399
* `pypa/cibuildwheel <https://github.com/pypa/cibuildwheel>`_ supports the
400-
free-threaded build if you set
400+
free-threaded build on Python 3.13 and 3.14. On Python 3.14, free-threaded
401+
wheels will be built by default. On Python 3.13, you will need to set
401402
`CIBW_ENABLE to cpython-freethreading <https://cibuildwheel.pypa.io/en/stable/options/#enable>`_.
402403

403404
Limited C API and Stable ABI

Doc/howto/free-threading-python.rst

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,14 @@ after the main thread is running. The following objects are immortalized:
116116
* :ref:`classes <classes>` (type objects)
117117

118118
Because immortal objects are never deallocated, applications that create many
119-
objects of these types may see increased memory usage. This is expected to be
120-
addressed in the 3.14 release.
119+
objects of these types may see increased memory usage under Python 3.13. This
120+
has been addressed in the 3.14 release, where the aforementioned objects use
121+
deferred reference counting to avoid reference count contention.
121122

122123
Additionally, numeric and string literals in the code as well as strings
123-
returned by :func:`sys.intern` are also immortalized. This behavior is
124-
expected to remain in the 3.14 free-threaded build.
124+
returned by :func:`sys.intern` are also immortalized in the 3.13 release. This
125+
behavior is part of the 3.14 release as well and it is expected to remain in
126+
future free-threaded builds.
125127

126128

127129
Frame objects
@@ -150,11 +152,12 @@ compared to the default GIL-enabled build. In 3.13, this overhead is about
150152
40% on the `pyperformance <https://pyperformance.readthedocs.io/>`_ suite.
151153
Programs that spend most of their time in C extensions or I/O will see
152154
less of an impact. The largest impact is because the specializing adaptive
153-
interpreter (:pep:`659`) is disabled in the free-threaded build. We expect
154-
to re-enable it in a thread-safe way in the 3.14 release. This overhead is
155-
expected to be reduced in upcoming Python release. We are aiming for an
156-
overhead of 10% or less on the pyperformance suite compared to the default
157-
GIL-enabled build.
155+
interpreter (:pep:`659`) is disabled in the free-threaded build.
156+
157+
The specializing adaptive interpreter has been re-enabled in a thread-safe way
158+
in the 3.14 release. The performance penalty on single-threaded code in
159+
free-threaded mode is now roughly 5-10%, depending on the platform and C
160+
compiler used.
158161

159162

160163
Behavioral changes

0 commit comments

Comments
 (0)