Transcription of Energy Efficiency across Programming Languages
1 Energy Efficiency across Programming LanguagesHow Do Energy , Time, and Memory Relate?Rui PereiraHASLab/INESC TECU niversidade do Minho, CoutoHASLab/INESC TECU niversidade do Minho, Ribeiro, Rui RuaHASLab/INESC TECU niversidade do Minho, come CunhaNOVA LINCS, DI, FCTUniv. Nova de Lisboa, o Paulo FernandesRelease/LISP, CISUCU niversidade de Coimbra, o SaraivaHASLab/INESC TECU niversidade do Minho, paper presents a study of the runtime, memory usageand Energy consumption of twenty seven well-known soft-ware Languages . We monitor the performance of such lan-guages using ten different Programming problems, expressedin each of the Languages . Our results show interesting find-ings, such as, slower/faster Languages consuming less/moreenergy, and how memory usage influences Energy consump-tion. We show how to use our results to provide softwareengineers support to decide which language to use whenenergy Efficiency is a Concepts Software and its engineering Soft-ware performance;General Programming Languages ;KeywordsEnergy Efficiency , Programming Languages , Lan-guage Benchmarking, Green SoftwareACM Reference Format:Rui Pereira, Marco Couto, Francisco Ribeiro, Rui Rua, J come Cunha,Jo o Paulo Fernandes, and Jo o Saraiva.
2 2017 . Energy Efficiencyacross Programming Languages : How Do Energy , Time, and Mem-ory Relate?. InProceedings of 2017 ACM SIGPLAN InternationalConference on Software language Engineering (SLE 17).ACM, NewYork, NY, USA, 12 IntroductionSoftware language engineering provides powerful techniquesand tools to design, implement and evolve software lan-guages. Such techniques aim at improving programmersPermission to make digital or hard copies of all or part of this work forpersonal or classroom use is granted without fee provided that copies are notmade or distributed for profit or commercial advantage and that copies bearthis notice and the full citation on the first page. Copyrights for componentsof this work owned by others than ACM must be honored. Abstracting withcredit is permitted. To copy otherwise, or republish, to post on servers or toredistribute to lists, requires prior specific permission and/or a fee.
3 Requestpermissions from 17, October 23 24, 2017 , Vancouver, Canada 2017 Association for Computing ISBN 978-1-4503-5525-4/17/10.. $ - by incorporating advanced features in the lan-guage design, like for instance powerful modular and typesystems - and at efficiently execute such software - by de-veloping, for example, aggressive compiler , most techniques were developed with the main goalof helping software developers in producing faster fact, in the last centuryperformancein software languageswas in almost all cases synonymous offast execution time(embedded systems were probably the single exception).In this century, this reality is quickly changing and soft-ware Energy consumption is becoming a key concern forcomputer manufacturers, software language engineers, pro-grammers, and even regular computer users. Nowadays, itis usual to see mobile phone users (which are powerful com-puters) avoiding using CPU intensive applications just tosave battery/ Energy .
4 While the concern on the computers Energy Efficiency started by the hardware manufacturers, itquickly became a concern for software developers too [28].In fact, this is a recent and intensive area of research whereseveral techniques to analyze and optimize the Energy con-sumption of software systems are being developed. Suchtechniques already provide knowledge on the Energy effi-ciency of data structures [15,27] and android language [25],the Energy impact of different Programming practices both inmobile [18,22,31] and desktop applications [26,32], the en-ergy Efficiency of applications within the same scope [2,17],or even on how to predict Energy consumption in severalsoftware systems [4, 14], among several other interesting question that frequently arises in the soft-ware Energy Efficiency area is whethera faster program isalso an Energy efficient program, or not.
5 If the answer is yes,then optimizing a program for speed also means optimizingit for Energy , and this is exactly what the compiler con-struction community has been hardly doing since the verybeginning of software Languages . However, Energy consump-tion does not depends only on execution time, as shownin the equationEnerдy=Time Pow er. In fact, there areseveral research works showing different results regarding256 SLE 17, October 23 24, 2017 , Vancouver, CanadaR. Pereira et. subject [1,21,27,29,35,38]. A similar question ariseswhen comparing software Languages :is a faster language , agreener one?Comparing software Languages , however, is anextremely complex task, since the performance of a languageis influenced by the quality of its compiler, virtual machine,garbage collector, available libraries, etc. Indeed, a softwareprogram may become faster by improving its source code,but also by "just" optimizing its libraries and/or its this paper we analyze the performance of twenty sevensoftware Languages .
6 We consider ten different programmingproblems that are expressed in each of the Languages , follow-ing exactly the same algorithm, as defined in theComputerLanguage Benchmark Game(CLBG) [12]. We compile/ex-ecute such programs using the state-of-the-art compilers,virtual machines, interpreters, and libraries for each of the27languages. Afterwards, we analyze the performance ofthe different implementation considering three variables:execution time, memory consumption and Energy consump-tion. Moreover, we analyze those results according to thelanguages execution type (compiled, virtual machine andinterpreted), and Programming paradigm (imperative, func-tional, object oriented, scripting) used. For each of the exe-cution types and Programming paradigms, we compiled asoftware language ranking according to each variable consid-ered. Our results show interesting findings, such as, slower/-faster software Languages consuming less/more Energy , andhow memory usage influences Energy consumption.
7 More-over, we discuss how to use such results to provide softwareengineers support to decide which language to use whenenergy Efficiency is a work builds on previous work [6] which presentsa framework to allow the monitoring of the Energy con-sumption of executable software programs. In that work, theC-based framework was used to define a preliminary rankingof ten Languages (where only Energy was considered). Wereuse the Energy monitoring framework (briefly described inSection ) to analyze the Energy Efficiency of27languagesand (almost)270programs. We have also extended it in orderto monitor memory consumption, as paper is organized as follows: Section 2 exposes thedetailed steps of our methodology to measure and compareenergy Efficiency in software Languages , followed by a pre-sentation of the results. Section 3 contains the analysis anddiscussion on the obtained results, where we first analyzewhether execution time performance implies Energy effi-ciency, then we examine the relation between peak mem-ory usage and memory Energy consumption, and finally wepresent a discussion on how Energy , time and memory re-late in the27software Languages .
8 In Section 4 we discussthe threats to the validity of our study. Section 5 presentsthe related work, and finally, in Section 6 we present theconclusions of our Measuring Energy in SoftwareLanguagesThe initial motivation and primary focus of this work is tounderstand the Energy Efficiency across various program-ming Languages . This might seem like a simple task, but itis not as trivial as it sounds. To properly compare the en-ergy Efficiency between Programming Languages , we mustobtain various comparable implementations with a goodrepresentation of different this in mind, we begin by trying to answer the fol-lowing research question: RQ1:Can we compare the Energy Efficiency of softwarelanguages?This will allow us to have results in whichwe can in fact compare the Energy Efficiency of pop-ular Programming Languages . In having these results,we can also explore the relations between Energy con-sumption, execution time, and memory following subsections will detail the methodologyused to answer this question, and the results we The Computer language Benchmarks GameIn order to obtain a comparable, representative and extensiveset of programs written in many of the most popular andmost widely used Programming Languages we have exploredThe Computer language Benchmarks Game [12].
9 (CLBG).The CLBG initiative includes a framework for running,testing and comparing implemented coherent solutions fora set of well-known, diverse Programming problems. Theoverall motivation is to be able to compare solutions, withinand between, different Programming Languages . While theperspectives for comparing solutions have originally essen-tially analyzed runtime performance, the fact is that CLBGhas recently also been used in order to study the energyefficiency of software [6, 21, 25].In its current stage, the CLBG has gathered solutions for 13benchmark problems, such that solutions to each such prob-lem must respect a given algorithm and specific implemen-tation guidelines. Solutions to each problem are expressedin, at most, 28 different Programming complete list of benchmark problems in the CLBG covers different computing problems, as described in Table , the complete list of Programming Languages inthe CLBG is shown in Table 2, sorted by their Design and ExecutionOur case study to analyze the Energy Efficiency of softwarelanguages is based on the the 28 Languages considered in the CLBG, we ex-cludedSmalltalksince the compiler for that language is pro-prietary.
10 Also, for comparability, we have discarded bench-mark problems whose language coverage is below the thresh-old of 80%. By language coverage we mean, for each bench-mark problem, the percentage of Programming languages257 Energy Efficiency across Programming LanguagesSLE 17, October 23 24, 2017 , Vancouver, CanadaTable corpus of precision N-bodysimulation50 Mfannkuch-reduxIndexed access to tiny integersequence12spectral-normEigenvalue using the powermethod5,500mandelbrotGenerate Mandelbrot setportable bitmap file16,000pidigitsStreaming arbitrary precisionarithmetic10,000regex-reduxMatc h DNA 8mers andsubstitute magic patternsfastaoutputfastaGenerate and write randomDNA sequences25Mk-nucleotideHashtable update andk-nucleotide stringsfastaoutputreverse-complementRead DNA sequences, writetheir reverse-complementfastaoutputbinary-tree sAllocate.