r/rust•
metadeus

Compile times and out of memory error

I'm working on a project that generates lots of Rust code (> 5MB). The problem is that I'm not able to compile it, as rustc uses too much memory (> 5GB) and gets killed by Linux kernel. Also, compile times are unacceptable (> 5 min).

This is very disappointing, as I have the same generated code for Ruby and Python and they both can handle it without any problems, but I really want to use Rust in production.

What can I do about it?

I already tried:

  • make a separate crate for generated code
  • opt-level = 0
  • explicitly provide all the types
  • generate simpler code

I can, of course, split crate into smaller ones, but then I will end up having 20-30 crates and I'm not sure it will solve the problem as all the generated structs and methods will be public.

Generated code is basically: ~1000 static variables and ~1500 structs with ~10 methods each.

Posted Mar 11, 2019, 3:26 PM UTC

1424
Loading comments…