switch from Integer to u128
- u128 is only 16 bytes instead of 24 - incrementing u128 does not involve heap allocations - u128 should be sufficent it would take more than 2 sextilion years to overflow if we would be incrementing it every tick at 5GHz i.e. 2^128-1 / 5 GHz / 60 / 60 / 24 / 356 > 2 sextilion before this ~3.2% of the execution time of the program in https://github.com/mthom/scryer-prolog/issues/3265#issuecomment-4103176469 was spend in the increment_call_count function, after this change it's down to 0.3%
This commit is contained in:
@@ -4256,12 +4256,12 @@ impl Machine {
|
||||
step_or_fail!(self.machine_st, self.machine_st.p = self.machine_st.cp);
|
||||
}
|
||||
&Instruction::CallInferenceCount => {
|
||||
let global_count = self.machine_st.cwil.global_count.clone();
|
||||
let global_count = self.machine_st.cwil.global_count;
|
||||
self.inference_count(self.machine_st.registers[1], global_count);
|
||||
step_or_fail!(self.machine_st, self.machine_st.p += 1);
|
||||
}
|
||||
&Instruction::ExecuteInferenceCount => {
|
||||
let global_count = self.machine_st.cwil.global_count.clone();
|
||||
let global_count = self.machine_st.cwil.global_count;
|
||||
self.inference_count(self.machine_st.registers[1], global_count);
|
||||
step_or_fail!(self.machine_st, self.machine_st.p = self.machine_st.cp);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user