Description
In rusterlium/rustler#299, we detected compile time to increase non-linearly when using a rather simple proc-macro. In rusterlium/rustler#299 (comment), we found that our decoder function results in a lot of IR. We were able to fix the issue in rusterlium/rustler#300 by making a simple transformation for generated struct initialization.
Transformation
The change to our proc-macro resulted in the following transformation of the resulting code.
Before:
Ok(SomeStruct {
field1: match Decoder::decode(term[1usize])? { ... }
// .. more fields
})
After:
let field1 = match Decoder::decode(term[1usize]) { ... };
// .. more bindings
Ok(SomeStruct {
field1,
// .. more fields
})
Simplification
I simplified our case in https://github.com/evnu/rust-slow-compilation. I haven't been able to simplify this further: when I tried to get rid of the rustler-specific Decoder
, or when using map_err()
, compilation became very fast. The README of the repository indicates compilation times on my machine for specific revisions of the repository.
Meta
$ rustc --version --verbose
rustc 1.40.0 (73528e339 2019-12-16)
binary: rustc
commit-hash: 73528e339aae0f17a15ffa49a8ac608f50c6cf14
commit-date: 2019-12-16
host: x86_64-unknown-linux-gnu
release: 1.40.0
LLVM version: 9.0