summaryrefslogtreecommitdiffstats
path: root/Objects
Commit message (Collapse)AuthorAgeFilesLines
* gh-116381: Specialize CONTAINS_OP (GH-116385)Ken Jin2024-03-063-10/+10
| | | | | | | | | | | * Specialize CONTAINS_OP * šŸ“œšŸ¤– Added by blurb_it. * Add PyAPI_FUNC for JIT --------- Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
* gh-115103: Delay reuse of mimalloc pages that store PyObjects (#115435)Sam Gross2024-03-064-6/+166
| | | | | | | | | | | | | | | | | | This implements the delayed reuse of mimalloc pages that contain Python objects in the free-threaded build. Allocations of the same size class are grouped in data structures called pages. These are different from operating system pages. For thread-safety, we want to ensure that memory used to store PyObjects remains valid as long as there may be concurrent lock-free readers; we want to delay using it for other size classes, in other heaps, or returning it to the operating system. When a mimalloc page becomes empty, instead of immediately freeing it, we tag it with a QSBR goal and insert it into a per-thread state linked list of pages to be freed. When mimalloc needs a fresh page, we process the queue and free any still empty pages that are now deemed safe to be freed. Pages waiting to be freed are still available for allocations of the same size class and allocating from a page prevent it from being freed. There is additional logic to handle abandoned pages when threads exit.
* gh-112087: Update list_get_item_ref to optimistically avoid locking (gh-116353)Donghee Na2024-03-051-11/+60
| | | Co-authored-by: Sam Gross <colesbury@gmail.com>
* gh-115103: Enable internal mimalloc assertions in debug builds (#116343)Sam Gross2024-03-051-0/+3
| | | | | | | | This sets `MI_DEBUG` to `2` in debug builds to enable `mi_assert_internal()` calls. Expensive internal assertions are not enabled. This also disables an assertion in free-threaded builds that would be triggered by the free-threaded GC because we traverse heaps that are not owned by the current thread.
* chore: fix typos (#116345)cui fliter2024-03-051-1/+1
| | | Signed-off-by: cui fliter <imcusg@gmail.com>
* gh-112075: Enable freeing with qsbr and fallback to lock on key changed ā†µDino Viehland2024-03-051-6/+3
| | | | (GH-116336)
* gh-112087: Make list_{slice, ass_slice, subscript} to be threadsafe (gh-116233)Donghee Na2024-03-051-50/+82
|
* gh-116029: Fix unused function warning on macOS (#116340)Sam Gross2024-03-051-2/+2
|
* gh-116316: Fix typo in `UNARY_FUNC(PyNumber_Positive)` macros (GH-116317)Kirill Podoprigora2024-03-041-1/+1
|
* gh-116296: Fix refleak in reduce_newobj() corner case (#116297)Erlend E. Aasland2024-03-041-0/+1
| | | Co-authored-by: Brandt Bucher <brandtbucher@microsoft.com>
* gh-112087: Use QSBR technique for list_new/clear for free-thread build ā†µDonghee Na2024-03-011-6/+29
| | | | (gh-115875)
* gh-115941: fixes in dictobject.c doc block(#116196)Humbulani2024-03-011-1/+2
|
* gh-115491: Fix Clang compiler warning (#116153)Sam Gross2024-03-011-1/+1
| | | gh-115491: Fix compiler warning on macOS
* gh-112075: Avoid locking shared keys on every assignment (#116087)Dino Viehland2024-02-291-12/+20
|
* gh-112075: Use relaxed stores for places where we may race with when reading ā†µDino Viehland2024-02-281-18/+25
| | | | lock-free (#115786)
* gh-115891: Fix debug byte filling in free-threaded build (#116018)Sam Gross2024-02-281-4/+13
| | | | | | The previous code had two bugs. First, the debug offset in the mimalloc heap includes the two pymalloc debug words, but the pointer passed to fill_mem_debug does not include them. Second, the current object heap is correct source for allocations, but not deallocations.
* gh-112075: Remove compiler warning from apple clang (gh-115855)Donghee Na2024-02-281-2/+2
|
* gh-115323: Add meaningful error message for using bytearray.extend with str ā†µJay Ting2024-02-241-0/+4
| | | | | | | | (#115332) Perform str check after TypeError is raised --------- Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
* gh-112075: Iterating a dict shouldn't require locks (#115108)Dino Viehland2024-02-221-60/+264
| | | Makes iteration of a dict be lock free for the forward iteration case.
* gh-115827: Fix compile warning in `longobject.c` (#115828)Nikita Sobolev2024-02-221-1/+1
| | | Objects/longobject.c:1186:42: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
* gh-115491: Keep some fields valid across allocations in obmalloc ā†µSam Gross2024-02-212-10/+33
| | | | (free-threading) (#115745)
* gh-112087: Make list_{concat, repeat, inplace_repeat, ass_item) to be ā†µDonghee Na2024-02-211-40/+82
| | | | thread-safe (gh-115605)
* gh-112075: Accessing a single element should optimistically avoid locking ā†µDino Viehland2024-02-212-174/+493
| | | | | (#115109) Makes accessing a single element thread safe and typically lock free
* gh-112075: Make PyDictKeysObject thread-safe (#114741)Dino Viehland2024-02-211-92/+198
| | | Adds locking for shared PyDictKeysObject's for dictionaries
* gh-115733: Fix crash involving exhausted list iterator (#115740)Sam Gross2024-02-201-3/+3
| | | | | * gh-115733: Fix crash involving exhausted iterator * Add blurb
* gh-115103: Implement delayed free mechanism for free-threaded builds (#115367)Sam Gross2024-02-201-0/+190
| | | | | | This adds `_PyMem_FreeDelayed()` and supporting functions. The `_PyMem_FreeDelayed()` function frees memory with the same allocator as `PyMem_Free()`, but after some delay to ensure that concurrent lock-free readers have finished.
* gh-115491: Keep some fields valid across allocations (free-threading) (#115573)Sam Gross2024-02-203-25/+16
| | | | | This avoids filling the memory occupied by ob_tid, ob_ref_local, and ob_ref_shared with debug bytes (e.g., 0xDD) in mimalloc in the free-threaded build.
* gh-101860: Expose __name__ on property (GH-101876)Eugene Toder2024-02-201-7/+66
| | | | | Useful for introspection and consistent with functions and other descriptors.
* gh-115618: Remove improper Py_XDECREFs in property methods (GH-115619)Serhiy Storchaka2024-02-171-3/+0
|
* gh-111968: Split _Py_async_gen_asend_freelist out of _Py_async_gen_frā€¦ ā†µDonghee Na2024-02-171-21/+30
| | | | (gh-115546)
* gh-113743: Give _PyTypes_AfterFork a prototype. (gh-115563)Benjamin Peterson2024-02-161-1/+1
| | | Fixes a compiler warning.
* gh-112529: Make the GC scheduling thread-safe (#114880)Sam Gross2024-02-161-0/+2
| | | | | | | | | | The GC keeps track of the number of allocations (less deallocations) since the last GC. This buffers the count in thread-local state and uses atomic operations to modify the per-interpreter count. The thread-local buffering avoids contention on shared state. A consequence is that the GC scheduling is not as precise, so "test_sneaky_frame_object" is skipped because it requires that the GC be run exactly after allocating a frame object.
* gh-111968: Split _Py_dictkeys_freelist out of _Py_dict_freelist (gh-115505)Donghee Na2024-02-164-35/+46
|
* gh-113743: Use per-interpreter locks for types (#115541)Dino Viehland2024-02-161-2/+3
| | | Move type-lock to per-interpreter lock to avoid heavy contention in interpreters test
* gh-113743: Make the MRO cache thread-safe in free-threaded builds (#113930)Dino Viehland2024-02-151-67/+357
| | | | | | | Makes _PyType_Lookup thread safe, including: Thread safety of the underlying cache. Make mutation of mro and type members thread safe Also _PyType_GetMRO and _PyType_GetBases are currently returning borrowed references which aren't safe.
* gh-114626: add PyCFunctionFast and PyCFunctionFastWithKeywords (GH-114627)David Hewitt2024-02-152-5/+4
| | | Co-authored-by: Petr Viktorin <encukou@gmail.com>
* gh-114570: Add PythonFinalizationError exception (#115352)Victor Stinner2024-02-141-0/+5
| | | | | | | | | | | | | | | | | Add PythonFinalizationError exception. This exception derived from RuntimeError is raised when an operation is blocked during the Python finalization. The following functions now raise PythonFinalizationError, instead of RuntimeError: * _thread.start_new_thread() * subprocess.Popen * os.fork() * os.fork1() * os.forkpty() Morever, _winapi.Overlapped finalizer now logs an unraisable PythonFinalizationError, instead of an unraisable RuntimeError.
* gh-112087: Make __sizeof__ and listiter_{len, next} to be threadsafe (gh-114843)Donghee Na2024-02-141-50/+52
|
* gh-111968: Rename freelist related struct names to Eric's suggestion (gh-115329)Donghee Na2024-02-147-128/+117
|
* gh-115391: Fix compiler warning in `Objects/longobject.c` (GH-115368)Kirill Podoprigora2024-02-131-1/+1
|
* gh-89240: Enable multiprocessing on Windows to use large process pools ā†µSteve Dower2024-02-131-4/+3
| | | | | | | (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-111140: Adds PyLong_AsNativeBytes and PyLong_FromNative[Unsigned]Bytes ā†µSteve Dower2024-02-121-8/+208
| | | | functions (GH-114886)
* GH-114695: Add `sys._clear_internal_caches` (GH-115152)Brandt Bucher2024-02-121-15/+7
|
* gh-111968: Refactor _PyXXX_Fini to integrate with _PyObject_ClearFreeLists ā†µDonghee Na2024-02-106-44/+19
| | | | (gh-114899)
* gh-110481: Implement inter-thread queue for biased reference counting (#114824)Sam Gross2024-02-092-7/+17
| | | | | | | | | 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-115184: Fix refleak tracking issues in free-threaded build (#115188)Sam Gross2024-02-093-6/+16
| | | | | | | | Fixes a few issues related to refleak tracking in the free-threaded build: - Count blocks in abandoned segments - Call `_mi_page_free_collect` earlier during heap traversal in order to get an accurate count of blocks in use. - Add missing refcount tracking in `_Py_DecRefSharedDebug` and `_Py_ExplicitMergeRefcount`. - Pause threads in `get_num_global_allocated_blocks` to ensure that traversing the mimalloc heaps is safe.
* gh-112069: Adapt set/frozenset methods to Argument Clinic (#115112)Tomas R2024-02-082-157/+673
|
* gh-112066: Use `PyDict_SetDefaultRef` in place of `PyDict_SetDefault`. (#112211)Sam Gross2024-02-072-8/+10
| | | | | This changes a number of internal usages of `PyDict_SetDefault` to use `PyDict_SetDefaultRef`. Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
* GH-108362: Revert "GH-108362: Incremental GC implementation (GH-108038)" ā†µMark Shannon2024-02-072-19/+1
| | | | | | | (#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-064-272/+721
| | | | | | | | | 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