Visitar URL original
Per-interpreter runtime state and a process-wide GC stop-the-world by youknowone · Pull Request #8517 · RustPython/RustPython · GitHub
Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
5c341d2
vm: add per-interpreter runtime state and interpreter registry
youknowone Aug 13, 2026
43f4b23
gc: stop every interpreter while collecting
youknowone Aug 13, 2026
ffd3d1e
vm: scope the interpreter registry per thread without threading
youknowone Aug 13, 2026
0079994
vm: keep the interpreter registry usable across bootstrap, drop and fork
youknowone Aug 13, 2026
8f108ff
vm: attach and detach thread slots when switching interpreters
youknowone Aug 13, 2026
696a8c1
vm: list only the current interpreter's subclasses
youknowone Aug 14, 2026
562b657
gc: give each interpreter its own collector state
youknowone Aug 14, 2026
30e2020
_queue, _thread: detach before taking locks held across waits
youknowone Aug 14, 2026
5ce062e
_io, _winapi: detach on the remaining stopped-holdable lock takes
youknowone Aug 14, 2026
87b6c68
gc: size the interpreter owner tag to the header padding
youknowone Aug 15, 2026
fd27902
vm: reuse cleared frame blocks and shorten interpreter hot paths
youknowone Aug 15, 2026
c3fcc70
gc, vm: address review notes on owner tags and interpreter docs
youknowone Aug 15, 2026
57428cd
vm: gate interpreter registration on stop-the-world admission
youknowone Aug 15, 2026
8d07831
gc: keep the tracking counters off the barrier path
youknowone Aug 15, 2026
4e518d3
dict: settle lookups and iteration steps under one read guard
youknowone Aug 15, 2026
eb94daf
vm: build a call's argument vector once
youknowone Aug 15, 2026
f70db35
vm: reach an instance dict without cloning it
youknowone Aug 15, 2026
4a76424
vm: shorten the per-instruction safepoint and the call preamble
youknowone Aug 15, 2026
b0f0dcc
vm: give KwArgs a zero-sized hasher
youknowone Aug 15, 2026
f9bbc6d
vm: promote borrowed stack refs before a yield
youknowone Aug 15, 2026
b4bb43c
vm: run the exact-args vectorcall on a heap frame again
youknowone Aug 15, 2026
98d2410
vm: release a tail call's function at the callee's return
youknowone Aug 16, 2026
08bd522
vm: stop copying a running frame's locals when it materializes
youknowone Aug 16, 2026
c7c1452
vm: key data stack frame reuse on the exact frame size
youknowone Aug 16, 2026
2d58fc8
vm: store the frame object payload address in the cross-thread slot
youknowone Aug 16, 2026
e24d831
vm: copy a foreign thread's frames instead of linking them
youknowone Aug 16, 2026
5d0d9be
vm: resolve the two rustdoc links this branch added
youknowone Aug 16, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
vm: key data stack frame reuse on the exact frame size
push_frame and pop_frame compared 16-byte-aligned sizes, so two frames
whose sizes differ by less than the alignment matched as a reuse. The
caller reads that as "every slot was cleared by the previous frame", but
the larger frame's tail slots were never touched by it.

Assisted-by: Claude
  • Loading branch information
youknowone committed Aug 16, 2026
commit c7c1452a4f83d2e8528d6953ef392c07a456708c
11 changes: 6 additions & 5 deletions crates/vm/src/datastack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,13 @@ impl DataStack {
/// a just-cleared frame block.
#[inline(always)]
pub fn push_frame(&mut self, size: usize) -> (*mut u8, bool) {
let aligned_size = (size + ALIGN - 1) & !(ALIGN - 1);
let reusable_frame = self.reusable_frame.take();
let ptr = self.push_inner(size);
let reused =
reusable_frame.is_some_and(|(base, old_size)| base == ptr && old_size == aligned_size);
// Exact sizes, not aligned ones: the caller reads "reused" as "every
// slot of this frame was cleared by the last one", and two frames whose
// sizes differ by less than ALIGN share an aligned size while the
// larger one's tail slots were never touched, let alone cleared.
let reused = reusable_frame.is_some_and(|(base, old_size)| base == ptr && old_size == size);
(ptr, reused)
}

Expand Down Expand Up @@ -177,8 +179,7 @@ impl DataStack {
#[inline(always)]
pub unsafe fn pop_frame(&mut self, base: *mut u8, size: usize) {
unsafe { self.pop_inner(base) };
let aligned_size = (size + ALIGN - 1) & !(ALIGN - 1);
self.reusable_frame = Some((base, aligned_size));
self.reusable_frame = Some((base, size));
}

#[inline(always)]
Expand Down