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
+9
View File
@@ -234,6 +234,15 @@ impl Vm {
}
}
// 指令周期采样:开启时(周期为 2 的幂)每 period 条指令记一条样本
// (flat_id, pc, opcode, frames 深度),run 末聚合成 top-K 直方图;
// 关闭时仅这一条可预测分支,零写零分配。
if self.sampling.period != 0 && (steps & (self.sampling.period - 1)) == 0 {
self.sampling
.records
.push((self.active_flat_id, pc as u32, op as u8, self.frames.len() as u32));
}
match op {
OpCode::NOP => {}