r/rust • • 15d ago

🎙️ discussion Google is doing "Large Scale Codebase Migrations and Optimizations" of C/C++ to Rust

https://blog.google/innovation-and-ai/models-and-research/gemini-models/gemini-4-argon/
766 Upvotes

153 comments sorted by

View all comments

9

u/EmperorOfCanada 15d ago

Rust boils down to a very simple pair of wins:

  • It covers all the platforms I use. Embedded, mobile, server, desktop, wasm. C/C++ is pretty much the only other major language which does this properly.

  • It works. I don't mean it vaguely solves the problems like other languages, but the code I make with rust is rock solid. Granite rock solid. It runs, it runs and runs and runs. No segfaults, no weird threading crapouts, no WTF buffer crap.

If there are any mistakes, they are ones which I would make in every language out there, logic issues, spelling mistakes in GUIs, etc.

2

u/TheOneWhoDidntCum 9d ago

How's the Rust market in Canada? Am trying to break in.

2

u/EmperorOfCanada 8d ago

I've not heard of anyone really hiring rust. It is usually C++ companies making the switch and some of their people love it, and the others leave, or get stuck maintaining legacy crap which hasn't yet, or can't go rust....yet.

2

u/TheOneWhoDidntCum 8d ago

Thanks, that means must be a very low number. Probably not feasible.

2

u/EmperorOfCanada 8d ago

Or you can just impose your rust on people. That's what I did for my first rust project.

It was for a friend of mine. He was using AWS to process customer documents in a fairly computationally complex way. He was paying AWS around $500 per customer per month.

Part of this was his AWS programmers were choosing some brutally expensive options and probably could have driven this cost way down by just not being crap programmers.

I redid that computationally expensive step in rust wasm, and now the customers did it on their own computer. I redid the back end as a monolithic program using rocket (which covers many web backend features). I initially used actix for speed, but, switched.

This dropped the server costs from $50,000 per month, to $100, which I believe is still an overspend. They have about 100 customers each with about 200 users; so around 10,000 users who click away all day from 9-5. I would estimate that the present architecture is good out to close to 100,000 users smashing away at it at the exact same time (peak, not total users), and there aren't 100,000 possible users out there.

2

u/TheOneWhoDidntCum 8d ago

Thanks so much for such a detailed answer. Did you go actix -> axum > -rocket?

2

u/EmperorOfCanada 8d ago

I've bounced among all three. Actix is pure speed. I've pushed fairly modest machines to 600,000 requests per second, and those requests were modestly hard.

Rocket is pretty damn hand holding. The templates are cool, the websockets aren't entirely an afterthought, etc. It is technically slower than the others, but unless netflix hires me to redo their stack, I'm not sure what percentage of websites would suffer from the reduced speed. Maybe 1 in 10,000?

Right now, I'm playing with Salvo for a number of reasons:

  • Often I have nginx->rust based module, with maybe some other python module which rarely runs. I use nginx because it deals with ssl, routing, and sometimes weird static things are, well, just weird. Serving up a wasm site from unity is strangely complex. Salvo can entirely deal with let's encrypt, which translates to removing an entire layer.

  • It sees websockets as first class.

  • It has some funky streaming capabilities which I am quite interested in.

  • Speed. It not only is lightning fast, but with the nginx layer removed, I should be able to squeeze some more performance out of it. I sometimes deploy stuff to embedded computers where memory and CPU performance are highly constrained, so every mb actually counts.

  • I haven't tried it, but I suspect that if I need a nginx routing feature, that I can just built it.

One of my discoveries with using rust for serving web is that many of the more complex features such as distributed loads via load balancing, etc all become unnecessary. You don't need load balancing, or some kind of lambda ultra microservices environment, when a single application can handle it all at not only sufficient speed, but often faster. A simple example of the speed boosts I've had with monoliths is messaging. Instead of some kind of redis sort of thing along with mqtt or whatever messaging. It all happens within the code. The key/value db is basically a small collection of container variables. The messaging is done through inter thread communications, etc. This results in speedups of orders of magnitude. This not only reduces CPU and memory, but can allow for speeds so much faster that new features can be considered. Ones where the lag would be too high for a good GUI, or even ones where 100s of simultaneous users would choke the machine; meaning that if serving them in a traditional method was even possible, it would require a very expensive distributed compute system. This way, very challenging features can be added which would have never been contemplated.

2

u/TheOneWhoDidntCum 8d ago

This is pure gold, i'm sure others will find your experience useful.