← Back to context

Comment by vmg12

8 days ago

The fundamental problem with all Js based apps is how they are very single threaded.

With js you get 1 thread at 100% utilization. Power usage and heat scale non-linearly with cpu utilization and 100% utilization on a single threaded js app means you will have ui lag. Other languages like golang would split work across 8 threads and have 8 threads at 20% utilization and this would result in less power usage. Claude Code would have been better off performance wise being an electron app because it would be offloading rendering to the browser and gpu.

Also, the architecture of Open Code is actually a lot better here than Claude Code. ClaudeCode does everything, including rendering in a single thread and it's all in js. OpenCode has a zig based tui renderer it offloads that work onto.

But I will also say these coding agent tuis do get unfairly maligned because they launch subprocesses and those subprocesses tend to be expensive. If you are using Rust analyzer with claude code, it's rust analyzer that's causing the majority of your problems.

No, the fundamental problem of these apps is that they are, for no reason, pretending they need a high powered game engine rendering loop. They don't. It's a text printout of history with some hotkeys for mode switches and such. "rendering in a single thread" should never be an issue because it should never be "rendering". It needs to stream text to stdout. That's been a solved problem for 50 years and now it takes 2GB of memory to be done poorly with broken scrollback.

  • Drawing to the terminal / rendering / whatever, this is all arguing semantics and very uninteresting and not insightful.

    > they need a high powered game engine rendering loop

    Don't believe the bs on twitter. Claude code source was leaked, there is no high powered game engine rendering loop.

    > It needs to stream text to stdout

    These apps are doing real work taking text that is streaming in and doing syntax highlighting, calculating diffs, and rendering markdown. If the work was split across threads they would not use anywhere close to as much power and there would not be a slow ui.

    If you think this is actually nothing, prove it. Put the code up on github that shows taking a constant random stream of markdown, code, and diffs and displays it in the terminal can be done cheaply on a single thread.

    The reason the computer gets hot and uses more power is because the cpu is getting close to 100% utilization.

    • There are two different arguments here.

      > These apps are doing real work taking text that is streaming in and doing syntax highlighting, calculating diffs, and rendering markdown.

      The first argument is that these are expensive operations. They are not. And the second argument is the assumption that these are desirable things for an agent system to be doing. That's a personal preference but, personally, I don't want them and would appreciate a way to disable all of that to reduce CPU use.

      3 replies →

    • The heck? It does all that rendering for a tiny fraction of the total amount of time that the TUI is running. The streaming is IO bound, there’s no way that it’s outputting nearly enough text to tax the CPU that much.

    • Sorry, but nope; Golang there would be there a beast doing that in a much, much faster way. Not to mention C/C++ with NCurses.

      2 replies →

That’s not really a big issue. In major OS like the BSD, SMP implementation are not that old. If we can have a full OS running in single core mode, we can have an application being performant too. I’m currently running OpenBSD on 4 cores and it’s basically 99% idle.

Bad coding is just bad coding.

  • It's basically idle because it's not doing anything. If you are streaming in markdown and code and then doing syntax highlighting on this code in real time, then rendering it on the screen you are doing actual work.

    It's also all cpu bound work. The majority of the stuff on your screen is being rendered by the gpu.

    • > If you are streaming in markdown and code and then doing syntax highlighting on this code in real time, then rendering it on the screen you are doing actual work.

      You are really, really not. Not at LLM inference speeds at least. Frontier models output maybe 200 bytes per second on the fast end. I guarantee you that idle BSD box is still processing more than 200 bytes of whatever at any point in time. Streaming 200 bytes of LLM output through syntax highlighting, markdown rendering, and diff formatting, will still leave the box basically idle if done correctly. Claude Code has not done it correctly.

      1 reply →

> Power usage and heat scale non-linearly with cpu utilization

I don't doubt this, but I would love details and citations here.

I'm not concerned with CPU use/wakeups while actively using it, but with it sitting idle doing nothing.