Can we make copy fromZipTree faster?


(Scott Palmer) #1

My colleague was working on some optimizations to our build process. Part of that is extracting SDKs for native code (headers and libs) with a standard Copy task using fromZipTree(The_SDK_Zip). What he found was that unzipping that way was about 5 times slower than if he uses the AntBuilder unzip from groovy.util.AntBuilder.

Is there something that can be tweaked to make the standard Gradle mechanism work faster? Like some property of the Copy task that can be set a certain way to skip checks for what is up-to-date or something like that? We are already unzipping to what should be a unique folder for each zip… so we skip the entire unzip step if the folder already exists.


(Luke Daley) #2

Two easy options I can think of:

task unzip(type: Copy) {
  into "foo"
  outputs.upToDateWhen { false } // always run this task (disable incremental build)
}

That shouldn’t be faster, but worth a try.

The other is to be less accurate and assume that the zip file never changes:

task unzip(type: Copy) {
  into "foo"
  onlyIf { !destinationDir.exists() || destinationDir.listFiles().empty } // skip the tasks if the destination directory already exists and is not empty
}

(that’s sketched code, I may have got a method name wrong)