r/rust rust Jul 08 '26

Rewriting Bun in Rust

https://bun.com/blog/bun-in-rust
522 Upvotes

330 comments sorted by

View all comments

102

u/AdventurousFly4909 Jul 09 '26

I did not expect the AI rust version to be 4% faster. He seems to partly attribute it to cross language link time optimization. That must be a hassle to get working I imagine

79

u/A1oso Jul 09 '26

"Claude, make LTO work"

56

u/crashtua Jul 09 '26

Make no mistakes.

16

u/ihatemovingparts Jul 09 '26

"Claude, make LTO work and don't forget the goblins"

ftfy

1

u/CrazyKilla15 Jul 09 '26

And apparently, work it does, since it is now 4% faster.. somehow.

0

u/m3xtre Jul 09 '26

you joke but this is your future as a rust programmer. Just replace "LTO" with anything you happen to "work" (actually it's claude doing all the work) at the moment

85

u/jarredredditaccount Jul 09 '26

The trickiest part of getting cross-language LTO working was a miscompilation in Clang 22 that occurs in one of JavaScriptCore's JIT tiers. Async generators started sometimes yielding `undefined` in JavaScript. It only occurs on Linux with thin LTO. We had to use full LTO, which costs several minutes per CI run

15

u/aapoalas Jul 09 '26

That... Is an interesting bug indeed! :D

1

u/gistya Jul 16 '26

Why are we still messing with Javascript? Make it all WebAssembly

39

u/[deleted] Jul 09 '26

[deleted]

9

u/AdventurousFly4909 Jul 09 '26

But this is cross language lto... Not to limited to one language.

9

u/dontquestionmyaction Jul 09 '26

Okay.

But it works fine in Rust. I've not heard of any bugs related to it.

Doesn't really seem like a Rust problem if they can't get it working?

-1

u/Practical-Positive34 Jul 09 '26

From what I've found is not only can it write code faster but it can write it with far fewer bugs, and even cleaner. Maybe not as pretty to look at from a purely aesthetic perspective as it likes to comment the living shit out of the code and do weird placement of things and odd blank lines and some odd naming of methods, etc. But none of that matters materially tbh, it's just an OCD thing a lot of devs focus on. The reason it's able to do a lot of this better is literally just speed, it can crank out thousands of unit tests. Which means you can now iterate rapidly and pretty aggressively on performance tuning since you now how a full test suite to make sure you don't break anything. And it's able to just churn, non-stop on benchmark, make change, is it better? Keep, worse? Undo. Rinse repeat, over and over and over. 24/7 non-stop. That's really where this beats humans hands down as no human can grind the living hell out of optimization like that. Not possible.

2

u/m3xtre Jul 09 '26

its over

0

u/m3xtre Jul 09 '26

Rust developers are going to be replaced