periodic checkpointing.
add periodicCheckpoint() function.