feat: server 执行请求路径,六段纯函数加每请求步数覆盖

This commit is contained in:
2026-10-06 15:02:47 +00:00
parent 196bb77516
commit 635c8144f6
10 changed files with 314 additions and 47 deletions
+11
View File
@@ -391,6 +391,10 @@ pub struct Vm {
/// `pc/opcode/flat_id/frames`,供监督者超时/崩溃杀子进程后读回挂死点;
/// 默认 None(零输出零分配)。
pub(crate) pc_watch: Option<PathBuf>,
/// 每请求步数上限覆盖:执行路径按请求设置,None 回退内核配置。
/// 池回收的 `full_reset` 路径清位;`run()` 入口的 `clear_execution_state`
/// 刻意不清(清在那会把执行路径刚设的覆盖抹掉)。
pub(crate) max_steps_override: Option<u64>,
}
impl Drop for Vm {
@@ -467,6 +471,13 @@ impl Vm {
self.pc_watch = path;
}
/// 设置每请求步数上限覆盖:dispatch 主循环取 `覆盖值.or(内核配置)`,
/// 覆盖优先、None 回退内核配置。执行路径按请求必设(含 None),池回收的
/// `full_reset` 路径清位。
pub fn set_max_steps(&mut self, limit: Option<u64>) {
self.max_steps_override = limit;
}
/// 设置指令周期采样周期(2 的幂,0 关闭)。开启后 dispatch 主循环每
/// `period` 条指令记一条样本(flat_id、pc、opcode、frames 深度),run 末
/// 按 flat_id 聚合并向 stderr 输出 top-K 直方图;关闭时热路径仅一次