feat: 新增采样器按指令周期记录样本并输出热点直方图

This commit is contained in:
2026-10-04 21:40:26 +00:00
parent 7390d66f3e
commit b77f75b237
10 changed files with 181 additions and 21 deletions
+5
View File
@@ -86,6 +86,11 @@ pub fn run_js_stress_bench(config: &BenchConfig, kernel: &Arc<KernelCore>, pool:
let mut guard = pool.spawn();
let vm = guard.vm_mut();
// 指令周期采样只对测量迭代开启:预热不采样,直方图不混入
// 预热样本,stderr 输出也不随预热迭代重复。
vm.set_sample_period(config.sample_period);
vm.set_sample_top_k(config.sample_top);
let pre_session = vm.session_object_count();
let pre_epoch = vm.epoch_object_count();
+5
View File
@@ -32,6 +32,11 @@ pub struct BenchConfig {
pub iterations: u32,
pub update_baseline: bool,
pub leak_check_interval: usize,
/// 指令周期采样周期(2 的幂,0 关闭):开启时测量迭代每 period 条指令
/// 记一条样本,run 末按 flat_id 输出 top-K 直方图。
pub sample_period: u64,
/// 采样直方图 top-K 大小(默认 10)。
pub sample_top: usize,
}
/// 按 mode 分派到具体 benchmark 实现(js/rust/leak)。