Behavior on Code Change
This page describes the cases where the checkpointed function could be correctly skipped by retrieving the cached value, and cases where it would be correctly re-executed.
Attention
All examples on this page have correct results. However, there are some cases where the function will be incorrectly skipped, or not using the cache as expected. Please see Caveats.
How the cases are written
The cases are generally written in the following format of two tabs.
This denotes:
- First, you have the script in the "1st run" tab. Running it gives you the corresponding output.
- Next, modify the script and change it to what's shown in the "2nd run" tab. Running it gives you another result, and it shows how the function gets skipped or re-executed.
If you want to try it out, please remember to clear the cache directory
(./.checkpointing
by default) between two cases, as one case might affect another.
Skipped cases
Renaming parameters
When executing the modified script,
foo
will be skipped as the checkpoint figured that the code change is only about renaming function parameters.
The result will be retrieved from the cache.
Renaming variables
When executing the modified script,
foo
will be skipped as the checkpoint figured that the code change is only about renaming those variables.
The result will be retrieved from the cache.
Renaming the function
When executing the modified script,
bar
will be skipped as the checkpoint figured that its logic is the same as the earlier foo
.
The result will be retrieved from the cache.
Adding comments and type annotations
When executing the modified script,
foo
will be skipped as the checkpoint figured that it's only adding type annotations and comments.
The result will be retrieved from the cache.
Changing default values
When executing the modified script, foo
will be skipped as the checkpoint figured that the actual value of a
is 1
in both executions.
The result will be retrieved from the cache.
This also works if you remove or add a default value to a parameter. In short, checkpoint does not care about the defaults; it only considers what arguments are plugged in.
Changing value of irrelevant global variables
When executing the modified script, foo
will be skipped as the checkpoint figured that X
is not referenced in the function code,
although its value has changed.
Formatting the code
When executing the modified script,
foo
will be skipped as the checkpoint figured that the code change is only about formatting.
Re-executed cases
Changing arguments
When executing the modified script, foo
will be re-executed and return the correct result, 1
,
because checkpoint finds that the passed arguments are different.
Changing code logic
When executing the modified script, foo
will be re-executed and return the correct result, -1
,
because checkpoint finds that the actual code logic of foo
has changed.
Changing value of reference global variables
When executing the modified script,
foo will be re-executed and return the correct result, 1
,
because checkpoint finds that the value of a reference global variable has been modified.