# Minimizing Energy and Computation in Long-Running Software
## 1 Introduction  
Long-running programs include database systems, operating systems, and platforms that support sensor systems. Such software needs to be very reliable, but should also be efficient in execution time and energy consumption. Thus its reliability [1] is often assured via checkpoints, to avoid that each failure leads to excessive overhead in execution time [2, 3, 4] and energy consumption [5]. Indeed, among the mechanisms that restore or preserve system consistency after failures [6], Checkpointing and Recovery (CR) is used widely to periodically save an up-to-date copy of system or program state that is used to restart execution if a failure occurs. CR can also be found in high performance systems [7, 8, 9, 10], operating systems including Linux [11, 12, 13], databases [14], and distributed systems [15, 16, 17, 18]. Thus checkpoint intervals have been widely studied to maximize system availability and minimize program execution time for transaction-oriented systems [19, 20, 21], and imbedded multiple level checkpoints introduced in [22, 23] were recently studied in [24]. CR [6, 25] includes \"Application-level Checkpoint and Restart\" (ALCR) [26, 27], that uses smaller memory space but requires significant programming skills to insert checkpoints in long-running loops [28, 29]. Since longer inter-checkpoint intervals increase the required time and energy of system restart, and short intervals increase them due to frequent checkpoints, the checkpoint interval should be chosen to minimizeboth energy consumption and execution time [30; 31]. In recent years the importance of energy savings in information technology and software has been often emphasized [32; 33; 34; 35], and research has addressed the efficient allocation of energy in computer systems [36; 37; 38] including the use of of server or network node vacations to reduce energy consumption [39], techniques to select Cloud servers based on energy efficiency [40], and the use of renewable energy sources [41; 42; 43; 44]. There has been less work on more detailed techniques such as checkpoints to reduce energy consumption [45; 46], or on checkpoint optimization in modern software using ALCR [47; 48]. In addition, commonly used tools such as ALCR do not offer assistance in selecting checkpoint intervals to optimize energy consumption or execution time, and a software tool was proposed recently to address this issue [49]. Thus in this paper we focus on analyzing the checkpoint intervals in a unified manner to effect savings in a weighted combination of execution time and energy, since energy consumption is of importance both in autonomously operating platforms and for software running in large scale Cloud data centers [50]. In the sequel, starting from first principles, we develop a mathematical model to estimate the average execution time as well as the energy consumption of a program with long loops that operates in the presence of failures, without and with ALCR. This allows us to compute the checkpoint interval that minimizes the program's energy consumption and average execution time, and its value that can minimize a cost function that is a weighted sum of both elements, expressed via the Lambert Function, with numerical examples that illustrate the results. In addiion, we also apply these results to a well known software benchmark. The rest of the paper is structured as follows. In Section 2, the mathematical model that estimates the average execution time and energy consumption of a software program that operates in the presence of failures with and without checkpoints is presented. In Section 3, based on this mathematical model, the closed-form expression of the optimum checkpoint interval is derived. In Section 4, we illustrate our results through a set of numerical examples.