Telerik blogs

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.

AppBuilder showing a build in progress
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.

What Are We Waiting For?

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.

Profiling and Optimizing plugman

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.

Speeding Up iOS

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!

Giving Back to the Community

Telerik Loves Cordova 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.

When Will These Updates Be Live in AppBuilder?

Later this week. And we have a whole lot more to announce. Stay tuned!

Martin Bektchiev

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
About the Author

TJ VanToll

TJ VanToll is a frontend developer, author, and a former principal developer advocate for Progress.


Comments are disabled in preview mode.