I think the problem is the training data. Whilst I don't know, I would guess that the greatest driving factors are "does it work", "how long did it take to write".
I have just done a performance audit on some endpoints of a very fast moving team. Man, it is disheartening. A simple GET request to fetch one record has loops in the controller with nested database and external api calls.
And this is in a well architected and documented repo, where directness is prioritized over magic, with little to no useless abstractions, on a typed codebase, with development guidelines that address these sorts of specific issues.
Ironically, if you ask it to figure out why this endpoint is slow, it will answer correctly.
I have found that you often have to provide some hints to the LLM. Also, providing server logs from production can also greatly assist it in finding performance issues. I have had pretty good success with this, and it has saved me a lot of time. Just be extremely scrutinizing about the solutions that it proposes, because those are frequently suboptimal.
[dead]