From my understanding of persistent programming models, it is up to the programmer to correctly distinguish the volatile variables as opposed to the persistent variables. Persistent variables would require some kind of atomic updates so that if a power failure occurs, the recovery program can clean up the program's data into a consistent state.
For example, if I insert a node to the beginning of a linked list with a persistent memory backed program, I would have to do the following:
- Create the new node with the new data inside it
- link the "next" pointer to the current head of the linked list
- then update the head pointer to point to the new node.
Each step has to be performed with either undo-log or redo-log to assist the recovery program for consistent state of the data. Also, each step must be persisted through flushes and fences.
Programmers want to identify which variables must survive the failure and which are not important so that they do not need the overhead ("logging" and "flush & fence"). This is much harder than it sounds like and there is much research and tools regarding it.
Now here is my question. Assuming that my understanding of the persistent programming model is correct, would treating all the volatile variables (e.g., loop counter) as persistent variables ever be incorrect? I understand that it would cause significant overhead and it is identified as "performance bug". I would appreciate if there are any cases where persisting a volatile variable would affect the correctness of the recovery program.
Thank you.