This is a devlog! I work on a bunch of random software projects on my own time and the devlogs are a way to keep track of and talk about what I’ve done, because the one thing the world needs is MORE CONTENT.
Devlog: tauri-bind and AI energy use analysis
In the last couple of weeks I made some changes to two projects I’m currently working on: opencode-energy-logger (which I wrote about in my last devlog) and a rust crate I’m calling tauri-bind. The changes I made to tauri-bind were primarily bug fixes and automated tests. In opencode-energy-logger, I added a reporting dashboard, which I then used to analyze the energy consumed by my AI use when working on tauri-bind.
tauri-bind
The main project I’ve been working on on-and-off for the last several years is called mise-en-place (at least for the moment). It is a mealplanning and recipe collecting app written with tauri, a framework for creating desktop/mobile apps using an embedded browser that communicates with rust code (basically a lighter weight electron).
So far I’ve been using the traditional tauri approach in creating mise-en-place: write as much as possible in JavaScript (or TypeScript in my case), and only use rust to expose functionality that isn’t available in the browser. Which kind of worked at first, but as the app grew it quickly became untenable.
JavaScript did not have a lot of the APIs I needed to use, APIs that might be more commonly used in a desktop app vs. the client side part of a webapp. APIs like performantly reading and writing PDFs, doing crc32 checksums, reading/extracting/manipulating zip archives, etc. Which meant I had to create a lot of tiny useless crates just to expose some functionality that would have been easily available if I were coding in rust. Additionally, I was dreading having to maintain the large morass of JavaScript I was writing for non-UI related functionality longterm.
So I decided to create a solution that would allow me to write everything in rust outside of the browser and only define UI components in the browser (specifically with leptos a client side framework written in rust). This solution is tauri-bind, a rust implementation of Vue.js’s reactivity primitives (ref() / computed() / etc.).
tauri-bind defines it’s own reactivity primitives, which are used to define application state (grouped together within store structs), and hooked up to the frontend with as little boilerplate as possible. The frontend modifies this state directly or invokes methods on stores to trigger changes to the application state, which flows back to the frontend. In this way, the frontend defines nothing but UI components and the entirety of the application behavior is defined in rust code, which has easy access to any API it needs.
Granted, this is only doable because I am writing this app by myself and am not trying to make money off it. If I were trying to make a living off of mise-en-place, wasting time worrying about my comfort as a developer probably wouldn’t be the best way to go about it.
The changes made to tauri-bind
tauri-bind was previously just a proof of concept that defined a ReactiveProperty struct, a Store trait, and macros to initialize and expose store properties & methods. What I wanted to do now was finish it so I could actually use it in mise-en-place. This would involve adding computed properties (properties defined by an idempotent function that uses reactive state) and making the binding interface simpler and more streamlined.
Having done the PoC I had a good idea of where to go in that direction. However, the PoC had no tests. So before a major change I wanted to make sure I had a mechanism to prevent regressions (so tests). This quickly snowballed when the AI found about ~20 or so issues with the current implementation (which is not uncommon in my experience when starting to use AI in a project).
Note that these weren’t edge cases, but legitimate bugs and design flaws, some coming from my inexperience with rust, others being concurrency related issues that would have been rather difficult to find by hand. So it was worth fixing them now rather than later on.
So I fixed those issues, which included upgrading the tauri version used to the latest version (I hadn’t touched this code in two years due to lack of time), introducing parking lot locks to replace unneeded tokio locks and removing use of unsafe pointers. Additionally I added tests, increasing test coverage from, well, 0% to about 95%. And in so doing, and thanks largely to the AI’s explanations, I learned a fair amount about rust.
opencode-energy-logger reporting
As I wrote in my previous devlog I consider AI use mandatory if you’re writing software for other people to use given it is so good at finding bugs humans never find. But I don’t want to use it without consideration. I want to make sure I am consuming as little energy as possible. Which of course first requires knowing how much energy my AI use consumes.
So I added several new metrics and reports including:
- energy use metrics like “total energy used” and “average energy per prompt”

- a “Most expensive prompts” report showing the top N prompts in terms of energy consumption

- a prompt chronology that displays every prompt made in order within a selected session

- the ability to annotate prompts with descriptive metadata in the prompt chronology so you can compare metric values between classes of prompts

- the ability to filter what logs are used to generate the above prompts

Analysis of AI energy usage in the tauri-bind changes
Using this new functionality in opencode-energy-logger I was able to get some insight into exactly how energy was consumed while working on tauri-bind.
First I annotated every prompt made on that branch, labeling each with what I consider to be the prompt’s category. I ended up using the following (non-mutually exclusive) labels:
- ai error
- bookkeeping
- clarification
- human error
- implementation
- investigation
- learning
- possibly unneeded
- refactor
- review
- revision
- tests
- upgrade tauri
Segmenting on those annotations, I was able to identify which types of AI use are worth optimizing and which types have little overall impact:
| Prompt Category | Total Energy | Average Energy Per Prompt | Percent of Total |
|---|---|---|---|
| ai error | 0.0737 kWh | 87 kJ | 1.57% |
| bookkeeping | 0.0586 kWh | 41 kJ | 1.25% |
| clarification | 0.0249 kWh | 44.6 kJ | 0.53% |
| human error | 0.153 kWh | 89.7 kJ | 3.26% |
| implementation | 2.53 kWh | 309 kJ | 53.83% |
| investigation | 1.35 kWh | 80.7 kJ | 28.72% |
| learning | 0.0632 kWh | 20.5 kJ | 1.34% |
| possibly unneeded | 0.172 kWh | 153 kJ | 3.66% |
| refactor | 1.91 kWh | 262 kJ | 40.64% |
| review | 0.234 kWh | 167 kJ | 5% |
| revision | 0.16 kWh | 188 kJ | 3.4% |
| tests | 0.0758 kWh | 129 kJ | 1.61% |
| upgrade tauri | 0.171 kWh | 153 kJ | 3.64% |
The two biggest consumers of energy here were prompts that generated code (implementation prompts) and prompts used to understand and explore (investigative prompts). The most expensive individual prompts were the ones that handled the entire implementation of an individual change.
Individual investigative prompts were actually not very expensive. Collectively they consumed a significant amount of energy due to the number I issued. I suspect this is only due to the nature of the change here; having to understand all the bugs that were found.
All other prompt types, including compaction and prompts that were required due to human error or AI error consumed minimal energy.
What surprised me the most, however, was how inexpensive energy review prompts were compared to coding tasks (which is the opposite of what I’d assumed in my previous devlog). The most expensive review prompt took 0.0772 kWh while the most expensive coding prompt took 0.297 kWh. On top of that, there were 14 coding prompts that were more expensive than the most expensive review prompt.
Intuitively, for me at least, this doesn’t make sense. As a human it’s entirely the opposite. Writing code, ie translating an idea into a chunk of code, doesn’t really require that much thinking. It’s mostly just typing, organizing and a lot of looking APIs up. Reviewing and finding issues is far more difficult, especially the kinds of issues the AI caught in this session (ie, race conditions and other concurrency issues).
Knowing how LLMs work, however, it becomes understandable. LLMs iteratively determine what the next token in a stream should be, and each request to get the next token has to process every token in the stream so far. So getting the next token in a large session takes more energy than getting the next token in a small session, and getting a whole response for a large session takes far more energy than getting the response for a small session.
Writing code requires researching the existing code base and adding that code to the current session, then writing a large amount of output tokens when generating code. So yes, it makes sense this would be more expensive than a text description of what’s wrong with some code. (Assuming my reasoning isn’t wrong again.)
I think a good way of explaining this is that human brains (or at least mine) are very good at going from point A to point B: finding a solution to a specific problem, for instance. But they are not very good at starting from point B and listing every point we could have started from other than point A, like listing every possible context in which a piece of code could be executed. AI/LLM’s seem to be very good at this.
Reducing energy use
So now that I know all this, how do I apply it and reduce the energy I’m using without sacrificing quality? By looking through each individual prompt in expensive prompt categories, I came up with the following experiments to try:
-
Try planning with GLM 5.3, but coding with a less powerful model like GLM 5.3 Flash.
I can’t change the model mid-session as that would result in cache misses when running inference (the entire session would have to be reprocessed). Instead I’ll have to try and use subagents or new sessions, where the main session outputs a detailed coding plan and the other implements it. Though I’m not sure if this will result in much lower energy use.
-
Code more, or entirely, by hand.
Originally I thought this would result in more energy use due to the amount of human errors the AI would need to catch. But obviously this isn’t exactly the case. And given how comparatively inexpensive review PRs are, it might result in lower energy usage.
-
Find a customizable editor or IDE and add functionality as I go to better support coding by hand.
Having the AI generate code is far more convenient, especially since it makes so few mistakes. So if I want to successfully go back to writing code myself without losing much of the speed increase, I think I will need to make coding more pleasant. The main thing I dislike about coding by hand, something I simply accepted before I started using AI, was the amount of pointless context switching when going through the development loop (ie, coding, running tests, analyzing failures, devising fixes, back to coding). No modern IDE lets me do all of this within a single context without also having to dodge enormous amounts of unnecessary functionality (*cough* Jetbrains *cough*). So maybe I can assemble my own dev environment, creating determinstic tools to help me code faster and with less stress.
So far, the best candidates I’ve seen for such an editor are Kate, Lite XL and Fresh.
-
Create a custom memory for the AI that injects context instead of waiting for the AI to request it.
To my knowledge AI agents will save relevant information the AI researches and provide this again via tool use when asked. But these solutions require the AI to request the use of the specific tool (ie, “check if there is information about X”), which means some wasted inference and relying on the model in question to actually trigger this optimization. Perhaps instead the agent could actively look for useful context before sending a prompt, and add it so the AI does not have to look it up. If this is actually workable it might save energy in coding, investigation and review prompts.
-
When investigating the feasability of a solution, do some research myself and add that research to prompts I write.
Straightforward, but it may reduce the amount of work the AI has to do.