LLM-assisted coding - CO2 emissions.
Using a (local) LLM for an update emits 3.2x more \(CO_2\) than perfroming the update and refactoring by hand!
In a previous analysis I have written how much time and energy had to be used to perform a LLM-assisted update of a simple C project to C++, with an introduction of Boost's program_options library.
The TL;DR version:
Overall the manual update used roughly 477 [Wh] of energy accomplishing the result in \(\sim 3.7\) hours , whereas the agentic update needed 1070 [Wh] to accomplish the same task with increased supervision in 5.7 hours.
To circle back to the estimates of \(CO_2\) emissions per query being held up as a reason to label LLM use as a non-issue the obtained results can be used to obtain an estimate of the \(CO_2\) equivalent required.
To this end I'm using the previously obtained measurements as well as the \(CO_2\) intensity data stored in Home Assistant using the Electricity Maps integration. This integration provides a value of g \(CO_2\) equivalent per kWh every hour on the hour as shown in
Given the above graph it should be fairly obvious that using a simple average of the gCO2eq/kWh would be a reasonable first approximation, but given that the individual phases of the agentic rewrite were performed at different times of the day we expect the actual CO2 equivalent to differ significantly from the mean estimate.
The average value of the mass equivalent of CO2 per kWh during the time of the rewrite is \(472.5 [\frac{gCO_2 eq}{kWh}]\), which implies that the agentic update of the code base to C++ and the introduction of Boost resulted in \(505.6 [g]\) of \(CO_2\) equivalent being emitted.
Refining the estimate using the data I obtain the following break down of the CO2 equivalent generation
| Task | agentic | manual |
|---|---|---|
| Code ingestion and analysis | 13 | 72.75 |
| Remove BladeRF and extra architectures | 76.17 | 15.44 |
| Convert the project to use C++ compiler | 154.2 | 0.43 |
Introduce Boost's program_options |
255.72 | 67.06 |
| Total [g] | 499.1 | 155.68 |
We thus observe that the agentic update of the simple C project to C++, with an introduction of Boost's program_options library to replace the command line argument parsing emitted 3.2 times as much \(CO_2\) as a manual execution of the same task.
It is important to note that this is still an estimate because the data provided by Electricity Maps is provided only a) with the granularity of the country and b) with a time resolution of 1 hour. To improve the estimate one could further use SMARD to obtain a detailed proportion of renewable and non-renewable sources of electricity but would then have to involve other estimates to obtain the CO2 equivalent of 1 kWh of electrical energy.
In conclusion we see that the amount of energy required to perform the same task was a factor of 2.24 larger when using LLMAC, while producing 3.2 times more \(CO_2\) equivalent emissions!