Skip to content

Commit 9d38eba

Browse files
olwangclaude
andcommitted
perf(reg-vm): enable DeepCopy elision by default (Phase 2 flip)
Flip RSS_VM_ELIDE_DEEPCOPY default OFF -> ON now that the optimization is proven parity-preserving and profitable. Unset = elision on; RSS_VM_ELIDE_DEEPCOPY=0 (or off/false/no) restores the byte-identical eager-copy lowering for instant rollback. Justification (all with elision active / default): - runtime 455/0, differential 33/0 - extended generative differential 33/0 @ PROPTEST_CASES=2000 (~25 min fuzzing) - soak 7/0, cost-model 1/0 - native flat-param telemetry intact (native_call_flat_int/float_param), aliasing counter-example held (native_store_reload_mutate_non_mut_heap_param_does_not_leak) - ~14x on the deep-copy-heavy kernel (deepcopy_read_param.rss: 2.5s -> 0.17s) - rollback path (elision off) re-verified byte-identical (runtime 455/0) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 11d3a2d commit 9d38eba

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

crates/rsscript/src/reg_vm/model.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1830,21 +1830,24 @@ pub(crate) enum MatchFailurePatch {
18301830

18311831
/// Process-once gate for compile-time `DeepCopy` elision (`RSS_VM_ELIDE_DEEPCOPY`).
18321832
///
1833-
/// Default OFF: the lowerer emits every prologue `DeepCopy` exactly as before, so lowering
1834-
/// is byte-identical to the pre-elision compiler. When set to a truthy value the lowerer
1835-
/// neutralizes the `DeepCopy` of any non-`mut` heap parameter it can PROVE is never mutated
1836-
/// through an alias and never escapes the frame — sharing the caller's `Rc` is then
1837-
/// observationally identical to copying it. Read once (like `RSS_JIT_COST_MODEL`) so the
1838-
/// verdict is stable across every function lowering in the process.
1833+
/// Default ON (Phase 2 v2): the lowerer neutralizes the prologue `DeepCopy` of any non-`mut`
1834+
/// heap parameter it can PROVE is never mutated through an alias and never escapes the frame —
1835+
/// sharing the caller's `Rc` is then observationally identical to copying it (the analysis
1836+
/// keeps the copy for everything not proven safe; native sees an unchanged `DeepCopyElided`
1837+
/// marker). Verified parity-preserving over runtime 455/0 + differential 33/0 @ 2000 generative
1838+
/// cases + soak + cost-model, with a ~14x win on the deep-copy-heavy kernel. Set
1839+
/// `RSS_VM_ELIDE_DEEPCOPY=0` (or `off`/`false`/`no`) to restore the byte-identical eager-copy
1840+
/// lowering for a fast rollback. Read once (like `RSS_JIT_COST_MODEL`) so the verdict is stable
1841+
/// across every function lowering in the process.
18391842
fn elide_deepcopy_enabled() -> bool {
18401843
static ENABLED: std::sync::OnceLock<bool> = std::sync::OnceLock::new();
18411844
*ENABLED.get_or_init(|| {
1842-
matches!(
1845+
!matches!(
18431846
std::env::var("RSS_VM_ELIDE_DEEPCOPY")
18441847
.ok()
18451848
.as_deref()
18461849
.map(str::trim),
1847-
Some("1") | Some("true") | Some("on") | Some("yes")
1850+
Some("0") | Some("false") | Some("off") | Some("no")
18481851
)
18491852
})
18501853
}

0 commit comments

Comments
 (0)