summaryrefslogtreecommitdiffstats
path: root/Python/gc.c
Commit message (Collapse)AuthorAgeFilesLines
* GH-133261: Make sure that the GC doesn't untrack objects in trashcan (GH-133431)Mark Shannon2025-05-051-0/+1
|
* GH-124715: Move trashcan mechanism into `Py_Dealloc` (GH-132280)Mark Shannon2025-04-301-3/+2
|
* GH-132508: Use tagged integers on the evaluation stack for the last ↵Mark Shannon2025-04-291-2/+8
| | | | instruction offset (GH-132545)
* gh-130704: Strength reduce `LOAD_FAST{_LOAD_FAST}` (#130708)mpage2025-04-011-1/+7
| | | Optimize `LOAD_FAST` opcodes into faster versions that load borrowed references onto the operand stack when we can prove that the lifetime of the local outlives the lifetime of the temporary that is loaded onto the stack.
* gh-131740: minor readability fix in PyUnstable_GC_VisitObjects (gh-131786)Martin DeMello2025-03-281-5/+5
| | | | | | | | | Minor readability fix in PyUnstable_GC_VisitObjects Replaces `if (visit_generation())` with `if (visit_generation() < 0)`, since we are checking for the failure case, and it's confusing to have that be implicitly `true`. Also fixes a misspelt variable name.
* gh-131740: Update PyUnstable_GC_VisitObjects to traverse perm gen (gh-131744)Donghee Na2025-03-261-1/+4
|
* gh-131238: Remove includes from pycore_interp.h (#131495)Victor Stinner2025-03-201-4/+3
| | | Remove also now unused includes in C files.
* gh-131238: Remove many includes from pycore_interp.h (#131472)Victor Stinner2025-03-191-0/+2
|
* GH-127705: Use `_PyStackRef`s in the default build. (GH-127875)Mark Shannon2025-03-101-3/+3
|
* gh-130019: Fix data race in _PyType_AllocNoTrack (gh-130058)Sam Gross2025-02-131-2/+3
| | | | | | | The reference count fields, such as `ob_tid` and `ob_ref_shared`, may be accessed concurrently in the free threading build by a `_Py_TryXGetRef` or similar operation. The PyObject header fields will be initialized by `_PyObject_Init`, so only call `memset()` to zero-initialize the remainder of the allocation.
* GH-128682: Account for escapes in `DECREF_INPUTS` (GH-129953)Mark Shannon2025-02-121-0/+1
| | | | | | | | * Handle escapes in DECREF_INPUTS * Mark a few more functions as escaping * Replace DECREF_INPUTS with PyStackRef_CLOSE where possible
* gh-129354: Use PyErr_FormatUnraisable() function (#129514)Victor Stinner2025-01-311-7/+13
| | | Replace PyErr_WriteUnraisable() with PyErr_FormatUnraisable().
* gh-129354: Fix grammar in PyErr_FormatUnraisable() (#129475)Victor Stinner2025-01-311-2/+2
| | | Replace "on verb+ing" with "while verb+ing".
* GH-128563: Add new frame owner type for interpreter entry frames (GH-129078)Mark Shannon2025-01-211-1/+1
| | | Add new frame owner type for interpreter entry frames
* gh-126491: Revert "GH-126491: Lower heap size limit with faster marking ↵Petr Viktorin2024-12-101-144/+157
| | | | | | | | (GH-127519)" (GH-127770) Revert "GH-126491: Lower heap size limit with faster marking (GH-127519)" This reverts commit 023b7d2141467017abc27de864f3f44677768cb3, which introduced a refleak.
* GH-126491: Lower heap size limit with faster marking (GH-127519)Mark Shannon2024-12-061-157/+144
| | | | | | | * Faster marking of reachable objects * Changes calculation of work to do and work done. * Merges transitive closure calculations
* GH-126491: GC: Mark objects reachable from roots before doing cycle ↵Mark Shannon2024-12-021-87/+268
| | | | | | | | | | | | | collection (GH-127110) * Mark almost all reachable objects before doing collection phase * Add stats for objects marked * Visit new frames before each increment * Update docs * Clearer calculation of work to do.
* GH-127010: Don't lazily track and untrack dicts (GH-127027)Mark Shannon2024-11-201-31/+4
|
* GH-124567: Replace quadratic assert with linear one (GH-127009)Mark Shannon2024-11-191-1/+1
|
* Revert "GH-126491: GC: Mark objects reachable from roots before doing cycle ↵Hugo van Kemenade2024-11-191-215/+62
| | | | collection (GH-126502)" (#126983)
* GH-126491: GC: Mark objects reachable from roots before doing cycle ↵Mark Shannon2024-11-181-62/+215
| | | | | | | | | | | | | | | | collection (GH-126502) * Mark almost all reachable objects before doing collection phase * Add stats for objects marked * Visit new frames before each increment * Remove lazy dict tracking * Update docs * Clearer calculation of work to do.
* GH-124567: Reduce overhead of debug build for GC. Should help CI performance ↵Mark Shannon2024-11-151-1/+9
| | | | (GH-126777)
* gh-116510: Fix crash during sub-interpreter shutdown (gh-124645)Neil Schemenauer2024-09-271-3/+26
| | | | | Fix a bug that can cause a crash when sub-interpreters use "basic" single-phase extension modules. Shared objects could refer to PyGC_Head nodes that had been freed as part of interpreter shutdown.
* gh-123923: Defer refcounting for `f_executable` in `_PyInterpreterFrame` ↵Sam Gross2024-09-121-0/+7
| | | | | | | | (#123924) Use a `_PyStackRef` and defer the reference to `f_executable` when possible. This avoids some reference count contention in the common case of executing the same code object from multiple threads concurrently in the free-threaded build.
* GH-117759: Document incremental GC (GH-123266)Mark Shannon2024-08-271-11/+16
| | | | | | * Update what's new * Update gc module docs and fix inconsistency in gc.get_objects
* GH-122298: Restore printing of GC stats (GH-123261)Mark Shannon2024-08-231-0/+25
|
* GH-115776: Allow any fixed sized object to have inline values (GH-123192)Mark Shannon2024-08-211-0/+3
|
* gh-117139: Garbage collector support for deferred refcounting (#122956)Sam Gross2024-08-151-0/+11
| | | | | | | | | | The free-threaded GC now visits interpreter stacks to keep objects that use deferred reference counting alive. Interpreter frames are zero initialized in the free-threaded GC so that the GC doesn't see garbage data. This is a temporary measure until stack spilling around escaping calls is implemented. Co-authored-by: Ken Jin <kenjin@python.org>
* gh-83754: Use the Py_TYPE() macro (#120599)Victor Stinner2024-06-171-3/+3
| | | | Don't access directly PyObject.ob_type, but use the Py_TYPE() macro instead.
* Fix typos in documentation and comments (#119763)Xie Yanbo2024-06-041-2/+2
|
* gh-110850: Remove _PyTime_TimeUnchecked() function (#118552)Victor Stinner2024-05-051-1/+0
| | | | | | | | | | | | | Use the new public Raw functions: * _PyTime_PerfCounterUnchecked() with PyTime_PerfCounterRaw() * _PyTime_TimeUnchecked() with PyTime_TimeRaw() * _PyTime_MonotonicUnchecked() with PyTime_MonotonicRaw() Remove internal functions: * _PyTime_PerfCounterUnchecked() * _PyTime_TimeUnchecked() * _PyTime_MonotonicUnchecked()
* GH-115776: Embed the values array into the object, for "normal" Python ↵Mark Shannon2024-04-021-1/+6
| | | | objects. (GH-116115)
* Silence compiler warnings in gc.c (#117422)Guido van Rossum2024-04-011-0/+3
|
* GH-117108: Set the "old space bit" to "visited" for all young objects (#117213)Mark Shannon2024-03-261-17/+37
| | | | Change old space bit of young objects from 0 to gcstate->visited_space. This ensures that any object created *and* collected during cycle GC has the bit set correctly.
* A few minor tweaks to get stats working and compiling cleanly. (#117219)Mark Shannon2024-03-251-5/+3
| | | | Fixes a compilation error when configured with `--enable-pystats`, an array size issue, and an unused variable.
* GH-117108: Change the size of the GC increment to about 1% of the total heap ↵Mark Shannon2024-03-221-15/+15
| | | | size. (GH-117120)
* GH-108362: Incremental Cycle GC (GH-116206)Mark Shannon2024-03-201-308/+498
|
* gh-116604: Correctly honor the gc status when calling _Py_RunGC (#116628)Pablo Galindo Salgado2024-03-121-0/+4
|
* gh-110850: Use public PyTime functions (#115746)Victor Stinner2024-02-201-1/+1
| | | | | Replace private _PyTime functions with public PyTime functions. random_seed_time_pid() now reports errors to its caller.
* gh-110850: Rename internal PyTime C API functions (#115734)Victor Stinner2024-02-201-3/+3
| | | | | | | | | | | | | | | | | Rename functions: * _PyTime_GetSystemClock() => _PyTime_TimeUnchecked() * _PyTime_GetPerfCounter() => _PyTime_PerfCounterUnchecked() * _PyTime_GetMonotonicClock() => _PyTime_MonotonicUnchecked() * _PyTime_GetSystemClockWithInfo() => _PyTime_TimeWithInfo() * _PyTime_GetMonotonicClockWithInfo() => _PyTime_MonotonicWithInfo() * _PyTime_GetMonotonicClockWithInfo() => _PyTime_MonotonicWithInfo() Changes: * Remove "typedef PyTime_t PyTime_t;" which was "typedef PyTime_t _PyTime_t;" before a previous rename. * Update comments of "Unchecked" functions. * Remove invalid PyTime_Time() comment.
* gh-110850: Cleanup pycore_time.h includes (#115724)Victor Stinner2024-02-201-0/+1
| | | | | <pycore_time.h> include is no longer needed to get the PyTime_t type in internal header files. This type is now provided by <Python.h> include. Add <pycore_time.h> includes to C files instead.
* gh-110850: Replace _PyTime_t with PyTime_t (#115719)Victor Stinner2024-02-201-1/+1
| | | | | Run command: sed -i -e 's!\<_PyTime_t\>!PyTime_t!g' $(find -name "*.c" -o -name "*.h")
* gh-112175: Add `eval_breaker` to `PyThreadState` (#115194)Brett Simmers2024-02-201-3/+6
| | | | | | | | | | | This change adds an `eval_breaker` field to `PyThreadState`. The primary motivation is for performance in free-threaded builds: with thread-local eval breakers, we can stop a specific thread (e.g., for an async exception) without interrupting other threads. The source of truth for the global instrumentation version is stored in the `instrumentation_version` field in PyInterpreterState. Threads usually read the version from their local `eval_breaker`, where it continues to be colocated with the eval breaker bits.
* gh-115124: Use _PyObject_ASSERT() in gc.c (#115125)Victor Stinner2024-02-151-15/+22
| | | | Replace assert() with _PyObject_ASSERT() in gc.c to dump the object when an assertion fails.
* GH-108362: Revert "GH-108362: Incremental GC implementation (GH-108038)" ↵Mark Shannon2024-02-071-514/+310
| | | | | | | (#115132) Revert "GH-108362: Incremental GC implementation (GH-108038)" This reverts commit 36518e69d74607e5f094ce55286188e4545a947d.
* GH-108362: Incremental GC implementation (GH-108038)Mark Shannon2024-02-051-310/+514
|
* gh-112529: Implement GC for free-threaded builds (#114262)Sam Gross2024-01-251-2/+6
| | | | | | | * 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-112529: Use GC heaps for GC allocations in free-threaded builds (gh-114157)Sam Gross2024-01-201-6/+7
| | | | | | | | | | * 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: Introduce _PyFreeListState and _PyFreeListState_GET API (gh-113584)Donghee Na2024-01-091-16/+1
|
* gh-113688: Split up gcmodule.c (gh-113715)Sam Gross2024-01-051-0/+1958
This splits part of Modules/gcmodule.c of into Python/gc.c, which now contains the core garbage collection implementation. The Python module remain in the Modules/gcmodule.c file.