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 plugman itself.
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!
About the Author
Martin Bektchiev is a senior developer at the AppBuilder team of Telerik. He is also a member of the MAT team which develops JustTrace and JustMock. He came to Telerik with a mainly C++ background and had worked on software for English language learning, an office suite and gambling software.
TJ VanToll is a web developer, speaker, and writer living in Lansing, MI and working as a developer advocate for Telerik. He is an open source advocate that is on the jQuery UI team and publishes his blog open source. TJ is also the author of an upcoming book from Manning: jQuery UI in Action. When not online, TJ is generally found chasing his twin sons in circles. TJ is @tjvantoll on Twitter and tjvantoll on Github.
Copyright © 2017, Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
Progress, Telerik, and certain product names used herein are trademarks or registered trademarks of Progress Software Corporation and/or one of its subsidiaries or affiliates in the U.S. and/or other countries. See Trademarks or appropriate markings.