danielsreichenbach,
@danielsreichenbach@mastodon.world avatar

I generally like #rustlang but I think every project developer should be forced to use it on a Raspberry Pi with 4GB RAM... had to build Vaultwarden (https://github.com/dani-garcia/vaultwarden) on one, and man,,, after 15 minutes compilation is no longer running because the device went OOM and now is so hot the fan is louder that a datacenter server...

Just to be clear, I think this is a Rust problem, not a project problem.

mo8it,
@mo8it@fosstodon.org avatar

@danielsreichenbach It is neither a Rust problem nor a project problem in my opinion. You shouldn't compile on a potato xD

Don't get me wrong, I love such boards, I even have one. But you can just cross compile and transfer the binary.

danielsreichenbach,
@danielsreichenbach@mastodon.world avatar

@mo8it But that is the thing, it is not a potato. I can compile a full server for World of Warcaft on it, the machine will not go OOM and also not die of heat. It is a Rust problem, not a problem of resources on that device. And if Rust is to be an alternative to C/C++ it should also be able to run in the same places IMHO. Don't get me wrong, I do not want to bash Rust, I would rather see a discussion happening on how to make Rust work properly here.

FSMaxB,
@FSMaxB@mastodon.cloud avatar

@danielsreichenbach @mo8it what you can try is telling cargo to only use one core, that should hopefully reduce the memory usage.

But yeah, the rust toolchain is quite resource intensive. In CPU, memory and disk space.

danielsreichenbach,
@danielsreichenbach@mastodon.world avatar

@FSMaxB @mo8it I tried the same thing on a Rock Pi 5b with 16 gigs of memory, it also consumed all CPU and memory. But with 16GB it does at least pass. I know rust does a lot in that process but IMHO if it can not adapt to the systems resources that is bad design.

mo8it,
@mo8it@fosstodon.org avatar

@danielsreichenbach @FSMaxB These two lines cause the problem:

https://github.com/dani-garcia/vaultwarden/blob/0fe93edea6cb8d4b30416a6d319164f8828ad8b7/Cargo.toml#L172-L173

The devs opt in for more optimizations. But these optimizations consume more resources during compilation and make the compilation time longer.

Scrolling down, I found this custom profile which is optimized for compiling on systems with low resources:

https://github.com/dani-garcia/vaultwarden/blob/0fe93edea6cb8d4b30416a6d319164f8828ad8b7/Cargo.toml#L196

To use this custom profile, you need to pass --profile release-low to cargo build (instead of --release) or cargo install

danielsreichenbach,
@danielsreichenbach@mastodon.world avatar

@mo8it @FSMaxB oh my god, thank you so much 😍 trying this

danielsreichenbach,
@danielsreichenbach@mastodon.world avatar

@mo8it @FSMaxB just to report a happy end: this worked. Now the RPi does the work, slow but steady.

ekuber,
@ekuber@hachyderm.io avatar

@danielsreichenbach @mo8it @FSMaxB It might be worth it to file a user experience ticket so that cargo/rustc can detect when you're running a configuration that will clash with the available resources and guide you on to how to change them.

chfkch,
@chfkch@ruhr.social avatar

@mo8it
There are several cases where cross compilation does not work or is at least a huge hassle. I don't know about vaultwarden though because i run it on x86.
If you want i can compile it on my ARM machine, but i wouldn't trust some internet random to provide for security binaries.
@danielsreichenbach

danielsreichenbach,
@danielsreichenbach@mastodon.world avatar

@chfkch @mo8it Vaultwarden was a good example because it is a rather small application. Not much to it. So why does compiling it kill a machine I otherwise use just fine with clang for compiling C/C++? And yeah, cross-compilation is there but that is not an option here.

janriemer,

@danielsreichenbach
Maybe try to reduce number of parallel jobs during build, like this:

cargo build --jobs 1

See docs:
https://doc.rust-lang.org/cargo/commands/cargo-build.html#miscellaneous-options

@chfkch @mo8it

  • All
  • Subscribed
  • Moderated
  • Favorites
  • rust
  • DreamBathrooms
  • magazineikmin
  • Youngstown
  • thenastyranch
  • rosin
  • slotface
  • ngwrru68w68
  • Durango
  • PowerRangers
  • kavyap
  • cisconetworking
  • tsrsr
  • everett
  • mdbf
  • anitta
  • tacticalgear
  • khanakhh
  • ethstaker
  • vwfavf
  • InstantRegret
  • tester
  • osvaldo12
  • cubers
  • GTA5RPClips
  • Leos
  • normalnudes
  • modclub
  • provamag3
  • All magazines