In recent years people have started paying more attention to the energy consumption of software and the emissions caused by its use and development. Terms like “green code” and “sustainable software development” have started to appear on the websites and materials of many software companies. However, the growth in energy consumption of software — and ICT as a whole — is a problem that has been recognised for a long time. Despite that, little has been done while compute and energy have been cheap and effectively abundant. The situation is changing quickly. Energy and component price volatility has increased, and the transition to renewable energy sources has accelerated significantly. In software development it is time to stop wasting energy and hardware capacity on poorly designed solutions and move towards building genuinely sustainable software so that the hardware in use can be utilised effectively. At the same time we can preserve good user experience and reasonable costs for developers and users alike.
What is energy-efficient programming?
An energy-efficient program is one that takes into account the impact of running the program, especially its energy consumption. A program's total energy use is made up of many factors which can be divided into three categories: factors during development, factors during program operation, and factors that affect decommissioning [1]. In this post I focus on runtime factors, one of the most important being the program's performance and speed [2]. In addition, things like the program's data transfer and storage also affect energy consumption.
Technology choices — for example the programming language or the database system — significantly influence a program's speed. There are large differences in efficiency between languages, and lower-level languages are often considerably more efficient when there is no heavy runtime environment consuming resources separately [2]. That said, this doesn't mean everything should be rewritten in C. Development speed and the time cost of development are also important. Many newer languages offer a good compromise between efficiency and usability — examples include Go and Rust. A complete rewrite is rarely sensible, so when optimising existing systems it's usually better to look at approaches other than changing the base technology.
Software architecture can also have a large effect on both performance and data transfer. A well-designed program avoids unnecessary code and dependencies, and minimises calls that cause needless data transfers to servers or databases. Effective use of caching helps reduce redundant data transfer and recomputation.
When people talk about “green code” or a program's “greenness”, it's important to consider the program's purpose as well as the code itself. A program that intelligently controls home heating might be implemented inefficiently, but its use can still have a net positive environmental impact because the savings from better heating control outweigh the inefficiency of the code. That said, a program should still be implemented as efficiently as possible, because efficiency also affects user experience and maintenance costs.
Why is software energy efficiency important?
Why should we care about a program's energy consumption? It may seem cheaper to buy more compute capacity than to optimise code. This short-sighted thinking leads to problems later when the software needs further development or must scale to a larger user base. It's much easier to consider efficiency from the start so that scaling costs remain moderate and the application architecture supports growth and continued development rather than hindering them. Thinking about efficiency has other useful effects as well, which this chapter covers.
Operational costs
Efficiency optimisation has a direct impact on the ongoing costs of running software. A well-engineered program requires less energy to do the same work as an inefficient one. In that case, an increase in users does not necessarily require a proportional increase in capacity and cost — the same number of users can be served with less capacity, for example with a cheaper virtual server instance. In one example, AWS Lambda functions written in Rust were compared to implementations in Python and C# and achieved up to three times lower costs [3]. In another case rewriting in Rust allowed reducing an AWS EC2 instance size and produced theoretical compute cost savings of 87% [4]. These results may not directly translate to larger, more complex systems, but they demonstrate that technology choices can have a significant impact on speed and therefore cost.
Smoother user experience
An efficient program typically provides a better user experience. The application starts and loads required content quickly so users don't wait unnecessarily. Efficiency affects not only startup behaviour but also the whole program — speeding up computations and queries, for example — which contributes to a smoother experience. User experience matters because satisfied users are less likely to abandon a product.
Considering usability is important also because a more usable program requires fewer actions and less time from the user to reach their goals, which directly reduces the total energy consumed by the application.
Regulation
From a regulatory perspective, the most important reforms are the European Union's Corporate Sustainability Reporting Directive (CSRD) and changes to the International Financial Reporting Standards (IFRS). Both introduce new requirements for companies around measuring and reporting emissions.
Under the CSRD, large and public companies and smaller companies operating in high-risk sectors must measure and report their environmental impacts. In IT systems there are not yet established practices for measuring emissions. CSRD will also affect smaller companies because they may be part of larger companies' supply chains and thereby fall under reporting obligations [5]. The ability to comply with the directive is likely to influence future partner and procurement decisions.
IFRS decided that companies following the standard must publish their emissions as part of their financial statements for all three scopes; IT systems belong to the third scope and are therefore included in reporting. The timeline for this change is not yet fully determined.
Environmental impact
The ICT sector currently consumes close to 10% of the world's produced energy and the trend is upward [6]. Part of this growth can be mitigated with more energy-efficient hardware, but continual hardware refreshes also have significant environmental costs because electronics recycling is not without problems [7]. It's therefore sensible to approach the problem from both sides: develop better hardware while also optimising software to be more efficient.
Where can I learn more about software energy efficiency?
Green code and energy-efficient programming are relatively new topics, or at least they've only recently gained attention. Teaching materials and expertise are already available. Below are a few sources where you can find more information.
The "Green Code" book
Janne Kalliola from Exove has written an excellent book on the subject. It serves as a good introduction to energy-efficient code and the benefits it can provide. It also gives software developers practical starting points for considering efficiency in their own code. The book is available in both Finnish and English.
Mitvidi
The Mitvidi project has developed metrics for assessing the energy efficiency of public ICT projects. The project has created a criteria set that defines the required level of a project in one of three categories. Knowing these categories and their functional criteria can be useful for those aiming to write more energy-efficient code.
Green ICT
Green ICT is another initiative that supports energy-efficient software. Their site contains materials, tools and news related to energy-efficient software as well as information for developers and procurers.
References
[1] S. Naumann, M. Dick, E. Kern, and T. Johann, “The greensoft model: A reference model for green and sustainable software and its engineering”, Sustainable Computing: Informatics and Systems, vol. 1, no. 4, pp. 294–304, 2011. doi: https://doi.org/10.1016/j.suscom.2011.06.004. Available: https://www.sciencedirect.com/science/article/pii/S2210537911000473
[2] R. Pereira et al., ‘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, Vancouver BC Canada: ACM, Oct. 2017, pp. 256–267. doi: 10.1145/3136014.3136031.
[3] N. Amerasinghe, “How Using AWS Lambda with Rust Saved 3x the Cost Compared to Using Python or .NET — HackerNoon.” https://hackernoon.com/how-using-aws-lambda-with-rust-saved-3x-the-cost-compared-to-using-python-or-net
[4] “I saved 87% on compute costs by switching languages — worldwithouteng.com.” https://worldwithouteng.com/articles/i-saved-87-percent-on-compute-costs-by-switching-languages/
[5] P. Komssi, “Kestävyysraportointidirektiivi astuu voimaan 1.1.2024, miten se koskee pienyritystä?” — yrittajat.fi. https://www.yrittajat.fi/uutiset/kestavyysraportointidirektiivi-astuu-voimaan-1-1-2024-miten-se-koskee-pienyritysta/
[6] E. Gelenbe, “Electricity consumption by ICT: Facts, trends, and Measurements,” Ubiquity, vol. 2023, no. August, pp. 1–15, Aug. 2023. doi:10.1145/3613207
[7] WHO, “Electronic waste (e-waste)”. https://www.who.int/news-room/fact-sheets/detail/electronic-waste-(e-waste)

