From b70e334bce98ccec063c076bd791ade786e2ae4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=88=B1=E7=89=B9=E6=AF=8F=E7=BE=8A=E9=98=9F?= Date: Mon, 10 Aug 2026 16:29:17 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20dispatch=20=E4=B8=BB=E5=BE=AA=E7=8E=AF?= =?UTF-8?q?=20hoist=20max=5Fsteps=EF=BC=8C=E5=85=8D=E9=80=90=E6=8C=87?= =?UTF-8?q?=E4=BB=A4=20config=20=E6=8C=87=E9=92=88=E8=BF=BD=E5=AF=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/oxide_vm/src/vm.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/oxide_vm/src/vm.rs b/crates/oxide_vm/src/vm.rs index 6646d82..3a2fb34 100644 --- a/crates/oxide_vm/src/vm.rs +++ b/crates/oxide_vm/src/vm.rs @@ -1124,10 +1124,13 @@ impl Vm { } pub(crate) fn dispatch(&mut self) -> Result { + // config.max_steps 逐指令只读且循环内不变:提到循环外,免每次经 kernel_core + // Arc 指针追寻读取(热点内唯一的 config 访问)。 + let max_steps = self.kernel_core.config.max_steps; let mut steps: u64 = 0; loop { steps += 1; - if let Some(max_steps) = self.kernel_core.config.max_steps { + if let Some(max_steps) = max_steps { if steps > max_steps { vm_warn!("dispatch: step limit {} exceeded at pc={}", max_steps, self.pc); self.profiling.set_instruction_count(steps);