summaryrefslogtreecommitdiffstats
path: root/Python/gc.c
Commit message (Collapse)AuthorAgeFilesLines
* GH-140638: Add a GC "candidates" stat (GH-141814)Brandt Bucher2025-11-221-5/+12
|
* GH-140638: Add a GC "duration" stat (GH-141720)Brandt Bucher2025-11-191-11/+10
|
* gh-141070: Add PyUnstable_Object_Dump() function (#141072)Victor Stinner2025-11-181-1/+1
| | | | | | | | | | * Promote _PyObject_Dump() as a public function. * Keep _PyObject_Dump() alias to PyUnstable_Object_Dump() for backward compatibility. * Replace _PyObject_Dump() with PyUnstable_Object_Dump(). Co-authored-by: Peter Bierma <zintensitydev@gmail.com> Co-authored-by: Kumar Aditya <kumaraditya@python.org> Co-authored-by: Petr Viktorin <encukou@gmail.com>
* GH-140643: Add `<native>` and `<GC>` frames to the sampling profiler (#141108)Brandt Bucher2025-11-171-0/+2
| | | | | | | | | - Introduce a new field in the GC state to store the frame that initiated garbage collection. - Update RemoteUnwinder to include options for including "<native>" and "<GC>" frames in the stack trace. - Modify the sampling profiler to accept parameters for controlling the inclusion of native and GC frames. - Enhance the stack collector to properly format and append these frames during profiling. - Add tests to verify the correct behavior of the profiler with respect to native and GC frames, including options to exclude them. Co-authored-by: Pablo Galindo Salgado <pablogsal@gmail.com>
* gh-131253: free-threaded build support for pystats (gh-137189)Neil Schemenauer2025-11-031-3/+4
| | | | | | | | Allow the --enable-pystats build option to be used with free-threading. The stats are now stored on a per-interpreter basis, rather than process global. For free-threaded builds, the stats structure is allocated per-thread and then periodically merged into the per-interpreter stats structure (on thread exit or when the reporting function is called). Most of the pystats related code has be moved into the file Python/pystats.c.
* GH-139951: Fix major GC performance regression (GH-140262)Mark Shannon2025-10-211-20/+23
| | | | | * Count number of actually tracked objects, instead of trackable objects. This ensures that untracking tuples has the desired effect of reducing GC overhead * Do not track most untrackable tuples during creation. This prevents large numbers of small tuples causing execessive GCs.
* gh-140358: Bring back elapsed time and unreachable count to gc debug output ↵Pål Grønås Drange2025-10-201-0/+13
| | | | (#140359)
* GH-137562: Fix github-issue number for deallocated objects in cache bug ↵Sergey Miryanov2025-08-121-1/+1
| | | | (GH-137614)
* gh-137562: Remove reference for GC_REACHABLE in comment (GH-137563)Sergey Miryanov2025-08-091-2/+1
| | | GC_REACHABLE is obsolete
* GH-135552: Make the GC clear weakrefs later (GH-136189)Neil Schemenauer2025-08-071-77/+122
| | | | | | | | | Fix a bug caused by the garbage collector clearing weakrefs too early. The weakrefs in the ``tp_subclasses`` dictionary are needed in order to correctly invalidate type caches (for example, by calling ``PyType_Modified()``). Clearing weakrefs before calling finalizers causes the caches to not be correctly invalidated. That can cause crashes since the caches can refer to invalid objects. Defer the clearing of weakrefs without callbacks until after finalizers are executed.
* GH-119085: Move comment in Python/gc.c to correct place.Abhinav Upadhyay2025-08-071-1/+2
| | | | | | In GH-116206, the comment about moving reachable objects to next generation got moved from its original place to a place where there is no code below it. Put the comment back to where the actual movement of reachable objects happens.
* gh-137084: remove multiple calls to `get_gc_state` in `gc.c` (#137085)Sergey Miryanov2025-07-251-1/+1
|
* gh-137054: remove obsolete counting of objects in young generation under ↵Sergey Miryanov2025-07-241-9/+0
| | | | `Py_STATS` builds (#137055)
* gh-136517: Print uncollectable objects if DEBUG_UNCOLLECTABLE mode was set ↵Sergey Miryanov2025-07-101-1/+1
| | | | (#136518)
* GH-91636: Clear weakrefs created by finalizers. (GH-136401)Neil Schemenauer2025-07-081-3/+22
| | | | | Weakrefs to unreachable garbage that are created during running of finalizers need to be cleared. This avoids exposing objects that have `tp_clear` called on them to Python-level code.
* `Python/gc.c`: Refer to `InternalDocs` instead of devguide. (#136243)Kirill Podoprigora2025-07-031-1/+1
|
* 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.