Kranc icon indicating copy to clipboard operation
Kranc copied to clipboard

Only update generated files if they have changed

Open ianhinder opened this issue 15 years ago • 1 comments

Kranc currently deletes the generated thorn and replaces it with the new version. This causes the CCL files to have a different datestamp, and the CST to be re-run. In many cases, this is unnecessary and takes a lot of time.

We could instead keep the old version of the thorn, and only update the files if they have changed. This should lead to the minimal amount of recompilation. This could be done by writing a temporary version of each file and using an external diff tool to see if the new and old versions are the same. If they are the same, just remove the temporary. If they are different, replace the original with the temporary. There might be a problem with spawning many versions of "diff". Should investigate if diff can be given pairs of files to check on a single invokation.

ianhinder avatar Mar 01 '10 22:03 ianhinder

An additional optimisation would be to avoid reprocessing calculations which have not changed. We could store the Mathematica calculation definition with the generated thorn, and compare the new with the old when generating the new calculation. One problem with this approach is that a calculation might change due to options/settings outside the calculation itself, e.g. in the options to CreateThorn. A solution would be to ensure internally that the function which generates the calculation takes all required information as an argument (the "augmented" calculation, containing any extra options), and storing this, rather than the user's original "bare" calculation. Storing the whole calculation might be distracting, so we could consider storing a hash instead. This touches on the issue of storing the original Kranc script along with the generated thorn for provenance and reproducibility purposes.

ianhinder avatar Sep 04 '13 06:09 ianhinder