-
Notifications
You must be signed in to change notification settings - Fork 69
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
Excessively high compile times #86
Comments
This one is very tricky...the library uses quite a bit of templating which has been known to increase compile time. But I am curious about clang:-fconstexpr-depth=2048. I don't quite understand why this is necessary, even for a struct your size. I will have to take a closer look. |
One thing you could do to alleviate the rapid iteration problem is to outsource the parsing into a separate compilation unit. Basically, have on .cpp file that just contains rfl::bson::read. If you are using something like cmake and ccache, I don't imagine you would have to recompile the parsing of your two structs unless you actually change anything about the structs. At the end of the day, it is important to remember that all of the boilerplate code that is abstracted away by the library still needs to be generated and compiled. So something like rfl::json::read is a one-liner to you but a lot is happening under the hood |
I have been thinking about this...I am fairly sure that the reason you need recursion to be that deep is because of C arrays, more specifically the things we are forced to do to support them. I think one thing we could try is is to turn off support for them using a compiler flag (which I would have to implement). You could then just use std::array instead. |
I was not aware of CCache, and will try and implement that. The code for serializing is currently located with other related code, but I think we can move it out to its own file somewhere. The compiler flag sounds like a good option! |
@Lazrius, the easiest way to get the parsing into a separate compilation unit is to use custom constructors: |
@Lazrius , I have added experimental support for a flag that might at least get rid of the recursion problem: https://github.com/getml/reflect-cpp/tree/f/build_time_performance You can add -DREFLECT_CPP_NO_C_ARRAYS_OR_INHERITANCE to your compile flags. Assuming that your structs do not involve inheritance or contain C arrays ( |
Very awesome. I will see if I have time to try this on the weekend, I should be free on Sunday to give it a go. |
Hey, I'm working with Lazrius on this issue, and we have tried the REFLECT_CPP_NO_C_ARRAYS_OR_INHERITANCE flag, but for reasons we cannot comprehend, it breaks on a very basic struct. It works just fine if both instances of CostumeData are commented out. The original Costume struct is exactly the same except for the array being a C-array. |
My 2 cents: I've started to use the library, and the quick experiment went fine, but when applying it to a "real" class which has a good amount of members, the compilation time went to really bad. A file which normally compiles in 2 or 3 seconds, takes 3 minutes instead. :-( I'm just starting to use the feature adding in #59, nothing more. I just want to loop over the fields of some structs. I tried to pinpoint if there was a serious issue with some of the types I'm using (it's mostly integral types), and if QString being one was an issue, but it seems what makes it slow compilation a lot is the number of fields. I also had to pass Additionally, I tried both master (6bb95ff) and the f/build_time_performance branch. Thank you very much for your effort! This library is very exciting and promising. |
Some additional information. We tried changing up which compiler we were using to see what effect it would have. Compiling on Windows using MSVC, our entire project which makes heavy use of templates, was 1m 15s at last check. It would seem that most of the time on that build wasn't even within the reflection code either. On the other side, when compiling MSVC using the ClangCL toolchain, the compile time was over 5 minutes, and the vast majority of time seemed to be spent within the reflection library. I am curious if it is things like compiler checks, of which clang seems to be far more aggressive with, is partially responsible. |
@suy , can you provide some examples of what it is that you are doing there? A problem that I often see is that a one-liner like But I would be very interested to see some reproducible code examples here. |
@Lazrius , thanks for the information. It's very weird to see that Clang should be the slowest compiler, because my experience is exactly the opposite. Just take a look at our Github Runners. By the way, we are working on this topic. It's something that affects us as well. |
Hello again. My coworkers and I have observed a massive increase in compile times ever since we have implemented your library into our project. To make the project compile, we've had to add the following compiler flag:
clang:-fconstexpr-depth=2048
, which strongly implies there is a heavy amount of recursion at play.As it stands, we are currently only reflecting two structs. One of them looks as follows:
We have no plans to introduce structs larger than this one, but the very notable increase in compile time (from about 30-40 seconds to around 5:30 minutes) completely cripples our ability for rapid iteration, slowing down development of several critical features to a standstill.
Thanks again for the great work, and I know it's not an easy thing to diagnose, but we'd greatly appreciate any support in getting those compile times to a more manageable level.
The text was updated successfully, but these errors were encountered: