Skip to content

Commit

Permalink
Missed the most important unnecessary .clone() in variable setting.
Browse files Browse the repository at this point in the history
25-30% throughput improvement in for/range and list_append benches.
  • Loading branch information
rdaum committed Jan 14, 2024
1 parent a06d77c commit d61ffd6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
2 changes: 2 additions & 0 deletions crates/kernel/src/vm/activation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,8 @@ impl Activation {
assert!(self.pc < self.program.main_vector.len(), "pc out of bounds");
let op = &self.program.main_vector[self.pc];
self.pc += 1;
// TODO: It would be nice to avoid the clone here, and hold a reference in the execution loop, but
// that leads to borrow issues.
op.clone()
}

Expand Down
2 changes: 1 addition & 1 deletion crates/kernel/src/vm/exec_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,6 @@ impl VMExecState {
/// Set the value of a local variable.
#[inline]
pub(crate) fn set_env(&mut self, id: &Name, v: Var) {
self.top_mut().environment.set(id.0 as usize, v.clone());
self.top_mut().environment.set(id.0 as usize, v);
}
}
14 changes: 4 additions & 10 deletions crates/kernel/src/vm/vm_execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -426,13 +426,13 @@ impl VM {
binary_bool_op!(state, <=);
}
Op::In => {
let lhs = state.pop();
let rhs = state.pop();
let (lhs, rhs) = (state.pop(), state.peek_top());
let r = lhs.index_in(&rhs);
if let Variant::Err(e) = r.variant() {
state.pop();
return self.push_error(state, *e);
}
state.push(r);
state.update(0, r);
}
Op::Mul => {
binary_var_op!(self, state, mul);
Expand Down Expand Up @@ -764,13 +764,7 @@ impl VM {
continue;
}
Op::Exit { stack, label } => {
return self.unwind_stack(
state,
FinallyReason::Exit {
stack,
label,
},
);
return self.unwind_stack(state, FinallyReason::Exit { stack, label });
}
Op::Scatter {
nargs,
Expand Down

0 comments on commit d61ffd6

Please sign in to comment.