fix: 直 session 分配站(函数对象/prototype 子对象/标签模板数组)补 session 堆账目,配单 run 分配包络高水位 O(1) 采样锚与执行期 churn 峰值校准用例

This commit is contained in:
2026-09-11 19:44:07 +00:00
parent ad0405fe51
commit 4c3ac707f7
6 changed files with 152 additions and 0 deletions
+11
View File
@@ -1002,6 +1002,12 @@ impl Vm {
self.epoch.bump().allocated_bytes() + self.gc_state.session_epoch.allocated_bytes()
}
/// 本 run 累计分配字节的高水位:`run_alloc_bytes` 的顶层指令边界
/// 采样上界,run 边界(reset/full_reset)重起算。留存内存观测锚。
pub fn run_alloc_peak(&self) -> usize {
self.gc_state.run_alloc_peak
}
/// 本 run 累计分配字节:epoch arena + session 对象 arena + session 手工堆
/// 账目(session 串 + session 对象及其属性向量 + GC 后补回的 BigInt)。
/// 单次 run 内单调不减(执行期对象不回收、
@@ -1635,6 +1641,11 @@ impl Vm {
if bytes > self.gc_state.session_bytes_peak {
self.gc_state.session_bytes_peak = bytes;
}
// 单 run 分配包络高水位:O(1) 三计数器读(双 arena + session 账目)。
let alloc = self.run_alloc_bytes();
if alloc > self.gc_state.run_alloc_peak {
self.gc_state.run_alloc_peak = alloc;
}
if bytes >= self.gc_state.string_gc_watermark {
self.maybe_collect_session_strings();
}