-
Notifications
You must be signed in to change notification settings - Fork 38
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
Compilation performance benchmark (boost::di vs kangaru) #79
Comments
Thanks a lot for this. It was one of my task but didn't had the time yet (#73). I suspect I'll run your test with templight to see what's going on. |
@gracicot Do you have any idea how to "profile" compilation? And any tips about how to understand what is going on under the hoop? I would like to help, I could allocate some time, but I feel complete lost in all these templates mecanisms. |
I never really profiled template code before, so the subject is quite new to me too. I know some guidelines (eg: aliases are lighter then instanciating types) but that's about it. I also discovered templight as a tool recently but the setup is tedious. There's indeed a lot of template machinery in this library. Explore as you wish and if you're stuck, poke me on gitter. I'd be happy to help. |
@Dragnalith Hello! It's been a long time, and I thought about a solution for the autowire compilation time explosion: How about defining the service map inside the classes using friend function? There are two ways to do this: struct class_a_service;
struct class_a {
friend auto service_map(class_a const&) -> class_a_service;
};
struct class_a_service : kgr::single_service<class_a, kgr::autowire> {}; And the second way: struct class_a {
friend auto service_map(class_a const&) -> kgr::autowire_single;
}; Would it be possible for you to run your tests again using these patterns instead? My hypothesis is that it will significantly reduce the compile times, probably reduce the time complexity because a new service don't add a possible overload for other service to see. |
You can profile compilation time with latest clang built from master. Recently they added new option Heavy template usage usually looks like this o_O |
I am investigation compilation performance, and I have discovered boost::di was way faster than kangaru.
Both have a compile time "autowire" feature. The following table compare boost::di with kangaru with and without autowire. I have generated a class graph and services are all
kgr::single_service
services.We can see Kangaru (autowire) seems to have an exponential complexity where for Boost::di it looks linear. This difference is surprising because even without autowire boost::di is faster. I am also surprise I cannot compile a graph with more than 100 classes.
I wonder which template black bagic makes this kind of performance difference. If we find it we could use it for kangaru's autowire.
You can find my test bench it this repository: https://github.com/Dragnalith/di_experiment. The dependency of this gen_test.h matched the
57
class count row.The text was updated successfully, but these errors were encountered: