Efficiency is important, and in Telerik AppBuilder we had an efficiency problem: our iOS and Android builds were taking too long, and we got sick of staring at animated gifs.
Who likes watching this?
As such, build performance was a major focus of our upcoming release. And after several weeks of profiling and optimizing, we're happy to announce an 8+ second improvement in Android build times, and a 26+ second improvement in iOS build times. In this article, I'll explain exactly what the optimizations were, and how our work benefited the entire Cordova/PhoneGap community.
After some intensive profiling, we found that the majority of build time was taken up adding Cordova plugins using
plugman. In fact, the time it took to execute
plugman multiple times was comparable to the time it took to perform the rest of our build steps combined!
Instead of trying to working around the issue, we decided to dig in upstream, and look into improving
We started with Android, and we quickly discovered a big problem: invoking
plugman multiple times was expensive - even if we didn't actually install plugins. Based on this, we implemented our first optimization: adding the ability to install multiple plugins in a single
plugman invocation. (Specifically you can repeat the
--plugin option multiple times. Refer to the pull request for more details.)
The results were drastic. The plugin installation step of a default AppBuilder Android project build went from ~11-12 seconds to ~3 seconds. An 8 second improvement!
Unfortunately we were only seeing minimal gains from this optimization on iOS, so we had to dig a little deeper.
After some more digging, and Node.js profiling, we found a bottleneck specific to iOS: a function that reads and parses the project's Xcode project file was unnecessarily being called once for each plugin being installed. So we introduced a simple caching mechanism that stores the parsed project file for subsequent plugins to access.
This small change also made a huge difference to AppBuilder build times. The plugin installation of a default iOS build went from 34 to 8 seconds. A 26 second improvement!
Image credit: Burke Holland, and his amazing design skills.
At Telerik we love giving back to the open-source community, and by making this change to
plugman directly, as of Cordova's 3.4.0-0.1.3 CLI release, all Cordova users benefit from the optimizations we made.
And our contributions to Cordova are just getting started. Earlier this month we fixed another issue involving an infinite loop with interdependent plugins - and we’re constantly looking for ways to upstream fixes to benefit the entire Cordova/PhoneGap ecosystem.
Later this week. And we have a whole lot more to announce. Stay tuned!
TJ VanToll is a frontend developer, author, and a former principal developer advocate for Progress.
Subscribe to be the first to get our expert-written articles and tutorials for developers!
All fields are required