| OCR Text |
Show provide execution states. The history cache guarantees that the process state will be correctly restored at execution states, although it does not preserve the order of history elements. A history cache is most effective in compacting the history if the program reads many values, but writes only a few. Often the difference between code with a good history compaction performance and code with a bad history compaction performance is minimal. An example of "good" code is computing the sum of the elements of an array (see Figure 5.10). This code reads n elements from array a, but changes only the values of two variables, i and sum. Regardless of the value of n, at most two locations are added to the history cache. An example of "bad" code is initializing an array (see Figure 5.11). In this case, the code changes n elements of array a and the loop index i. Furthermore, since no element of a is changed twice, no history compaction is possible on these elements. 5.4.4 Additional History Reduction Methods A background process can be used to compact the history even further. The background process can remove any execution state from the history and merge two history intervals before and after this execution state. During merging, the sum = 0; for (i = 0; i < n; i++) sum += a[i]; Figure 5.10. An Example of Code with "Good" History Compaction fo r ( i = 0; i < n; i++) a [ i ] = 0; Figure 5.11. An Example of Code with "Bad" History Compaction |