News for hackers. Stuff that matters.
Re:An update on recent Claude Code quality reports by jannyfer on Thursday April 23, 2026 @07:15PM (#47883471)
I’m not sure that it’s O(N) with caching but this illustrates the N^2 part:

https://blog.exe.dev/expensively-quadratic

Re:An update on recent Claude Code quality reports by bontaq on Friday April 24, 2026 @12:13AM (#47885435)
If there was an exponential cost, I would expect to see some sort of pricing based on that. I would also expect to see it taking exponentially longer to process a prompt. I don't believe LLMs work like that. The "scary quadratic" referenced in what you linked seems to be pointing out that cache reads increase as your conversation continues?

If I'm running a database keeping track of a conversation, and each time it writes the entire history of the conversation instead of appending a message, are we calling that O(N^2) now?

Re:An update on recent Claude Code quality reports by atq2119 on Friday April 24, 2026 @01:40AM (#47886029)
Yes, that is indeed O(N^2). Which, by the way, is not exponential.

Also by the way, caching does not make LLM inference linear. It's still quadratic, but the constant in front of the quadratic term becomes a lot smaller.

Re:An update on recent Claude Code quality reports by computably on Friday April 24, 2026 @05:20AM (#47887701)
> Also by the way, caching does not make LLM inference linear. It's still quadratic, but the constant in front of the quadratic term becomes a lot smaller.

Touché. Still, to a reasonable approximation, caching makes the dominant term linear, or equiv, linearly scales the expensive bits.

Re:An update on recent Claude Code quality reports by _flux on Friday April 24, 2026 @04:03AM (#47887148)
What we would call O(n^2) in your rewriting message history would be the case where you have an empty database and you need to populate it with a certain message history. The individual operations would take 1, 2, 3, .. n steps, so (1/2)*n^2 in total, so O(n^2).

This is the operation that is basically done for each message in an LLM chat in the logical level: the complete context/history is sent in to be processed. If you wish to process only the additions, you must preserve the processed state on server-side (in KV cache). KV caches can be very large, e.g. tens of gigabytes.

Re:An update on recent Claude Code quality reports by bavell on Friday April 24, 2026 @08:42AM (#47889412)
> I would also expect to see it taking exponentially longer to process a prompt. I don't believe LLMs work like that.

Try this out using a local LLM. You'll see that as the conversation grows, your prompts take longer to execute. It's not exponential but it's significant. This is in fact how all autoregressive LLMs work.