Could Callous Computer Coding Kill the Climate?


Could Callous Computer Coding Kill the Climate?

Green Computing, do we care?

Climate change is on the agenda. Young girls to older TV wildlife presenters are galivanting around the world telling us we’re destroying the planet and shouting that we need to do something about it NOW! But sure, it’s all down to the coal-fired power stations and of course, those people who continue to drive around in big diesel engine cars. Those guys need to sit up and smell the coffee, turn things around and go out and buy a Prius or an ID3 (if they can get one)!

Good job that software developers don’t generate any carbon. Or do they? I’m talking to all those dark-side programmers out there that take 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 actually work.

Recently, I attended an IT industry conference where they waxed on about saving carbon by building software for specific CPU architectures like Intel or AMD. One speaker showed a wonderful piece of code that printed out the name of the CPU and was obviously far more efficient and better for the environment. In reality, his code was written in JavaScript, executed in a browser and wrapped in a container. In turn, this ran within a Kubernetes cluster, hosted on a VM, then on a hypervisor which itself ran on the operating system before getting down to the actual hardware, (phew).

Now, this all sounds very technical but what it really means, in a nutshell, is that this one innocent piece of code required a huge number of extremely complicated and expensive processes to be running underneath the surface. So what is actually 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, software development practices or even how code is written doing more damage to the planet than we first realized?

Falling to the dark side, Anakin Skywalker abandons all good coding practices and pulls down dodgy, un-performant javascript frameworks from the Internet that get the job done quick.

It’s a familiar experience to most to have our computer’s suddenly slow down, the fan starting up and the machine radiating so much heat that it could set the desk on fire. Quick! Either crack an egg onto the casing and make a nice buttie, or kill off a few processes before the machine explodes.

Now let’s be honest, most of the time this manic buzz of activity is caused by a virus scanner or a windows update, but what about if it was your bad code heating up the office? Well, before we get too excited and start talking about what to do about it, let’s step back and ask if it’s worth our attention in the first place.


Some Numbers

My Dell Precision laptop that I’m typing this into is pretty powerful, with four cores, sixteen gigs of RAM and a five-twelve hard disk. As I’m beavering away with Microsoft Word, the hardware monitor application running at the same time is helpfully reporting that the CPU cores are tripping along happily 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 I now fire up Visual Studio, open a mobile app development project and launch the debugger, things start to get a bit fruity. 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 of it as the CPU goes into overdrive and the temperature climbs higher than ninety degrees in each core. The fan pathetically attempts to compensate and cool everything down but core temperatures are still spiking continuously into the high eighties and early nineties.

This equates to power consumption of over thirty watts and although my monitor application can’t interrogate the fan, I’m reliably informed that it can easily consume another three or four watts of power. This amounts to a difference of about thirty watts or 0.03-kilowatt hours compared to when the machine was idling along before running Microsoft Word. Now, don’t be fooled into thinking that this is a bug with Visual Studio, I can easily replicate exactly the same problem running Microsoft PowerPoint or even Google Chrome with too many tabs open.

The Dell goes into overdrive with all four cores clocking in near boiling point. Almost certainly it’s using the same amount of energy as a small European country.


In the Clear?

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. Phew, that’s fine, it’s a tiny number, nothing to worry about, and certainly insufficient to melt any glaciers, or cause any tidal waves.

So we don’t need to care after all. Relax! Just settle back and open up a few extra browser tabs and stream some massive videos off the Internet. After all, we won’t need to work so hard this afternoon as we can just hack in that rubbish piece of javascript we found up on Code Project earlier!

According to Google, my bank has 26,498 employees. Let’s imagine that the crummy application we’ve just butchered has been deployed to all staff and the bad code is already maxing out desktop CPUs all over the country. For every hour of execution, my bank will be pumping out four hundred and sixty-one pounds of carbon. That’s three thousand, six hundred and eighty-nine pounds per day and a staggering one million, three hundred and forty-six thousand, three hundred and ten per year! That’s also equivalent to six hundred and ten metric tons of carbon dioxide generated!

Climate consultants Selectra believe that it takes six trees to shift one metric ton of carbon so my bank would need to plant a good three thousand six hundred and sixty new trees per year to counteract that lovely piece of coding we’ve just done. But hey, at least we had some extra free time to watch the latest episode of Obi-Wan on Disney!

Now I know that these numbers are highly subjective and the application won’t be running all day every day, but just consider what else is installed on the machine. Maybe it's not so far outside the realms of possibility that the computer is coming down with bad quality software, all of which is putting too many demands on the system. The figures paint a picture that IT and software do have a part to play in reducing carbon emissions and that bad coding practices really could destroy the entire world.

So, let’s leave Disney Plus to later, close down that Code Project tab and take another look at the code.

A decent-sized bank may need to be planting this amount of trees every year just to counter one lazy hack.


So what are we going to do about it?

Journey with me through this series of articles as we explore together methods of minimizing the quantity of energy used in software development. Over the next few months, we will dive into three target areas where particular savings can be made.

Firstly, development processes and reducing energy by optimizing the way we build and automatically test the software. I’ve seen companies where huge networks of high-end servers are continually maxed out running 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 actually perform well without belching out sickening 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 amount of resources.

Thanks for reading and I hope you’ve enjoyed this article. While waiting for the next one, why not start to think about how you can optimize your own practices to help save the planet? If you too are a software developer, think about writing more unit tests and less automated tests and maybe getting the code working locally first rather than kicking off multiple CI/CD pull requests.


My name is Graeme Clarke and I’m global head of DevOps at Expleo, probably the best software quality consultancy in the work. By night, I’m into writing books and you may know me from my Charlie Bluster funny fantasy series. Read more of my stuff by downloading a free ebook from Charlie Bluster.com.

.