summaryrefslogtreecommitdiffstats
path: root/Include/internal
Commit message (Collapse)AuthorAgeFilesLines
* gh-112050: Make collections.deque thread-safe in free-threaded builds (#113830)mpage2024-02-151-0/+2
| | | | | | | Use critical sections to make deque methods that operate on mutable state thread-safe when the GIL is disabled. This is mostly accomplished by using the @critical_section Argument Clinic directive, though there are a few places where this was not possible and critical sections had to be manually acquired/released.
* gh-112529: Use _PyThread_Id() in mimalloc in free-threaded build (#115488)Sam Gross2024-02-142-4/+13
| | | | | The free-threaded GC uses mimallocs segment thread IDs to restore the overwritten `ob_tid` thread ids in PyObjects. For that reason, it's important that PyObjects and mimalloc use the same identifiers.
* gh-115041: Add wrappers that are atomic only in free-threaded builds (#115046)mpage2024-02-141-0/+35
| | | | | | These are intended to be used in places where atomics are required in free-threaded builds but not in the default build. We don't want to introduce the potential performance overhead of an atomic operation in the default build.
* gh-115441: Fix missing braces warning (#115460)Sam Gross2024-02-141-11/+0
| | | Removes `_py_object_state_INIT`. We want to initialize the `object_state` field to zero.
* gh-111968: Rename freelist related struct names to Eric's suggestion (gh-115329)Donghee Na2024-02-146-40/+34
|
* gh-76785: Improved Subinterpreters Compatibility with 3.12 (gh-115424)Eric Snow2024-02-133-0/+42
| | | | | For the most part, these changes make is substantially easier to backport subinterpreter-related code to 3.12, especially the related modules (e.g. _xxsubinterpreters). The main motivation is to support releasing a PyPI package with the 3.13 capabilities compiled for 3.12. A lot of the changes here involve either hiding details behind macros/functions or splitting up some files.
* GH-113710: Improve `_SET_IP` and `_CHECK_VALIDITY` (GH-115248)Mark Shannon2024-02-132-2/+5
|
* GH-113710: Backedge counter improvements. (GH-115166)Mark Shannon2024-02-131-2/+4
|
* gh-114058: Foundations of the Tier2 redundancy eliminator (GH-115085)Ken Jin2024-02-133-10/+17
| | | | | | | --------- Co-authored-by: Mark Shannon <9448417+markshannon@users.noreply.github.com> Co-authored-by: Jules <57632293+JuliaPoo@users.noreply.github.com> Co-authored-by: Guido van Rossum <gvanrossum@users.noreply.github.com>
* gh-89240: Enable multiprocessing on Windows to use large process pools ↵Steve Dower2024-02-134-0/+60
| | | | | | | (GH-107873) We add _winapi.BatchedWaitForMultipleObjects to wait for larger numbers of handles. This is an internal module, hence undocumented, and should be used with caution. Check the docstring for info before using BatchedWaitForMultipleObjects.
* gh-114271: Make `PyInterpreterState.threads.count` thread-safe in ↵mpage2024-02-121-1/+1
| | | | | free-threaded builds (gh-115093) Use atomics to mutate PyInterpreterState.threads.count.
* gh-110850: Add PyTime_t C API (GH-115215)Petr Viktorin2024-02-121-48/+51
| | | | | | | | | | | | * gh-110850: Add PyTime_t C API Add PyTime_t API: * PyTime_t type. * PyTime_MIN and PyTime_MAX constants. * PyTime_AsSecondsDouble(), PyTime_Monotonic(), PyTime_PerfCounter() and PyTime_GetSystemClock() functions. Co-authored-by: Victor Stinner <vstinner@python.org>
* GH-113710: Fix updating of dict version tag and add watched dict stats ↵Mark Shannon2024-02-121-2/+3
| | | | (GH-115221)
* gh-111968: Refactor _PyXXX_Fini to integrate with _PyObject_ClearFreeLists ↵Donghee Na2024-02-109-26/+10
| | | | (gh-114899)
* gh-110481: Implement inter-thread queue for biased reference counting (#114824)Sam Gross2024-02-095-0/+84
| | | | | | | | | Biased reference counting maintains two refcount fields in each object: `ob_ref_local` and `ob_ref_shared`. The true refcount is the sum of these two fields. In some cases, when refcounting operations are split across threads, the ob_ref_shared field can be negative (although the total refcount must be at least zero). In this case, the thread that decremented the refcount requests that the owning thread give up ownership and merge the refcount fields.
* gh-114828: parenthesize non-atomic macro definitions in pycore_symtable.h ↵Carl Meyer2024-02-071-12/+12
| | | | (#115143)
* GH-108362: Revert "GH-108362: Incremental GC implementation (GH-108038)" ↵Mark Shannon2024-02-073-34/+33
| | | | | | | (#115132) Revert "GH-108362: Incremental GC implementation (GH-108038)" This reverts commit 36518e69d74607e5f094ce55286188e4545a947d.
* gh-112075: Add critical sections for most dict APIs (#114508)Dino Viehland2024-02-061-0/+46
| | | | | | | | | Starts adding thread safety to dict objects. Use @critical_section for APIs which are exposed via argument clinic and don't directly correlate with a public C API which needs to acquire the lock Use a _lock_held suffix for keeping changes to complicated functions simple and just wrapping them with a critical section Acquire and release the lock in an existing function where it won't be overly disruptive to the existing logic
* gh-115035: Mark ThreadHandles as non-joinable earlier after forking (#115042)Sam Gross2024-02-062-6/+11
| | | | | | This marks dead ThreadHandles as non-joinable earlier in `PyOS_AfterFork_Child()` before we execute any Python code. The handles are stored in a global linked list in `_PyRuntimeState` because `fork()` affects the entire process.
* gh-91602: Add iterdump() support for filtering database objects (#114501)Mariusz Felisiak2024-02-064-0/+6
| | | | | | Add optional 'filter' parameter to iterdump() that allows a "LIKE" pattern for filtering database objects to dump. Co-authored-by: Erlend E. Aasland <erlend@python.org>
* gh-112075: Add gc shared bits (#114931)Dino Viehland2024-02-051-0/+17
| | | Add GC shared flags for objects to the GC bit states in free-threaded builds
* GH-108362: Incremental GC implementation (GH-108038)Mark Shannon2024-02-053-33/+34
|
* gh-104530: Enable native Win32 condition variables by default (GH-104531)Andrew Rogers2024-02-021-5/+5
|
* GH-113710: Add a "globals to constants" pass (GH-114592)Mark Shannon2024-02-026-8/+22
| | | Converts specializations of `LOAD_GLOBAL` into constants during tier 2 optimization.
* gh-111968: Use per-thread freelists for dict in free-threading (gh-114323)Donghee Na2024-02-015-22/+17
|
* gh-112529: Remove PyGC_Head from object pre-header in free-threaded build ↵Sam Gross2024-02-011-9/+18
| | | | | | | | | | | | | | | | | (#114564) * gh-112529: Remove PyGC_Head from object pre-header in free-threaded build This avoids allocating space for PyGC_Head in the free-threaded build. The GC implementation for free-threaded CPython does not use the PyGC_Head structure. * The trashcan mechanism uses the `ob_tid` field instead of `_gc_prev` in the free-threaded build. * The GDB libpython.py file now determines the offset of the managed dict field based on whether the running process is a free-threaded build. Those are identified by the `ob_ref_local` field in PyObject. * Fixes `_PySys_GetSizeOf()` which incorrectly incorrectly included the size of `PyGC_Head` in the size of static `PyTypeObject`.
* Fix comment in pycore_runtime.h (GH-110540)He Weidong2024-02-011-1/+1
|
* gh-112087: Make PyList_{Append,Size,GetSlice} to be thread-safe (gh-114651)Donghee Na2024-01-311-1/+2
|
* gh-112919: Speed-up datetime, date and time.replace() (GH-112921)Eugene Toder2024-01-304-0/+48
| | | | | Use argument clinic and call new_* functions directly. This speeds up these functions 6x to 7.5x when calling with keyword arguments.
* gh-112075: Dictionary global version counter should use atomic increments ↵Dino Viehland2024-01-291-0/+6
| | | | | (#114568) Dictionary global version counter should use atomic increments
* gh-112050: Adapt collections.deque to Argument Clinic (#113963)mpage2024-01-294-0/+6
|
* GH-113464: Add a JIT backend for tier 2 (GH-113465)Brandt Bucher2024-01-292-2/+27
| | | | | | | Add an option (--enable-experimental-jit for configure-based builds or --experimental-jit for PCbuild-based ones) to build an *experimental* just-in-time compiler, based on copy-and-patch (https://fredrikbk.com/publications/copy-and-patch.pdf). See Tools/jit/README.md for more information on how to install the required build-time tooling.
* gh-113055: Use pointer for interp->obmalloc state (gh-113412)Neil Schemenauer2024-01-274-9/+13
| | | | | | | | | For interpreters that share state with the main interpreter, this points to the same static memory structure. For interpreters with their own obmalloc state, it is heap allocated. Add free_obmalloc_arenas() which will free the obmalloc arenas and radix tree structures for interpreters with their own obmalloc state. Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
* gh-111968: Unify freelist naming schema to Eric's suggestion (gh-114581)Donghee Na2024-01-261-7/+7
|
* gh-112529: Implement GC for free-threaded builds (#114262)Sam Gross2024-01-254-9/+128
| | | | | | | * gh-112529: Implement GC for free-threaded builds This implements a mark and sweep GC for the free-threaded builds of CPython. The implementation relies on mimalloc to find GC tracked objects (i.e., "containers").
* gh-112075: Add try-incref functions from nogil branch for use in dict thread ↵Dino Viehland2024-01-251-0/+136
| | | | | | | | | | | | | | | | | | | | safety (#114512) * Bring in a subset of biased reference counting: https://github.com/colesbury/nogil/commit/b6b12a9a94e The NoGIL branch has functions for attempting to do an incref on an object which may or may not be in flight. This just brings those functions over so that they will be usable from in the dict implementation to get items w/o holding a lock. There's a handful of small simple modifications: Adding inline to the force inline functions to avoid a warning, and switching from _Py_ALWAYS_INLINE to Py_ALWAYS_INLINE as that's available Remove _Py_REF_LOCAL_SHIFT as it doesn't exist yet (and is currently 0 in the 3.12 nogil branch anyway) ob_ref_shared is currently Py_ssize_t and not uint32_t, so use that _PY_LIKELY doesn't exist, so drop it _Py_ThreadLocal becomes _Py_IsOwnedByCurrentThread Add '_PyInterpreterState_GET()' to _Py_IncRefTotal calls. Co-Authored-By: Sam Gross <colesbury@gmail.com>
* gh-114312: Collect stats for unlikely events (GH-114493)Michael Droettboom2024-01-252-0/+31
|
* GH-112354: `END_FOR` instruction to only pop one value. (GH-114247)Mark Shannon2024-01-245-3/+39
| | | | * Compiler emits END_FOR; POP_TOP instead of END_FOR. To support tier 2 side exits in loops.
* GH-113710: Add a tier 2 peephole optimization pass. (GH-114487)Mark Shannon2024-01-242-3/+6
| | | | | * Convert _LOAD_CONST to inline versions * Remove PEP 523 checks
* gh-111964: Implement stop-the-world pauses (gh-112471)Sam Gross2024-01-236-14/+68
| | | | | | | | | | | | | | | | | The `--disable-gil` builds occasionally need to pause all but one thread. Some examples include: * Cyclic garbage collection, where this is often called a "stop the world event" * Before calling `fork()`, to ensure a consistent state for internal data structures * During interpreter shutdown, to ensure that daemon threads aren't accessing Python objects This adds the following functions to implement global and per-interpreter pauses: * `_PyEval_StopTheWorldAll()` and `_PyEval_StartTheWorldAll()` (for the global runtime) * `_PyEval_StopTheWorld()` and `_PyEval_StartTheWorld()` (per-interpreter) (The function names may change.) These functions are no-ops outside of the `--disable-gil` build.
* gh-112532: Improve mimalloc page visiting (#114133)Sam Gross2024-01-221-0/+4
| | | | | | | | | | | | | | | This adds support for visiting abandoned pages in mimalloc and improves the performance of the page visiting code. Abandoned pages contain memory blocks from threads that have exited. At some point, they may be later reclaimed by other threads. We still need to visit those pages in the free-threaded GC because they contain live objects. This also reduces the overhead of visiting mimalloc pages: * Special cases for full, empty, and pages containing only a single block. * Fix free_map to use one bit instead of one byte per block. * Use fast integer division by a constant algorithm when computing block offset from block size and index.
* gh-112529: Use GC heaps for GC allocations in free-threaded builds (gh-114157)Sam Gross2024-01-201-0/+71
| | | | | | | | | | * gh-112529: Use GC heaps for GC allocations in free-threaded builds The free-threaded build's garbage collector implementation will need to find GC objects by traversing mimalloc heaps. This hooks up the allocation calls with the correct heaps by using a thread-local "current_obj_heap" variable. * Refactor out setting heap based on type
* gh-111968: Use per-thread freelists for generator in free-threading (gh-114189)Donghee Na2024-01-184-30/+21
|
* gh-112529: Track if debug allocator is used as underlying allocator (#113747)Sam Gross2024-01-163-0/+6
| | | | | | | | | | | | | | | * gh-112529: Track if debug allocator is used as underlying allocator The GC implementation for free-threaded builds will need to accurately detect if the debug allocator is used because it affects the offset of the Python object from the beginning of the memory allocation. The current implementation of `_PyMem_DebugEnabled` only considers if the debug allocator is the outer-most allocator; it doesn't handle the case of "hooks" like tracemalloc being used on top of the debug allocator. This change enables more accurate detection of the debug allocator by tracking when debug hooks are enabled. * Simplify _PyMem_DebugEnabled
* gh-111968: Use per-thread freelists for PyContext in free-threading (gh-114122)Donghee Na2024-01-164-20/+14
|
* gh-113626: Add allow_code parameter in marshal functions (GH-113648)Serhiy Storchaka2024-01-164-0/+6
| | | | | Passing allow_code=False prevents serialization and de-serialization of code objects which is incompatible between Python versions.
* gh-111968: Use per-thread slice_cache in free-threading (gh-113972)Donghee Na2024-01-154-4/+11
|
* GH-112354: `_GUARD_IS_TRUE_POP` side-exits to target the next instruction, ↵Mark Shannon2024-01-151-1/+1
| | | | not themselves. (GH-114078)
* Fix a grammatical error in `pycore_pymem.h` (#112993)Joseph Pearson2024-01-121-1/+1
|
* gh-113710: Add types to the interpreter DSL (#113711)Ken Jin2024-01-123-55/+56
| | | | Co-authored-by: Jules <57632293+JuliaPoo@users.noreply.github.com> Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>