Gradle build (all tasks up to date) slow on bad network (high packet loss) with offline mode, debugging it why?


Any way to see what’s taking up all the time in Gradle. Here’s what I see with --offline --debug:

00:36:55.442 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleComponentRepository] Found artifact 'ant-launcher.jar (org.apache.ant:ant-launcher:1.9.4)' in resolver cache: /home/bernat/.gradle/caches/modules-2/files-2.1/org.apache.ant/ant-la
25 00:36:55.470 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Waiting to acquire shared lock on no_buildscript class cache for build file '/home/bernat/git/reco/modules/reco/ejb/ejb.gradle' (/home/bernat/.gradle/caches/2.4-20150331220024+0000/scripts/ejb_dafus
26 00:36:55.471 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Lock acquired.
27 00:37:33.867 [DEBUG] [org.gradle.configuration.project.BuildScriptProcessor] Timing: Running the build script took 38.731 secs
28 00:37:33.881 [INFO] [org.gradle.configuration.project.BuildScriptProcessor] Evaluating project ':war' using build file '/home/bernat/git/reco/modules/reco/war/war.gradle'.

So it took 30 seconds, but what took 30 seconds. I run the latest build, and all is up to date. Any option to see a more detailed report?

Description Duration
Total Build Time 3m42.20s
Startup 1.780s
Settings and BuildSrc 0.471s
Loading Projects 0.242s
Configuring Projects 6m18.14s
Task Execution 2.304s

Any way to see why are configuration so slow?

PS. I’m on a slow network, but the offline mode should mitigate that, shouldn’t it?

I would love to see a line by line profiling option :smile: to identify what actually requires 5 minutes in configuration.

Is the profile options the best I can get at the moment? :slight_smile: for performance debugging?

Something looks strange. Could you put your full log in a gist?

It’s taking 30 seconds to evaluate/execute your gradle script. The log is cut off, so I can’t tell which one, but if you look for “Evaluating project” you should see a file path. Is there anything in the gradle files that access remote resources?

The profile report doesn’t go into great detail. You can connect a debugger to the Gradle process to catch it in the “slow” part or a low-tech solution would be to have Gradle generate a thread dump when it seems to be waiting and see if there’s anything strange there.

Things that don’t respect offline mode include javadoc (options.links) and downloadLicenses from the license plugin.

Sadly I do not have the full log, and can’t reproduce as it was a travel wifi in a hotel. Maybe one could reproduce with some bad internet simulator :smile: But I’m thinking about a more general solution for slow builds profiling :-? because the current tells wheres slow, but not why :smile:

OK, can you provide any details about what your build scripts do?

Thinking back I use multiple plugins, so it’s possible that the plugin elements do not abid the offline command. No real idea how to facitilate this. Could one query for offline mode in its plugin? :smile:

Yep with gradle.startParameter.offline

Which plugins do you use?