However, when it comes to carbon emissions, software development has not always been considered a contributor. Easy examples of this are taking the easy route of bringing in yet another runtime, framework, or cloud service to make their jobs easier rather than considering how well the code will work.
This may sound technical, but this one piece of code required a high number of complicated and expensive processes to be running underneath the surface. So, what is happening behind the curtains in this example? How much CPU, RAM and disk are consumed and how would that scale across all the thousands of desktop machines in a big company? How much liquid black gold is being turned into carbon dioxide for this one piece of badly designed code?
Are the choices of technology, the software development practices or even how code is written doing more damage to the planet than we first realised?
The Dell Precision laptop this blog has been written on is powerful, with four cores, 16 gigs of RAM and a five-twelve hard disk. The hardware monitor application running at the same time is helpfully reporting that the CPU cores are tripping along at a few per cent of capacity, the temperature is a cool six degrees centigrade, and the power usage is somewhere near five watts.
If Visual Studio and an app development project are opened and the debugger is launched. Visual Studio compiles the code, kicks off the android emulator and starts debugging. The computer appears very unhappy at so many difficult demands being made — the CPU goes into overdrive and the temperature climbs higher than ninety degrees in each core. The fan attempts to compensate and cool everything down, but core temperatures are still spiking continuously into the high eighties and early nineties.
This equates to a power consumption of over 30 watts and although the monitor application can’t interrogate the fan, it can easily consume another three or four watts of power. This amounts to a difference of about 30 watts or 0.03-kilowatt hours compared to when the machine was idling along before running Microsoft Word. Now, this isn’t a bug with Visual Studio, the same problem can be replicated by running Microsoft PowerPoint or by having too many tabs open in Google Chrome. The Dell goes into overdrive with all four cores clocking in near boiling point, consuming a massive amount of energy.
According to the US Energy Information Administration, 0.03 kilowatt hours is equivalent to 0.0174 pounds of carbon based on energy production in America. Let us imagine that the application example we’ve just used has been deployed to all staff in a bank which has 26,498 employees and the bad code is already maxing out desktop CPUs all over the country. For every hour of execution, this bank will be generating 461 pounds of carbon. That’s 3,689 pounds per day and a staggering 1,346,310 pounds per year — the equivalent of 610 metric tons of carbon dioxide.
Climate consultants Selectra believe that it takes six trees to shift one metric ton of carbon so, a bank of this size would need to plant 3,660 trees per year to counteract that piece coding we’ve just explained
These numbers are highly subjective, and the application won’t be continual, but we must consider what else is installed on the machine, there’s a possibility that the computer is coming down with bad quality software, all of which is putting too many demands on the system. The figures however paint a picture that IT and software do have a part to play in reducing carbon emissions and that bad coding practices really could have a negative impact on the world.
Close that Code Project tab and take another look at the code.
So, what are we going to do about it?
Journey with Expleo through this series of blogs as we explore together methods of minimising the quantity of energy used in software development. We’ll dive into three target areas where savings can be made.
Firstly, development processes and reducing energy by optimising the way we build and automatically test the software. We’ve seen companies where huge networks of high-end servers are continually maxed out on automated CI/CD build and test pipelines. We’ll look at the different types of functional and non-functional testing and the impact they can have on energy consumption.
Secondly, technologies and platforms. Which technologies are hugely wasteful and which ones will perform well without producing large amounts of carbon? We’ll look at development platforms and frameworks as well as cloud providers, infrastructure, and RPC technologies.
Finally, coding practices. Good programming techniques can vastly increase performance, reduce system requirements, and ensure that code runs effectively and efficiently never consuming more than the bare minimum number of resources.
Can you begin to think about how you can optimise your own practices to help save the planet? Think about writing more unit tests and fewer automated tests and getting the code working locally first rather than kicking off multiple CI/CD pull requests.