cpython/Objects/mimalloc
Sam Gross c012c8ab7b
gh-115103: Delay reuse of mimalloc pages that store PyObjects (#115435)
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.
2024-03-06 09:42:11 -05:00
..
prim chore: fix typos (#116345) 2024-03-05 09:05:52 -07:00
alloc-aligned.c
alloc-override.c
alloc-posix.c
alloc.c gh-115103: Enable internal mimalloc assertions in debug builds (#116343) 2024-03-05 13:54:20 -05:00
arena.c
bitmap.c
bitmap.h
heap.c gh-115103: Delay reuse of mimalloc pages that store PyObjects (#115435) 2024-03-06 09:42:11 -05:00
init.c gh-115491: Keep some fields valid across allocations (free-threading) (#115573) 2024-02-20 10:36:40 -05:00
options.c
os.c
page-queue.c
page.c gh-115103: Delay reuse of mimalloc pages that store PyObjects (#115435) 2024-03-06 09:42:11 -05:00
random.c
segment-map.c
segment.c gh-115103: Delay reuse of mimalloc pages that store PyObjects (#115435) 2024-03-06 09:42:11 -05:00
static.c
stats.c