Commit graph

6214 commits

Author SHA1 Message Date
Nadeshiko Manju
4345253981
gh-134584: Eliminate redundant refcounting from _STORE_ATTR_WITH_HINT (GH-142767)
Signed-off-by: Manjusaka <me@manjusaka.me>
2025-12-16 22:21:04 +00:00
Nadeshiko Manju
6ee51a36b3
gh-134584: Eliminate redundant refcounting from _LOAD_ATTR_INSTANCE_VALUE (GH-142769)
Signed-off-by: Manjusaka <me@manjusaka.me>
2025-12-16 20:39:20 +00:00
Hugo van Kemenade
47ec96f133 Post 3.15.0a3 2025-12-16 16:31:52 +02:00
Hugo van Kemenade
f1eb0c0b0c Python 3.15.0a3 2025-12-16 14:26:12 +02:00
Savannah Ostrowski
bef63d2fb8
GH-134584: Remove redundant refcount from _STORE_ATTR_SLOT (#142729) 2025-12-15 15:18:44 -08:00
Ken Jin
790a46a449
gh-134584: JIT: Eliminate redundant refcount ops for X_INT (GH-142765) 2025-12-15 22:22:18 +00:00
Nadeshiko Manju
059316ade6
gh-134584: Eliminate redundant refcounting from _STORE_ATTR_INSTANCE_VALUE (GH-142759)
Signed-off-by: Manjusaka <me@manjusaka.me>
2025-12-15 20:17:12 +00:00
Ken Jin
0ac4e6c6cd
gh-134584: Remove custom float decref ops (GH-142576) 2025-12-15 19:38:58 +00:00
Mark Shannon
27a2e49d18
GH-142718: JIT: Fix crash due to incorrect caching on side exits when exiting jitted code. (GH-142762)
JIT: Fix crash due to incorrect caching on side exits when exiting jitted code.

* Make sure that stack is in correct state at side exits with TOS cached values
* Simplify choice of cached items for side exits
2025-12-15 19:01:29 +00:00
Sam Gross
a882ae198a
gh-142472: Clean-up _PyStackRef functions (gh-142479)
This combines most _PyStackRef functions and macros between the free
threaded and default builds.

- Remove Py_TAG_DEFERRED (same as Py_TAG_REFCNT)
- Remove PyStackRef_IsDeferred (same as !PyStackRef_RefcountOnObject)
2025-12-15 12:03:49 -05:00
Donghee Na
abaaeee6a0
gh-134584: Eliminate redundant refcounting from _STORE_SUBSCR_DICT (GH-142712)
Co-authored-by: Ken Jin <kenjin4096@gmail.com>
2025-12-15 16:42:32 +00:00
Nadeshiko Manju
872ab51f32
gh-134584: Eliminate redundant refcounting from _CALL_LIST_APPEND (GH-142711)
Signed-off-by: Manjusaka <me@manjusaka.me>
Co-authored-by: Ken Jin <kenjin4096@gmail.com>
2025-12-15 15:49:36 +00:00
Pablo Galindo Salgado
6658e2cb07
gh-138122: Add --subprocesses flag to profile child processes in tachyon (#142636) 2025-12-15 12:11:40 +00:00
Kumar Aditya
fb554ad68d
gh-140414: streamline thread state access in asyncio (#142742) 2025-12-15 16:57:51 +05:30
Donghee Na
04da416e6b
gh-134584: Eliminate redundant refcounting from _STORE_SUBSCR_LIST_INT (gh-142703) 2025-12-14 12:26:00 +00:00
PuQing
a2a400af1e
gh-134584: Eliminate redundant refcounting from _CALL_BUILTION_O (GH-142695)
Co-authored-by: Ken Jin <kenjin4096@gmail.com>
2025-12-14 10:28:02 +00:00
Nadeshiko Manju
a154c9ed4e
gh-134584: Eliminate redundant refcounting from _CALL_STR_1 (GH-136070)
Signed-off-by: Manjusaka <me@manjusaka.me>
2025-12-14 09:33:05 +00:00
Ken Jin
e02a35c365
gh-134584: Cleanups for GH-135860 (GH-142604) 2025-12-13 14:38:10 +00:00
Neil Schemenauer
c98182be8d
gh-132657: Add lock-free set contains implementation (#132290)
This roughly follows what was done for dictobject to make a lock-free
lookup operation. With this change, the set contains operation scales much
better when used from multiple-threads. The frozenset contains performance
seems unchanged (as already lock-free).

Summary of changes:

* refactor set_lookkey() into set_do_lookup() which now takes a function
  pointer that does the entry comparison. This is similar to dictobject and
  do_lookup(). In an optimized build, the comparison function is inlined and
  there should be no performance cost to this.

* change set_do_lookup() to return a status separately from the entry value

* add set_compare_frozenset() and use if the object is a frozenset. For the
  free-threaded build, this avoids some overhead (locking, atomic operations,
  incref/decref on key)

* use FT_ATOMIC_* macros as needed for atomic loads and stores

* use a deferred free on the set table array, if shared (only on free-threaded
  build, normal build always does an immediate free)

* for free-threaded build, use explicit for loop to zero the table, rather than memcpy()

* when mutating the set, assign so->table to NULL while the change is a
  happening. Assign the real table array after the change is done.
2025-12-13 09:50:23 +00:00
Ken Jin
a3a611b042
gh-134584: Revert partially GH-135860 (GH-142620) 2025-12-12 14:04:11 +00:00
Victor Stinner
7aa353c414
gh-142217: Deprecate the private _Py_Identifier C API (#142221)
Deprecate functions:

* _PyObject_CallMethodId()
* _PyObject_GetAttrId()
* _PyUnicode_FromId()
2025-12-12 14:10:25 +01:00
Sam Gross
0a62f8277e
gh-142534: Avoid TSan warnings in dictobject.c (gh-142544)
There are places we use "relaxed" loads where C11 requires "consume" or
stronger. Unfortunately, compilers don't really implement "consume" so
fake it for our use in a way that avoids upsetting TSan.
2025-12-11 16:23:19 -05:00
Pablo Galindo Salgado
6a0135a392
gh-138122: Add exception profiling mode to the sampling profiler (#142561) 2025-12-11 20:46:34 +00:00
Donghee Na
a27538540e
gh-134584: Eliminate redundant refcounting from `_CALL_LEN` (gh-136104) 2025-12-11 15:24:34 +00:00
Noam Cohen
a78f43b001
gh-134584: Eliminate redundant refcounting from _CALL_TUPLE_1 (GH-135860) 2025-12-11 14:31:28 +00:00
Mark Shannon
469f191a85
GH-135379: Top of stack caching for the JIT. (GH-135465)
Uses three registers to cache values at the top of the evaluation stack
This significantly reduces memory traffic for smaller, more common uops.
2025-12-11 10:32:52 +00:00
Dino Viehland
da8199f884
gh-123241: Don't modify ref count during visitation (GH-142232) 2025-12-11 09:54:29 +01:00
Pablo Galindo Salgado
5b19c75b47
gh-138122: Make the tachyon profiler opcode-aware (#142394) 2025-12-11 03:41:47 +00:00
Ken Jin
ebf3427615
gh-141976: Protect against non-progressing specializations in tracing JIT (GH-141989) 2025-12-10 19:39:11 +00:00
Victor Stinner
b20722c300
gh-142447: Fix cast warning in pycore_backoff.h (#142465)
MAKE_VALUE_AND_BACKOFF() macro casts its result to uint16_t.

Add pycore_backoff.h header to test_cppext tests.
2025-12-09 17:03:13 +01:00
Victor Stinner
49207a5226
gh-140222: Increase stack margin on debug build (#142452)
Increase _PyOS_MIN_STACK_SIZE if Python is built in debug mode.
2025-12-09 16:25:46 +01:00
John Paul Adrian Glaubitz
02c085d48b
gh-142342: Fix m68k assembler operand constraints for %fpcr access (gh-142343)
On m68k, an fmove instruction accessing %fpcr may only move from
or to a data register or a memory operand. The constraint "g" also
permits the use of address registers, which is invalid. The correct
constraint is "dm". Beginning with GCC 15, the register allocator
picks an address register in the code which causes SIGILL during
runtime.

Co-authored-by: Michael Karcher <github@mkarcher.dialup.fu-berlin.de>
2025-12-09 13:46:40 +00:00
Sam Gross
f2fba4c99a
gh-124379: Document _PyStackRef (gh-142321) 2025-12-08 12:14:50 -05:00
Donghee Na
c4ccaf4b10
gh-141770: Annotate anonymous mmap usage if "-X dev" is used (gh-142079) 2025-12-08 14:47:19 +00:00
dr-carlos
ff2577f56e
gh-141732: Fix ExceptionGroup repr changing when original exception sequence is mutated (#141736) 2025-12-07 21:04:04 +00:00
Pablo Galindo Salgado
d6d850df89
gh-138122: Don't sample partial frame chains (#141912) 2025-12-07 15:53:48 +00:00
Pablo Galindo Salgado
572c780aa8
gh-138122: Implement frame caching in RemoteUnwinder to reduce memory reads (#142137)
This PR implements frame caching in the RemoteUnwinder class to significantly reduce memory reads when profiling remote processes with deep call stacks.

When cache_frames=True, the unwinder stores the frame chain from each sample and reuses unchanged portions in subsequent samples. Since most profiling samples capture similar call stacks (especially the parent frames), this optimization avoids repeatedly reading the same frame data from the target process.

The implementation adds a last_profiled_frame field to the thread state that tracks where the previous sample stopped. On the next sample, if the current frame chain reaches this marker, the cached frames from that point onward are reused instead of being re-read from remote memory.

The sampling profiler now enables frame caching by default.
2025-12-06 22:37:34 +00:00
Serhiy Storchaka
706fdda8b3
gh-141370: Fix undefined behavior when using Py_ABS() (GH-141548)
Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
2025-12-05 16:24:35 +02:00
Stan Ulbrych
fb404ab575
gh-142225: Fix PyABIInfo_VAR macro (GH-142230) 2025-12-04 10:33:15 +01:00
Mark Shannon
62423c9c36
GH-141794: Limit size of generated machine code. (GH-142228)
* Factor out bodies of the largest uops, to reduce jit code size.
* Factor out common assert, also reducing jit code size.
* Limit size of jitted code for a single executor to 1MB.
2025-12-03 17:43:35 +00:00
Victor Stinner
7e5fcae09b
gh-142217: Remove internal _Py_Identifier functions (#142219)
Remove internal functions:

* _PyDict_ContainsId()
* _PyDict_DelItemId()
* _PyDict_GetItemIdWithError()
* _PyDict_SetItemId()
* _PyEval_GetBuiltinId()
* _PyObject_CallMethodIdNoArgs()
* _PyObject_CallMethodIdObjArgs()
* _PyObject_CallMethodIdOneArg()
* _PyObject_VectorcallMethodId()
* _PyUnicode_EqualToASCIIId()

These functions were not exported and so no usable outside CPython.
2025-12-03 14:33:32 +01:00
Peter Bierma
41728856a2
gh-142163: Only define HAVE_THREAD_LOCAL when Py_BUILD_CORE is set (#142164) 2025-12-02 09:43:11 +05:30
Victor Stinner
9c4ff8a615
gh-130396: Export _Py_ReachedRecursionLimitWithMargin() (#142012)
test_peg_generator needs the function.
2025-11-27 12:22:15 +00:00
Victor Stinner
d5d9e89dde
gh-116008: Detect freed thread state in faulthandler (#141988)
Add _PyMem_IsULongFreed() function.
2025-11-27 12:35:00 +01:00
Victor Stinner
83d8134c5b
gh-127635: Use flexible array in tracemalloc (#141991)
Replace frames[1] with frames[] in tracemalloc_traceback structure.
2025-11-27 12:32:31 +01:00
Victor Stinner
7fe1a18b77
gh-130396: Remove _Py_ReachedRecursionLimitWithMargin() function (#141951)
Move the private function to the internal C API (pycore_ceval.h).
2025-11-27 12:32:00 +01:00
Alper
bc9e63dd9d
gh-116738: Fix thread-safety issue in re module for free threading (gh-141923)
Added atomic operations to `scanner_begin()` and `scanner_end()` to prevent
race conditions on the `executing` flag in free-threaded builds. Also added
tests for concurrent usage of the `re` module.

Without the atomic operations, `test_scanner_concurrent_access()` triggers
`assert(self->executing)` failures, or a thread sanitizer run emits errors.
2025-11-26 15:40:45 -05:00
Petr Viktorin
226011ba12
gh-139165: Make Py_SIZE, Py_IS_TYPE,Py_ SET_SIZE regular functions in stable ABI (GH-139166)
* Make Py_{SIZE,IS_TYPE,SET_SIZE} regular functions in stable ABI

Group them together with Py_TYPE & Py_SET_TYPE to cut down
on repetitive preprocessor macros.
Format repetitive definitions in object.c more concisely.

Py_SET_TYPE is still left out of the Limited API.
2025-11-25 14:30:33 +01:00
Sam Gross
c490ffb7ac
gh-116749: Fix code comment for _PyConfig_GIL_DEFAULT (gh-141804) 2025-11-24 10:42:00 -05:00
Petr Viktorin
bf66bce4ee
gh-141780: Make PyModule_FromSlotsAndSpec enable GIL if needed (GH-141785) 2025-11-24 13:26:35 +01:00