save_function_params comes down to use cases like this:
var r = range([1,2,3,4]);
save_function_params is used to make sure that the vector (
[1,2,3,4]) which is created on the stack does not get popped from the stack and cause a memory error at runtime when the user attempts to use the variable
I have made some headway on my current optimization work to identify functions where
save_function_params does not need to be called - the most obvious case being if the return value from the function is unused. The performance difference is not as big as I would have hoped, however.
Would you mind running an experiment for me:
- Run some timings with the stock code.
- simply comment out the internal call to
save_function_params in your check-out of ChaiScript
- Run timings again.
- Repeat both timings with
That should give you 4 sets of timings (I’m assuming optimized builds for all tests):
- save_function_params / no threads
- save_function_params / threads
- no save_function_params / no threads
- no save_function_params / threads
Then report back with the timings and your hardware configuration and compiler, that could really help me a lot, to know how much effort I should spend on this.
FYI: I did just run this test myself and am seeing a pretty significant performance difference, let me know how much you see.