-
Notifications
You must be signed in to change notification settings - Fork 386
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Moderately-sized crate with protobuf-generated modules takes 5 minutes to compile in release mode #383
Comments
One of the possible causes of this is this issue: #339: each generated message has too many virtual functions. I'm not sure how much it affects compilation performance, but it definitely bloats the resulting binary size. I have not found a good solution for this issue with the current Rust language. Ideas are welcome. |
Are all of the generated reflection methods (descriptor methods returning or implementing |
Reflection is also used for printing to text format (e. g. for debugging). Technically it's possible to make it optional, but I have a feeling that largest code size is occupied by unnecessary virtual functions of Also, FYI, for primitive fields, I tried to rewrite reflection implementation to store field offsets instead of generating accessor functions. AFAIR, it did not save a lot. However, it can probably speed up compilation. I'll try to revive that patch. |
OK, switching to offsets saves only about 3% of generated code size. |
Closing due to old age. |
I am not sure whether this issue relates to Rust compiler itself or to the generated code but the problem I experience is that the crate which contains just around 36 protobuf files of various sizes takes 5 minutes to compile in release mode, with rustc compiler memory usage maxing at 1.5Gb of RAM.
The number of files will be probably growing further so the build times will increase even more.
Considering that it takes just about 1.5-2x times as much to build the rest of the crates (more than 300 dependencies currently) there is something wrong with the generated protobuf code, either it's too complicated or too large.
The text was updated successfully, but these errors were encountered: