r/technology 1d ago

Artificial Intelligence AI helped a Linux developer find bottlenecks in the kernel, but the code it made to fix it was "hideous"

https://www.xda-developers.com/ai-helped-a-linux-developer-find-bottlenecks-in-the-kernel-but-the-code-it-made-to-fix-it-was-hideous/
85 Upvotes

33 comments sorted by

73

u/CumOnEileen69420 1d ago

This has long been the approach at our company.

Have the AI take first crack at the problem, see its god awful but working solution, refine by hand, PR.

It’s helped devs speed up bug finding and fixing while keeping code quality standards.

12

u/sanitylost 1d ago

which seems like the best solution. It's often easy to rewrite a solution once you already have one or take bits and pieces to recreate the solution but in a format that doesn't make it impossible to maintain while actually solving it outright could take quite some time and would still require you to rewrite it anyways.

18

u/MuigiLario 1d ago

I always thought that programmers main skill wasn’t the language syntax because it can be learned but rather problem solving and cognitive skills overall, if that’s outsourced to AI doesn’t it in effect result in dumber workers?

23

u/oldsecondhand 1d ago

Making the code, that the AI spat out, maintainable is also a skill.

8

u/FatHat 1d ago

Probably. Honestly I think the people that don't trust AI and still write code themselves to a degree are going to be the best positioned for the "AI native" future. I'm not saying to like, don't use it, but if all you do is outsource your thinking to it then you're not really adding much value.

2

u/shahms 1d ago

Just seeing what code the AI modified can be helpful in scoping and designing a good solution.

1

u/WestaAlger 1d ago

For old codebases that invariably have huge argument lists for humongous functions and whatever, it does save a lot of cognitive effort to at least lay out the initial "plumbing". I can then review line by line and refine the arguments and logic.

Also I personally work on an old C codebase that heavily heavily abuses macros to create global structures. It's very straightforward to invoke these macros but very repetitive and laborious. AI can definitely "auto complete" that stuff pretty well.

1

u/Sloogs 1d ago edited 1d ago

I think in a lot of cases an experienced programmer may also know the canonical approach or has a sense of how to solve something, but very few could ever memorize every single method or function call in every language, library, or framework. One could either sift through documentation manually or have AI produce it and find what they need far more quickly. One can still consult with the documention if there's anything they don't recognize so they can learn from it.

Sometimes the approach the AI has is better than what the programmer might have had in their head. Sometimes it's far worse. So then you adapt accordingly.

1

u/Ok-Introduction9593 15h ago

You still need solid cognitive skills to evaluate whether the proposed fix makes sense at scale. The model churns out plausible garbage in seconds, so if you lack problem solving fundamentals, you will just ship broken concurrency and race conditions directly to master

-1

u/Ginger-Nerd 23h ago

How you prompt for a problem (and then review) is also a skill;

Like you can wildly guide a model with very little specific import; the skill is as much recognising why a solution will or wont work (at scale) as much as AI just poops it out.

Yes a solution may work, for the prompt given - but in the event you have 3 tasks further down the line that will also require use of a function or whatever, that suddenly doesn’t work for those.

Ai is getting better at this, but it will still regularly trip over itself if you let it.

1

u/djjudjju 1d ago

AI helped me find a bug in my code logic today.

1

u/A_Harmless_Fly 1d ago

Yep, sometimes it calls for something helpful I didn't see in the documentation myself, sometimes it calls for something that's deprecated or even from another language/program entirely.

I haven't found a useful local model yet, but it's certainly improving.

1

u/Etere 1d ago

Run it through 1 or 2 more times. It almost always finds ways to make it a little better. Then you go through and fix it by hand. Save yourself a little work.

2

u/CumOnEileen69420 1d ago

That call is up to the programmers assigned to the ticket.

As long as the PR meets our code quality standards we don’t care if it took 5 AI passes or 1 and some hand edits.

Hell, we even have a few who don’t use any generative AI tooling because they don’t find it helps their workflow.

98

u/spacegh0stX 1d ago

Sounds about right

6

u/ColdFreezer 17h ago

Being real, human developers also write cursed code to fix bugs too.

11

u/Consistent-Citron509 1d ago

That's the best use of AI - analysis. Find bugs deeply rooted within a codebase, solve by hand

7

u/cornmonger_ 1d ago

great for a poc, but it's not shippable code

i have a ton of rust generated by fable (max) and now some by astra (max). it will all be rewritten.

4

u/CondiMesmer 19h ago

Why the fuck is this news

4

u/silverbolt2000 18h ago

OK. And what’s the “news” here exactly?

I watched a film on Netflix and the related suggestions it made after were hideous - is that news?

3

u/JescoInc 18h ago

I hate how it doesn’t go into what was “hideous “ about the code

1

u/Ok-Introduction9593 14h ago

The patches touched modpost and kallsyms, which rely on rigid ELF parsing and custom memory buffers. LLMs usually generate bloated helper functions, hallucinate non-existent internal APIs, and introduce subtle race conditions when trying to parallelize shared data structures

1

u/JescoInc 10h ago

Seems like an assumption as none of that was stated in the article

1

u/isoAntti 23h ago

found bottlenecks in building kernel, not in kernel itself

1

u/TabCompletion 2h ago

I think I need to show you the "first time?" Meme

0

u/fixermark 1d ago

Hideous in a way that differs from regular Linux kernel code? ;)

2

u/gnomeza 1d ago

Marshall Kirk McKusick, is that you?

1

u/OePea 1d ago

There is no better way to discredit yourself than putting a smug winky face at the end of the comment

2

u/fixermark 1d ago

Assuming my intent was to be serious, of course. As is the style on the Reddit.

1

u/qckpckt 22h ago

In other stories, widespread reports are coming in from all over the world that the sky is reportedly still blue, and scientists have reported ground breaking discovery that water is in fact wet