Improving energy-efficiency by recommending Java collections

Abstract

Over the last years, increasing attention has been given to creating energy-efficient software systems. However, developers still lack the knowledge and the tools to support them in that task. In this work, we explore our vision that non-specialists can build software that consumes less energy by alternating diversely-designed pieces of software without increasing the development complexity. To support our vision, we propose an approach for energy-aware development that combines the construction of application-independent energy profiles of Java collections and static analysis to produce an estimate of in which ways and how intensively a system employs these collections. We implement this approach in a tool named CT+ that works with both desktop and mobile Java systems and is capable of analyzing 39 different collection implementations of lists, maps, and sets. We applied CT+ to seventeen software systems: two mobile-based, twelve desktop-based, and three that can run in both environments. Our evaluation infrastructure involved a high-end server, two notebooks, three smartphones, and a tablet. Overall, 2295 recommendations were applied, achieving up to 16.34% reduction in energy consumption, usually changing a single line of code per recommendation. Even for a real-world, mature system such as Tomcat, CT+ could achieve a 4.12% reduction in energy consumption. Our results indicate that some widely used collections, e.g., ArrayList, HashMap, and Hashtable, are not energy- efficient and sometimes should be avoided when energy consumption is a major concern.

This is a preview of subscription content, access via your institution.

Fig. 1
Fig. 2
Fig. 3

Notes

  1. 1.

    ONU sustainable goals: https://sdgs.un.org/goals

  2. 2.

    EU guidelines: https://ec.europa.eu/commission/sites/beta-political/files/political-guidelines-next-commission_en.pdf

  3. 3.

    Gist website: http://gist.github.com

  4. 4.

    StackOverflow website: https://stackoverflow.com

  5. 5.

    Java Collections Framework webiste: https://docs.oracle.com/javase/8/docs/technotes/guides/collections/

  6. 6.

    Apache Commons Collections website: https://commons.apache.org/proper/commons-collections/

  7. 7.

    Eclipse Collections website: https://www.eclipse.org/collections/

  8. 8.

    WALA website: http://wala.sourceforge.net/wiki/index.php/Main_Page

  9. 9.

    Maven’s new policy: https://central.sonatype.org/articles/2019/Apr/30/http-access-to-repo1mavenorg-and-repomavenapacheorg-is-being-deprecated/

  10. 10.

    Summary about hyper-threading: https://en.wikipedia.org/wiki/Hyper-threading

  11. 11.

    Xalan project: https://github.com/apache/xalan-java

  12. 12.

    DaCapo website: http://dacapobench.sourceforge.net/benchmarks.html

  13. 13.

    Available at: https://www.eclipse.org/collections/

  14. 14.

    On our experiments, the threshold was 100 times slower

References

  1. Aggarwal K, Zhang C, Campbell JC, Hindle A, Stroulia E (2014) The power of system call traces: predicting the software energy consumption impact of changes. In: Proceedings of 24th Annual International Conference on Computer Science and Software Engineering, CASCON 2014. IBM / ACM, pp 219–233

  2. Andrae A (2017) Total consumer power consumption forecast. Nordic Digital Business Summit 10

  3. Baldwin CY, Clark KB Design rules, volume 1: The power of modularity, vol 1, 1st edn. The MIT Press

  4. Barrett E, Bolz-Tereick CF, Killick R, Mount S, Tratt L (October 2017a) Virtual machine warmup blows hot and cold. Proc ACM Program Lang 1 (OOPSLA):52:1–52:27. https://doi.org/10.1145/3133876

    Article  Google Scholar 

  5. Bennett J, Lanning S, Netflix N (2007b) The netflix prize. In: In KDD Cup and Workshop in conjunction with KDD

  6. Blackburn SM, Garner R, Hoffmann C, Khang AM, McKinley KS, Bentzur R, Diwan A, Feinberg D, Frampton D, Guyer S Z, Hirzel M, Hosking A, Jump M, Lee H, Moss JEB, Phansalkar A, Stefanović D, VanDrunen T, von Dincklage D, Wiedermann B (2006) The dacapo benchmarks: Java benchmarking development and analysis. In: Proceedings of the 21st Annual ACM SIGPLAN Conference on Object-oriented Programming Systems, Languages, and Applications, OOPSLA ’06. ACM, New York, pp 169–190. https://doi.org/10.1145/1167473.1167488

  7. Chen Q, Grosso P, Van Der Veldt K, De Laat C, Hofman R, Bal H (2011) Profiling energy consumption of VMs for green cloud computing. In: Proceedings - IEEE 9th International Conference on Dependable, Autonomic and Secure Computing, DASC 2011, pp 768–775

  8. Chowdhury SA, Hindle A (2016) Characterizing energy-aware software projects: Are they different? In: Proceedings of the 13th International Conference on Mining Software Repositories, MSR ’16. ACM, New York, pp 508–511. https://doi.org/10.1145/2901739.2903494

  9. Chowdhury SA, Hindle A, Kazman R, Shuto T, Matsui K, Kamei Y (2019a) Greenbundle: An empirical study on the energy impact of bundled processing. In: 2019 IEEE/ACM 41st International Conference on Software Engineering (ICSE), pp 1107–1118

  10. Chowdhury S, Borle S, Romansky S, Hindle A (August 2019b) Greenscaler: Training software energy models with automatic test generation. Empir Softw Engg 24(4):1649–1692. https://doi.org/10.1007/s10664-018-9640-7

    Article  Google Scholar 

  11. Cliff N (1993) Answering ordinal questions with ordinal data using ordinal statistics. Multivar Behav Res 31:331–350. https://doi.org/10.1207/s15327906mbr3103_4

    Article  Google Scholar 

  12. Costa D, Andrzejak A, Seboek J, Lo D (2017) Empirical study of usage and performance of java collections. In: Proceedings of the 8th ACM/SPEC on International Conference on Performance Engineering, ICPE ’17. ACM, New York, pp 389–400. https://doi.org/10.1145/3030207.3030221

  13. Cruz L, Abreu R (2017) Performance-based guidelines for energy efficient mobile applications. In: Proceedings of the 4th International Conference on Mobile Software Engineering and Systems, MOBILESoft ’17. IEEE Press, pp 46–57. https://doi.org/10.1109/MOBILESoft.2017.19

  14. Duarte LM, da Silva Alves D, Toresan BR, Maia PH, Silva D (2019) A model-based framework for the analysis of software energy consumption. In: Proceedings of the XXXIII Brazilian Symposium on Software Engineering, SBES 2019. Association for Computing Machinery, New York, pp 67–72. https://doi.org/10.1145/3350768.3353813

  15. Georges A, Buytaert D, Eeckhout L (October 2007) Statistically rigorous java performance evaluation. SIGPLAN Not 42 (10):57–76. https://doi.org/10.1145/1297105.1297033

    Article  Google Scholar 

  16. Georgiou S, Spinellis D (2020) Energy-delay investigation of remote inter-process communication technologies. J Syst Softw 162:110506. https://doi.org/10.1016/j.jss.2019.110506, http://www.sciencedirect.com/science/article/pii/S0164121219302808

    Article  Google Scholar 

  17. Hähnel M, Döbel B, Völp M, Härtig H (January 2012) Measuring energy consumption for short code paths using rapl. SIGMETRICS Perform Eval Rev 40(3):13–17. https://doi.org/10.1145/2425248.2425252

    Article  Google Scholar 

  18. Hao S, Li D, Halfond WGJ, Govindan R (2013) Estimating mobile application energy consumption using program analysis. In: Proceedings of the 2013 International Conference on Software Engineering, ICSE ’13. IEEE Press, Piscataway, pp 92–101. http://dl.acm.org/citation.cfm?id=2486788.2486801

  19. Hasan S, King Z, Hafiz M, Sayagh M, Adams B, Hindle A (2016) Energy profiles of java collections classes. In: Proceedings of the 38th International Conference on Software Engineering, New York, pp 225–236. https://doi.org/10.1145/2884781.2884869

  20. Lee J, Chon Y, Cha H (2015) Evaluating battery aging on mobile devices. In: 2015 52nd ACM/EDAC/IEEE Design Automation Conference (DAC), pp 1–6

  21. Li D, Hao S, Gui J, Halfond WGJ (2014a) An empirical study of the energy consumption of android applications. In: 30th IEEE International Conference on Software Maintenance and Evolution, pp 121–130

  22. Li D, Tran AH, Halfond WGJ (2014b) Making web applications more energy efficient for OLED smartphones. In: 36th International Conference on Software Engineering (ICSE’2014). ACM, pp 527–538

  23. Lima L G, Soares-Neto F, Lieuthier P, Castor F, Melfe G, Fernandes JP (2016) Haskell in Green Land: Analyzing the Energy Behavior of a Purely Functional Language. In: 2016 IEEE 23rd International Conference on Software Analysis, Evolution, and Reengineering (SANER), vol 1, pp 517–528

  24. Lin Y, Dig D (2015) A study and toolkit of CHECK-THEN-ACT idioms of java concurrent collections. Softw Test Verif Reliab 25(4):397–425

    Article  Google Scholar 

  25. Linares-Vásquez M, Bavota G, Bernal-Cárdenas C, Oliveto R, Di Penta M, Poshyvanyk D (2014) Mining energy-greedy api usage patterns in android apps: An empirical study. In: Proceedings of the 11th Working Conference on Mining Software Repositories, MSR 2014. ACM, New York, pp 2–11. https://doi.org/10.1145/2597073.2597085

  26. Linares-Vásquez M, Bavota G, Cárdenas CEB, Oliveto R, Di Penta M, Poshyvanyk D (2015) Optimizing energy consumption of guis in android apps: A multi-objective approach. In: Proceedings of the 2015 10th Joint Meeting on Foundations of Software Engineering, ESEC/FSE 2015. ACM, New York, pp 143–154

  27. Linares-Vásquez M, Bavota G, Bernal-Cárdenas C, Penta MD, Oliveto R, Poshyvanyk D (2018) Multi-objective optimization of energy consumption of guis in android apps. ACM Trans Softw Eng Methodol 27(3):14:1–14:47

    Article  Google Scholar 

  28. Liu K, Pinto G, Liu D (2015) Data-oriented characterization of application-level energy optimization. In: Proceedings of the 18th International Conference on Fundamental Approaches to Software Engineering, FASE’15

  29. Lyu Y, Gui J, Wan M, Halfond WGJ (2017) An Empirical Study of Local Database Usage in Android Applications. In: Proceedings of the International Conference on Software Maintenance and Evolution (ICSME)

  30. Manotas I, Pollock L, Clause J (2014) Seeds: A software engineer’s energy-optimization decision support framework. In: Proceedings of the 36th International Conference on Software Engineering, ICSE 2014, pp 503–514. https://doi.org/10.1145/2568225.2568297

  31. Manotas I, Bird C, Zhang R, Shepherd D, Jaspan C, Sadowski C, Pollock L, Clause J (2016) An empirical study of practitioners’ perspectives on green software engineering. In: ICSE, pp 237–248

  32. Mcintosh A, Hassan S, Hindle A (April 2019) What can android mobile app developers do about the energy consumption of machine learning?. Empir Softw Engg 24(2):562–601. https://doi.org/10.1007/s10664-018-9629-2

    Article  Google Scholar 

  33. Mingay S (2007) Green IT: The new industry shockwave. Gartner RAS Core Research Note G00153703

  34. Oliveira W, Oliveira R, Castor F (2017) A Study on the Energy Consumption of Android App Development Approaches. In: 2017 IEEE/ACM 14th International Conference on Mining Software Repositories (MSR)

  35. Oliveira W, Oliveira R, Castor F, Fernandes B, Pinto G (2019) Recommending energy-efficient java collections. In: 2019 IEEE/ACM 16th International Conference on Mining Software Repositories (MSR), pp 160–170

  36. Pang C, Hindle A, Adams B, Hassan A E (2016) What do programmers know about software energy consumption?. IEEE Softw 33(3):83–89. https://doi.org/10.1109/MS.2015.83

    Article  Google Scholar 

  37. Pereira R, Couto M, Saraiva J, Cunha J, Fernandes JP (2016) The Influence of the Java Collection Framework on Overall Energy Consumption. In: Proceedings of the 5th International Workshop on Green and Sustainable Software, GREENS ’16. ACM, New York, pp 15–21. https://doi.org/10.1145/2896967.2896968

  38. Pereira R, Couto M, Ribeiro F, Rua R, Cunha J, Fernandes JP, Saraiva J (2017) Energy Efficiency Across Programming Languages: How Do Energy, Time, and Memory Relate? In: Proceedings of the 10th ACM SIGPLAN International Conference on Software Language Engineering, SLE 2017. ACM, New York, pp 256–267. https://doi.org/10.1145/3136014.3136031

  39. Pereira R, Simão P, Cunha J, Saraiva J (2018) jStanley: Placing a Green Thumb on Java Collections. In: Proceedings of the 33rd ACM/IEEE International Conference on Automated Software Engineering, ASE 2018. ACM, New York, pp 856–859. https://doi.org/10.1145/3238147.3240473

  40. Peterson M (2009) Decisions under ignorance. In: An Introduction to Decision Theory, Cambridge Introductions to Philosophy. Cambridge University Press, pp 40–63

  41. Pinto G, Castor F, Liu Y (2014a) Mining questions about software energy consumption. In: Proceedings of the 11th Working Conference on Mining Software Repositories, MSR 2014, pp 22–31

  42. Pinto G, Castor F, Liu Y D (2014b) Understanding energy behaviors of thread management constructs. In: Proceedings of the 2014 ACM International Conference on Object Oriented Programming Systems Languages and Applications, OOPSLA ’14, pp 345–360

  43. Pinto G, Liu K, Castor F, Liu YD (2016) A comprehensive study on the energy efficiency of java thread-safe collections. In: ICSME

  44. Rocha G, Castor F, Pinto G (2019) Comprehending energy behaviors of java i/o apis. In: 2019 ACM/IEEE International Symposium on Empirical Software Engineering and Measurement (ESEM), pp 1–12

  45. Rodrigues RE, Alves P, Pereira F, Gonnord L (2014) Real-world loops are easy to predict: a case study. In: Workshop on Software Termination (WST’14)

  46. Romano J, Kromrey JD, Coraggio J, Skowronek J (2006) Appropriate statistics for ordinal level data: Should we really be using t-test and cohen’s d for evaluating group differences on the NSSE and other surveys? In: Annual meeting of the Florida Association of Institutional Research

  47. Romansky S, Borle NC, Chowdhury S, Hindle A, Greiner R (2017) Deep green: Modelling time-series of software energy consumption. In: 2017 IEEE International Conference on Software Maintenance and Evolution (ICSME), pp 273–283

  48. Saborido R, Morales R, Khomh F, Guéhéneuc Y-G, Antoniol G (2018) Getting the most from map data structures in Android. Empir Softw Eng. https://doi.org/10.1007/s10664-018-9607-8

  49. Sahin C, Cayci F, Gutiérrez ILM, Clause J, Kiamilev F, Pollock L, Winbladh K (2012) Initial explorations on design pattern energy usage. In: 2012 1st International Workshop on Green and Sustainable Software, GREENS 2012 - Proceedings, pp 55–61

  50. Sahin C, Pollock L, Clause J (2014) How do code refactorings affect energy usage? In: Proceedings of the 8th ACM/IEEE International Symposium on Empirical Software Engineering and Measurement, ESEM ’14, pp 36:1–36:10

  51. Shapiro SS, Wilf MB (1965) An Analysis of Variance Test for Normality (complete samples). Biometrika 52(3-4):591–611

    MathSciNet  Article  Google Scholar 

  52. Šimunić T, Benini L, De Micheli G, Hans M (2000) Source code optimization and profiling of energy consumption in embedded systems. In: Proceedings of the International Symposium on System Synthesis, pp 193–198

  53. Wan M, Jin Y, Li D, Gui J, Mahajan S, Halfond William GJ (2017) Detecting display energy hotspots in android apps. Softw Test Verif Reliab 27(6):16–35

    Article  Google Scholar 

  54. Wilks D S (2011) Statistical methods in the atmospheric sciences. Elsevier Academic Press, Amsterdam. https://www.amazon.com/Statistical-Atmospheric-Sciences-International-Geophysics/dp/0123850223/ref=pd_bxgy_14_img_3?_encoding=UTF8&psc=1&refRID=ESPQQ0R2PB1TP1VJSGCZ

Download references

Acknowledgments

We would like to thank the anonymous reviewers for helping to improve this paper. This paper acknowledges the support of the Erasmus+ Key Action 2 (Strategic partnership for higher education) project No. 2020-1-PT01-KA203-078646: ”SusTrainable - Promoting Sustainability as a Fundamental Driver in Software Development Training and Education”. The information and views set out in this paper are those of the author(s) and do not necessarily reflect the official opinion of the European Union. Neither the European Union institutions and bodies nor any person acting on their behalf may be held responsible for the use which may be made of the information contained therein. This research was partially funded by CAPES/Brazil (88887.364121/2019-00), CNPq/Brazil (304755/2014-1, 406308/2016-0, 465614/2014-0, 309032/2019-9), FACEPE/Brazil (APQ-0839-1.03/14, 0388-1.03/14, 0592-1.03/15).

Author information

Affiliations

Authors

Corresponding author

Correspondence to Wellington Oliveira.

Additional information

Publisher’s note

Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

This article belongs to the Topical Collection: Recommendation Systems for Software Engineering

Communicated by: Ali Ouni, David Lo, Xin Xia, Alexander Serebrenik and Christoph Treude

Rights and permissions

Reprints and Permissions

About this article

Verify currency and authenticity via CrossMark

Cite this article

Oliveira, W., Oliveira, R., Castor, F. et al. Improving energy-efficiency by recommending Java collections. Empir Software Eng 26, 55 (2021). https://doi.org/10.1007/s10664-021-09950-y

Download citation

Keywords

  • Energy consumption
  • Collections
  • Recommendation systems