| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
| |
* 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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
| |
Co-authored-by: Sam Gross <colesbury@gmail.com>
|
|
|
|
|
|
|
|
| |
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.
|
|
|
| |
Signed-off-by: cui fliter <imcusg@gmail.com>
|
|
|
|
| |
(GH-116336)
|
| |
|
| |
|
| |
|
|
|
| |
Co-authored-by: Brandt Bucher <brandtbucher@microsoft.com>
|
|
|
|
| |
(gh-115875)
|
| |
|
|
|
| |
gh-115491: Fix compiler warning on macOS
|
| |
|
|
|
|
| |
lock-free (#115786)
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
|
|
| |
(#115332)
Perform str check after TypeError is raised
---------
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
|
|
|
| |
Makes iteration of a dict be lock free for the forward iteration case.
|
|
|
| |
Objects/longobject.c:1186:42: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
|
|
|
|
| |
(free-threading) (#115745)
|
|
|
|
| |
thread-safe (gh-115605)
|
|
|
|
|
| |
(#115109)
Makes accessing a single element thread safe and typically lock free
|
|
|
| |
Adds locking for shared PyDictKeysObject's for dictionaries
|
|
|
|
|
| |
* gh-115733: Fix crash involving exhausted iterator
* Add blurb
|
|
|
|
|
|
| |
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.
|
|
|
|
|
| |
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.
|
|
|
|
|
| |
Useful for introspection and consistent with functions and other
descriptors.
|
| |
|
|
|
|
| |
(gh-115546)
|
|
|
| |
Fixes a compiler warning.
|
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
| |
Move type-lock to per-interpreter lock to avoid heavy contention in interpreters test
|
|
|
|
|
|
|
| |
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.
|
|
|
| |
Co-authored-by: Petr Viktorin <encukou@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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-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.
|
|
|
|
| |
functions (GH-114886)
|
| |
|
|
|
|
| |
(gh-114899)
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
| |
This changes a number of internal usages of `PyDict_SetDefault` to use `PyDict_SetDefaultRef`.
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
|
|
|
|
|
|
|
| |
(#115132)
Revert "GH-108362: Incremental GC implementation (GH-108038)"
This reverts commit 36518e69d74607e5f094ce55286188e4545a947d.
|
|
|
|
|
|
|
|
|
| |
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
|