Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Run CDPT in cooperative collection mode
Select CDPT's cooperative collection mode before the collection guard's
first pin, so CDPT never deploys a background collector thread. The
guard is only a barrier; a background thread would make the process
multi-threaded, breaking fork and signal semantics and burning CPU
while idle.

Pin CDPT to a git revision that provides the selectable collection mode.

Assisted-by: Claude
  • Loading branch information
youknowone committed Jul 3, 2026
commit 574e86a54b7c189a24ddc3d6bc950391cd92f1a1
16 changes: 7 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ bitflagset = "0.0.3"
bstr = "1"
bzip2 = "0.6"
chrono = { version = "0.4.44", default-features = false, features = ["clock", "std"] }
cdpt = "0.1.0"
cdpt = { git = "https://github.com/youknowone/cdpt", rev = "125a2a4c6c5ed3ba4f2550eeb8a3d44b71716a80" }
console_error_panic_hook = "0.1"
constant_time_eq = "0.5"
cranelift = "0.132.0"
Expand Down
16 changes: 14 additions & 2 deletions crates/vm/src/gc_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -414,9 +414,21 @@ impl GcState {
};

// Keep a CDPT guard during collection, following origin/gc's
// coarse-grained guarded collection experiment.
// coarse-grained guarded collection experiment. Run CDPT in cooperative
// mode so it never spawns a background collector thread: the guard here
// is only a barrier, and a background thread would make the process
// multi-threaded (breaking fork/signal semantics) and burn CPU while
// idle. Selecting the mode before this first `pin()` keeps the thread
// from being deployed at all.
#[cfg(not(target_arch = "wasm32"))]
let _cdpt_guard = cdpt::pin();
let _cdpt_guard = {
// This is the only `cdpt::pin()` in the process, and the mode is
// selected right before it, so cooperative mode always latches and
// no background collector thread is ever deployed.
let cooperative = cdpt::global().set_collection_mode(cdpt::CollectionMode::Cooperative);
debug_assert!(cooperative, "CDPT must run in cooperative mode");
cdpt::pin()
};

// Memory barrier to ensure visibility of all reference count updates
// from other threads before we start analyzing the object graph.
Expand Down
Loading