cordova-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jason Ginchereau <>
Subject RE: [DISCUSS] Faster incremental builds
Date Wed, 20 Apr 2016 00:58:55 GMT
I collected data for 4 projects with varying numbers and sizes of source files (mostly .js
and .png):
    Tiny  :     17 files, 0.24 MB (A new Cordova project created from the VS template)
    Small :     55 files,  7.7 MB
    Medium:    242 files,   44 MB
    Large : 12,923 files,  134 MB

Following are full -> incremental times for 'cordova prepare android' commands, without
any source file changes in between, averaged over 5 warm runs on my medium-spec Windows desktop
machine with SSD:

    Tiny  :  1.98 -> 1.84 s
    Small :  2.40 -> 1.94 s
    Medium:  4.22 -> 2.02 s
    Large : 50.24 -> 5.81 s

As you can see, larger projects see greatly improved prepare times when using the incremental

Also, I confirmed that without using the --incremental option with this change, times are
not measurably different compared to the released version 6.1.1 of Cordova. So there doesn't
seem to be any regression compared to the previous use of shelljs.cp('-R') to blindly copy
files when preparing.


-----Original Message-----
From: Steven Gill [] 
Sent: Tuesday, April 19, 2016 3:14 PM
Subject: Re: [DISCUSS] Faster incremental builds

Sounds like a worthy cause. Do you have any stats on how much time is saved?

Definitely put it behind the --incremental flag to start.

On Tue, Apr 19, 2016 at 2:43 PM, Jason Ginchereau <>

> We've had a few customers complain that the dev inner loop for Cordova 
> apps is slow compared to native app development. So recently I've been 
> looking at ways to optimize it. The two largest pieces of a Cordova 
> build are "prepare" and "compile" phases. While there's not much we 
> can realistically do to speed up the native-code compilation (in which 
> gradle/xcodebuild/etc is invoked), it's clear that the prepare phase 
> is not nearly as efficient as it could be. So I opened a JIRA for 
> that, and I have a solution in the works that I want to get feedback on.
> CB-11117: Preparing platforms should skip copying files which haven't 
> changed<
> f91ab2d7cd011db47%7c1&sdata=E2Ww9LusEmVkUgjXPPGnxcGz%2fMH8fWruqGWUrLXq
> KRk%3d> Many cordova CLI commands include a "prepare" operation, 
> including 'cordova build', 'cordova run', 'cordova plugin add', and 
> more. Every time each of those commands runs, the target platform is 
> "prepared", which involves copying all files from [<project>/www, 
> <project>/platforms/<platform>/platform_www, 
> <project>/merges/<platform>] to the platform's target www folder, as 
> well as copying a bunch of icons and splash screens to platform-specific locations.
> For the very first prepare of a platform, all that file copying is 
> necessary. But most of the time after that most of the files being 
> copied have not changed and therefore don't really need to be copied 
> again. So the typical developer inner loop (edit a few source files, 
> build and run the app, repeat) is a lot slower than it could be for a 
> Cordova project, especially one that includes a significant number of 
> source files or resources.
> Instead, Cordova should be smart enough to skip copying of files that 
> haven't changed, based on their last-modified timestamp. But there 
> should still be a way to force a clean/full/non-incremental copy if 
> desired. To preserve compatibility with all possible existing 
> workflows, I'm leaning toward keeping the full copy as the default 
> behavior, and enabling the optimization only with a new --incremental 
> flag, at least initially. If we find the incremental option is working 
> well for everyone, we can promote that behavior to default in a future major version
> See PRs here for implementation of this idea...
> Add FileUpdater module 
> to cordova-common
> Use FileUpdater to 
> optimize prepare for android platform I'll submit PRs for cordova-ios 
> and cordova-windows platforms soon, as well as a cordova-cli change to 
> enable the optimization via a new --incremental flag (assuming we 
> don't want to make it the default behavior).
> Jason
View raw message