cpython/Python
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
..
clinic
deepfreeze
frozen_modules
_warnings.c
adaptive.md
asdl.c
asm_trampoline.S
assemble.c
ast.c
ast_opt.c
ast_unparse.c
bltinmodule.c
bootstrap_hash.c
brc.c
bytecodes.c GH-113710: Tier 2 optimizer: check the function instead of checking globals. (GH-116410) 2024-03-06 13:12:23 +00:00
ceval.c gh-116098: Revert "gh-107674: Improve performance of sys.settrace (GH-114986)" (GH-116178) 2024-03-01 07:46:33 +01:00
ceval_gil.c
ceval_macros.h gh-116098: Revert "gh-107674: Improve performance of sys.settrace (GH-114986)" (GH-116178) 2024-03-01 07:46:33 +01:00
codecs.c
compile.c
condvar.h
context.c
critical_section.c
crossinterp.c
crossinterp_data_lookup.h
crossinterp_exceptions.h
dtoa.c
dup2.c
dynamic_annotations.c
dynload_hpux.c
dynload_shlib.c
dynload_stub.c
dynload_win.c
emscripten_signal.c
emscripten_trampoline.c
errors.c
executor_cases.c.h GH-113710: Tier 2 optimizer: check the function instead of checking globals. (GH-116410) 2024-03-06 13:12:23 +00:00
fileutils.c
flowgraph.c
formatter_unicode.c
frame.c
frozen.c
frozenmain.c
future.c
gc.c
gc_free_threading.c gh-115103: Update refleak checker to trigger _PyMem_ProcessDelayed (gh-116238) 2024-03-03 06:44:16 +09:00
gc_gil.c
generated_cases.c.h GH-115685: Split _TO_BOOL_ALWAYS_TRUE into micro-ops (GH-116352) 2024-03-05 15:23:08 +00:00
getargs.c
getcompiler.c
getcopyright.c
getopt.c
getplatform.c
getversion.c
hamt.c
hashtable.c
import.c
importdl.c
initconfig.c gh-107954: Add PyConfig_MEMBER_BOOL type to PyConfigSpec (#116359) 2024-03-06 09:29:27 +00:00
instrumentation.c gh-115832: Fix instrumentation version mismatch during interpreter shutdown (#115856) 2024-03-04 11:29:39 -05:00
intrinsics.c
jit.c GH-116134: JIT aarch64-pc-windows-msvc (GH-116130) 2024-03-04 10:16:56 -08:00
legacy_tracing.c
lock.c gh-114271: Make _thread.ThreadHandle thread-safe in free-threaded builds (GH-115190) 2024-03-01 13:43:12 -08:00
marshal.c
modsupport.c
mysnprintf.c
mystrtoul.c
object_stack.c
opcode_targets.h
optimizer.c Fix debug output for optimized executor (#116337) 2024-03-05 10:05:29 -08:00
optimizer_analysis.c GH-113710: Tier 2 optimizer: check the function instead of checking globals. (GH-116410) 2024-03-06 13:12:23 +00:00
optimizer_bytecodes.c GH-115687: Most comparisons create Booleans, so propagate that information (GH-116360) 2024-03-06 10:46:42 +00:00
optimizer_cases.c.h GH-113710: Tier 2 optimizer: check the function instead of checking globals. (GH-116410) 2024-03-06 13:12:23 +00:00
optimizer_symbols.c GH-115819: Eliminate Boolean guards when value is known (GH-116355) 2024-03-05 15:06:00 +00:00
parking_lot.c
pathconfig.c
perf_trampoline.c
preconfig.c
pyarena.c
pyctype.c
pyfpe.c
pyhash.c
pylifecycle.c
pymath.c
pystate.c gh-115103: Delay reuse of mimalloc pages that store PyObjects (#115435) 2024-03-06 09:42:11 -05:00
pystrcmp.c
pystrhex.c
pystrtod.c
Python-ast.c
Python-tokenize.c
pythonrun.c
pytime.c
qsbr.c gh-115103: Delay reuse of mimalloc pages that store PyObjects (#115435) 2024-03-06 09:42:11 -05:00
README
specialize.c
stdlib_module_names.h
structmember.c
suggestions.c
symtable.c
sysmodule.c gh-116326: Handler errors correctly in getwindowsversion in sysmodule (#116339) 2024-03-05 12:31:04 +00:00
thread.c
thread_nt.h
thread_pthread.h
thread_pthread_stubs.h
tier2_engine.md
traceback.c
tracemalloc.c
vm-state.md

Miscellaneous source files for the main Python shared library