This document covers this process:
http://docs.ros2.org/dashing/develope...
It is slightly out of date, but the gist of what is happening is still the same.
Basically it takes so long because it has to do a lot of work.
It has to generate code for C++, C, and Python for each type, then generate and compile rmw implementation specific code for each type (e.g. code generated by the DDS implementation), and then it has to generate and compile code to handle the interaction between the ROS types and the rmw implementation.
Also, this process is highly decoupled (each stage is an extension), which makes it very flexible for both code generators (i.e. if you wanted to add a new language like Java or something) and for the rmw implementation (i.e. if you wanted to add a new rmw implementation that has its own code generation). Unfortunately that means it hasn't scaled well, and results in starting Python many, many times (each time you start the interpreter it takes like 200ms on most machines), and that adds considerably to the overhead. We've talked about a solution to this in the past, but never had time to implement it.
One good trade off, though, is that applications compile faster (another good reason to separate your msg/srv files into a separate package) and things like code completion in your editor run faster because there's less complex templates behind message types and calls like create_publisher
or create_subscription
.