Gradle 1.1 builds slower using daemon


(andy) #1

Hi,

I am a new user of gradle (so it is likely I am doing something stupid).

From the doco I got the impression that running a gradle build with the daemon should speed things up (possibly by avoiding a load of startup overhead).

However, when I try this I find that the build runs slower overall when using the daemon…

I am using gradle 1.1 on Win7 64bit from a command line.

If I run a build from the command line without the daemon I get:

C:\Users\andy.redhead\git\demo-numberguess\numberguess>gradle -Peap6repo=C:/ar-work/devenv/testing/repo compileJava
:compileJava UP-TO-DATE
  BUILD SUCCESSFUL
  Total time: 3.715 secs

When I run with the daemon I get:

C:\Users\andy.redhead\git\demo-numberguess\numberguess>gradle --daemon -Peap6repo=C:/ar-work/devenv/testing/repo compileJava
:compileJava UP-TO-DATE
  BUILD SUCCESSFUL
  Total time: 6.862 secs

The build time is ~3 seconds longer (on a 3.5 second build).

Running with the daemon with -d shows:

C:\Users\andy.redhead\git\demo-numberguess\numberguess>gradle --daemon -d -Peap6repo=C:/ar-work/devenv/testing/repo compileJava
21:44:23.730 [DEBUG] [org.gradle.logging.internal.DefaultLoggingConfigurer] Finished configuring with level: DEBUG, configurers: [org.gradle.logging.internal.OutputEventRenderer@3194737d, org.gradle.logging.internal.logback.LogbackLoggingConfigurer@92a2cf9, org.gradle.logging.internal.JavaUtilLoggingConfigurer@2fee9422]
21:44:23.890 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Waiting to acquire shared lock on daemon addresses registry.
21:44:23.894 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Lock acquired.
21:44:23.915 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on daemon addresses registry.
21:44:23.917 [DEBUG] [org.gradle.messaging.remote.internal.inet.TcpOutgoingConnector] Attempting to connect to [6c03b282-7451-4972-8b0a-dc037c172aad port:49515, addresses:[/127.0.0.1, /0:0:0:0:0:0:0:1]].
21:44:23.919 [DEBUG] [org.gradle.messaging.remote.internal.inet.TcpOutgoingConnector] Trying to connect to address /127.0.0.1.
21:44:24.933 [DEBUG] [org.gradle.messaging.remote.internal.inet.TcpOutgoingConnector] Cannot connect to address /127.0.0.1, skipping.
21:44:24.938 [DEBUG] [org.gradle.messaging.remote.internal.inet.TcpOutgoingConnector] Trying to connect to address /0:0:0:0:0:0:0:1.
21:44:25.946 [DEBUG] [org.gradle.messaging.remote.internal.inet.TcpOutgoingConnector] Cannot connect to address /0:0:0:0:0:0:0:1, skipping.
21:44:25.953 [DEBUG] [org.gradle.launcher.daemon.client.DefaultDaemonConnector] We cannot connect to the daemon at [6c03b282-7451-4972-8b0a-dc037c172aad port:49515, addresses:[/127.0.0.1, /0:0:0:0:0:0:0:1]] due to org.gradle.messaging.remote.internal.ConnectException: Could not connect to server [6c03b282-7451-4972-8b0a-dc037c172aad port:49515, addresses:[/127.0.0.1, /0:0:0:0:0:0:0:1]]. Tried addresses: [/127.0.0.1, /0:0:0:0:0:0:0:1].. We will not remove this daemon from the registry because the connection issue may have been temporary.
21:44:25.961 [DEBUG] [org.gradle.messaging.remote.internal.inet.TcpOutgoingConnector] Attempting to connect to [7a999b55-05bb-4178-be76-21738c9e448e port:53612, addresses:[/127.0.0.1, /0:0:0:0:0:0:0:1]].
21:44:25.966 [DEBUG] [org.gradle.messaging.remote.internal.inet.TcpOutgoingConnector] Trying to connect to address /127.0.0.1.
21:44:26.973 [DEBUG] [org.gradle.messaging.remote.internal.inet.TcpOutgoingConnector] Cannot connect to address /127.0.0.1, skipping.
21:44:26.974 [DEBUG] [org.gradle.messaging.remote.internal.inet.TcpOutgoingConnector] Trying to connect to address /0:0:0:0:0:0:0:1.
21:44:27.975 [DEBUG] [org.gradle.messaging.remote.internal.inet.TcpOutgoingConnector] Cannot connect to address /0:0:0:0:0:0:0:1, skipping.
21:44:27.982 [DEBUG] [org.gradle.launcher.daemon.client.DefaultDaemonConnector] We cannot connect to the daemon at [7a999b55-05bb-4178-be76-21738c9e448e port:53612, addresses:[/127.0.0.1, /0:0:0:0:0:0:0:1]] due to org.gradle.messaging.remote.internal.ConnectException: Could not connect to server [7a999b55-05bb-4178-be76-21738c9e448e port:53612, addresses:[/127.0.0.1, /0:0:0:0:0:0:0:1]]. Tried addresses: [/127.0.0.1, /0:0:0:0:0:0:0:1].. We will not remove this daemon from the registry because the connection issue may have been temporary.
21:44:27.990 [DEBUG] [org.gradle.messaging.remote.internal.inet.TcpOutgoingConnector] Attempting to connect to [e529c701-04f0-4409-a703-ea2a6d362c39 port:55799, addresses:[/127.0.0.1, /0:0:0:0:0:0:0:1]].
21:44:27.994 [DEBUG] [org.gradle.messaging.remote.internal.inet.TcpOutgoingConnector] Trying to connect to address /127.0.0.1.
21:44:28.998 [DEBUG] [org.gradle.messaging.remote.internal.inet.TcpOutgoingConnector] Cannot connect to address /127.0.0.1, skipping.
21:44:29.004 [DEBUG] [org.gradle.messaging.remote.internal.inet.TcpOutgoingConnector] Trying to connect to address /0:0:0:0:0:0:0:1.
21:44:30.009 [DEBUG] [org.gradle.messaging.remote.internal.inet.TcpOutgoingConnector] Cannot connect to address /0:0:0:0:0:0:0:1, skipping.
21:44:30.015 [DEBUG] [org.gradle.launcher.daemon.client.DefaultDaemonConnector] We cannot connect to the daemon at [e529c701-04f0-4409-a703-ea2a6d362c39 port:55799, addresses:[/127.0.0.1, /0:0:0:0:0:0:0:1]] due to org.gradle.messaging.remote.internal.ConnectException: Could not connect to server [e529c701-04f0-4409-a703-ea2a6d362c39 port:55799, addresses:[/127.0.0.1, /0:0:0:0:0:0:0:1]]. Tried addresses: [/127.0.0.1, /0:0:0:0:0:0:0:1].. We will not remove this daemon from the registry because the connection issue may have been temporary.
21:44:30.023 [DEBUG] [org.gradle.messaging.remote.internal.inet.TcpOutgoingConnector] Attempting to connect to [8e2a95d5-aaf3-445c-9d05-01d6320ae02a port:50775, addresses:[/127.0.0.1, /0:0:0:0:0:0:0:1]].
21:44:30.028 [DEBUG] [org.gradle.messaging.remote.internal.inet.TcpOutgoingConnector] Trying to connect to address /127.0.0.1.
21:44:30.034 [DEBUG] [org.gradle.messaging.remote.internal.inet.TcpOutgoingConnector] Connected to address /127.0.0.1.
21:44:30.059 [INFO] [org.gradle.launcher.daemon.client.DaemonClient] Connected to the daemon. Dispatching Build{id=89a7cb70-2093-4097-9caf-4a78c986e236.1, currentDir=C:\Users\andy.redhead\git\demo-numberguess\numberguess} request.
21:44:30.084 [INFO] [org.gradle.launcher.daemon.server.exec.LogToClient] The client will now receive all logging from the daemon (pid: 7828). The daemon log file: C:\Users\andy.redhead\.gradle\daemon.1\daemon-7828.out.log

Is it normal to have a number of failed attempts to connect to the daemon?

Without really knowing whats going on it looks like there is a lot of time spent failing to connect to the daemon… ?

Cheers, Andy


(René Groeschke) #2

hey andy, when you run gradle with the --daemon option for the first time, gradle initialises and starts the daemon process in the background, that the overhead you see. But running gradle with --daemon again should be definitely faster.

cheers, René


(andy) #3

Hi,

thanks for your reply :slight_smile:

I appreciate that the first time you run with the daemon there is an overhead for “getting stuff started” and that once you’ve got the daemon running, subsequent invocations should be quicker - unfortunately that isn’t what I’m finding.

I should have made it clear in my original post that the timings I took were after several runs.

The first thing I did this morning after I got to the office was run a series of builds from the command line (exactly the same as before).

I ran 3 builds consecutively for with and without the daemon. The results:

First, without daemon:

Total time: 3.911 secs Total time: 3.632 secs Total time: 3.598 secs

Next, with daemon:

Total time: 16.885 secs Total time: 10.999 secs Total time: 10.989 secs

Looking at the with-daemon times, there is a definite reduction in total time for subsequent builds however the total time even for subsequent builds is still a lot higher than running without the daemon - which I find completely counter intuitive!

I’ve added the top of the debug output for a “subsequent daemon invocation” run below (I can provide the complete output if required). Once again I’m struck by the amount of time spent re-trying to connect to the daemon at the start of the process… ?

I am happy to provide the build.gradle file if it would be helpful?

Cheers, Andy

08:13:34.656 [DEBUG] [org.gradle.logging.internal.DefaultLoggingConfigurer] Finished configuring with level: DEBUG, configurers: [org.gradle.logging.internal.OutputEventRenderer@51e7c4d4, org.gradle.logging.internal.logback.LogbackLoggingConfigurer@472b644e, org.gradle.logging.internal.JavaUtilLoggingConfigurer@71c66162]
08:13:34.813 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Waiting to acquire shared lock on daemon addresses registry.
08:13:34.818 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Lock acquired.
08:13:34.837 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on daemon addresses registry.
08:13:34.838 [DEBUG] [org.gradle.messaging.remote.internal.inet.TcpOutgoingConnector] Attempting to connect to [6c03b282-7451-4972-8b0a-dc037c172aad port:49515, addresses:[/127.0.0.1, /0:0:0:0:0:0:0:1]].
08:13:34.839 [DEBUG] [org.gradle.messaging.remote.internal.inet.TcpOutgoingConnector] Trying to connect to address /127.0.0.1.
08:13:35.842 [DEBUG] [org.gradle.messaging.remote.internal.inet.TcpOutgoingConnector] Cannot connect to address /127.0.0.1, skipping.
08:13:35.844 [DEBUG] [org.gradle.messaging.remote.internal.inet.TcpOutgoingConnector] Trying to connect to address /0:0:0:0:0:0:0:1.
08:13:36.846 [DEBUG] [org.gradle.messaging.remote.internal.inet.TcpOutgoingConnector] Cannot connect to address /0:0:0:0:0:0:0:1, skipping.
08:13:36.849 [DEBUG] [org.gradle.launcher.daemon.client.DefaultDaemonConnector] We cannot connect to the daemon at [6c03b282-7451-4972-8b0a-dc037c172aad port:49515, addresses:[/127.0.0.1, /0:0:0:0:0:0:0:1]] due to org.gradle.messaging.remote.internal.ConnectException: Could not connect to server [6c03b282-7451-4972-8b0a-dc037c172aad port:49515, addresses:[/127.0.0.1, /0:0:0:0:0:0:0:1]]. Tried addresses: [/127.0.0.1, /0:0:0:0:0:0:0:1].. We will not remove this daemon from the registry because the connection issue may have been temporary.
08:13:36.851 [DEBUG] [org.gradle.messaging.remote.internal.inet.TcpOutgoingConnector] Attempting to connect to [7a999b55-05bb-4178-be76-21738c9e448e port:53612, addresses:[/127.0.0.1, /0:0:0:0:0:0:0:1]].
08:13:36.853 [DEBUG] [org.gradle.messaging.remote.internal.inet.TcpOutgoingConnector] Trying to connect to address /127.0.0.1.
08:13:37.854 [DEBUG] [org.gradle.messaging.remote.internal.inet.TcpOutgoingConnector] Cannot connect to address /127.0.0.1, skipping.
08:13:37.856 [DEBUG] [org.gradle.messaging.remote.internal.inet.TcpOutgoingConnector] Trying to connect to address /0:0:0:0:0:0:0:1.
08:13:38.858 [DEBUG] [org.gradle.messaging.remote.internal.inet.TcpOutgoingConnector] Cannot connect to address /0:0:0:0:0:0:0:1, skipping.
08:13:38.861 [DEBUG] [org.gradle.launcher.daemon.client.DefaultDaemonConnector] We cannot connect to the daemon at [7a999b55-05bb-4178-be76-21738c9e448e port:53612, addresses:[/127.0.0.1, /0:0:0:0:0:0:0:1]] due to org.gradle.messaging.remote.internal.ConnectException: Could not connect to server [7a999b55-05bb-4178-be76-21738c9e448e port:53612, addresses:[/127.0.0.1, /0:0:0:0:0:0:0:1]]. Tried addresses: [/127.0.0.1, /0:0:0:0:0:0:0:1].. We will not remove this daemon from the registry because the connection issue may have been temporary.
08:13:38.863 [DEBUG] [org.gradle.messaging.remote.internal.inet.TcpOutgoingConnector] Attempting to connect to [e529c701-04f0-4409-a703-ea2a6d362c39 port:55799, addresses:[/127.0.0.1, /0:0:0:0:0:0:0:1]].
08:13:38.864 [DEBUG] [org.gradle.messaging.remote.internal.inet.TcpOutgoingConnector] Trying to connect to address /127.0.0.1.
08:13:39.866 [DEBUG] [org.gradle.messaging.remote.internal.inet.TcpOutgoingConnector] Cannot connect to address /127.0.0.1, skipping.
08:13:39.868 [DEBUG] [org.gradle.messaging.remote.internal.inet.TcpOutgoingConnector] Trying to connect to address /0:0:0:0:0:0:0:1.
08:13:40.870 [DEBUG] [org.gradle.messaging.remote.internal.inet.TcpOutgoingConnector] Cannot connect to address /0:0:0:0:0:0:0:1, skipping.
08:13:40.873 [DEBUG] [org.gradle.launcher.daemon.client.DefaultDaemonConnector] We cannot connect to the daemon at [e529c701-04f0-4409-a703-ea2a6d362c39 port:55799, addresses:[/127.0.0.1, /0:0:0:0:0:0:0:1]] due to org.gradle.messaging.remote.internal.ConnectException: Could not connect to server [e529c701-04f0-4409-a703-ea2a6d362c39 port:55799, addresses:[/127.0.0.1, /0:0:0:0:0:0:0:1]]. Tried addresses: [/127.0.0.1, /0:0:0:0:0:0:0:1].. We will not remove this daemon from the registry because the connection issue may have been temporary.
08:13:40.875 [DEBUG] [org.gradle.messaging.remote.internal.inet.TcpOutgoingConnector] Attempting to connect to [8e2a95d5-aaf3-445c-9d05-01d6320ae02a port:50775, addresses:[/127.0.0.1, /0:0:0:0:0:0:0:1]].
08:13:40.877 [DEBUG] [org.gradle.messaging.remote.internal.inet.TcpOutgoingConnector] Trying to connect to address /127.0.0.1.
08:13:41.878 [DEBUG] [org.gradle.messaging.remote.internal.inet.TcpOutgoingConnector] Cannot connect to address /127.0.0.1, skipping.
08:13:41.880 [DEBUG] [org.gradle.messaging.remote.internal.inet.TcpOutgoingConnector] Trying to connect to address /0:0:0:0:0:0:0:1.
08:13:42.881 [DEBUG] [org.gradle.messaging.remote.internal.inet.TcpOutgoingConnector] Cannot connect to address /0:0:0:0:0:0:0:1, skipping.
08:13:42.884 [DEBUG] [org.gradle.launcher.daemon.client.DefaultDaemonConnector] We cannot connect to the daemon at [8e2a95d5-aaf3-445c-9d05-01d6320ae02a port:50775, addresses:[/127.0.0.1, /0:0:0:0:0:0:0:1]] due to org.gradle.messaging.remote.internal.ConnectException: Could not connect to server [8e2a95d5-aaf3-445c-9d05-01d6320ae02a port:50775, addresses:[/127.0.0.1, /0:0:0:0:0:0:0:1]]. Tried addresses: [/127.0.0.1, /0:0:0:0:0:0:0:1].. We will not remove this daemon from the registry because the connection issue may have been temporary.
08:13:42.886 [DEBUG] [org.gradle.messaging.remote.internal.inet.TcpOutgoingConnector] Attempting to connect to [7dd347f0-96fd-4ce5-9eb9-11b18841108a port:52843, addresses:[/127.0.0.1, /0:0:0:0:0:0:0:1]].
08:13:42.887 [DEBUG] [org.gradle.messaging.remote.internal.inet.TcpOutgoingConnector] Trying to connect to address /127.0.0.1.
08:13:43.889 [DEBUG] [org.gradle.messaging.remote.internal.inet.TcpOutgoingConnector] Cannot connect to address /127.0.0.1, skipping.
08:13:43.891 [DEBUG] [org.gradle.messaging.remote.internal.inet.TcpOutgoingConnector] Trying to connect to address /0:0:0:0:0:0:0:1.
08:13:44.893 [DEBUG] [org.gradle.messaging.remote.internal.inet.TcpOutgoingConnector] Cannot connect to address /0:0:0:0:0:0:0:1, skipping.
08:13:44.896 [DEBUG] [org.gradle.launcher.daemon.client.DefaultDaemonConnector] We cannot connect to the daemon at [7dd347f0-96fd-4ce5-9eb9-11b18841108a port:52843, addresses:[/127.0.0.1, /0:0:0:0:0:0:0:1]] due to org.gradle.messaging.remote.internal.ConnectException: Could not connect to server [7dd347f0-96fd-4ce5-9eb9-11b18841108a port:52843, addresses:[/127.0.0.1, /0:0:0:0:0:0:0:1]]. Tried addresses: [/127.0.0.1, /0:0:0:0:0:0:0:1].. We will not remove this daemon from the registry because the connection issue may have been temporary.
08:13:44.898 [DEBUG] [org.gradle.messaging.remote.internal.inet.TcpOutgoingConnector] Attempting to connect to [4d3d0908-9907-4b6b-af0d-229f2f17d24e port:49492, addresses:[/127.0.0.1, /0:0:0:0:0:0:0:1]].
08:13:44.899 [DEBUG] [org.gradle.messaging.remote.internal.inet.TcpOutgoingConnector] Trying to connect to address /127.0.0.1.
08:13:44.901 [DEBUG] [org.gradle.messaging.remote.internal.inet.TcpOutgoingConnector] Connected to address /127.0.0.1.
08:13:44.933 [INFO] [org.gradle.launcher.daemon.client.DaemonClient] Connected to the daemon. Dispatching Build{id=d0be6b66-f4a5-402b-ae0b-fb2f1e816262.1, currentDir=C:\Users\andy.redhead\git\demo-numberguess\numberguess} request.
08:13:44.959 [INFO] [org.gradle.launcher.daemon.server.exec.LogToClient] The client will now receive all logging from the daemon (pid: 7132). The daemon log file: C:\Users\andy.redhead\.gradle\daemon.1\daemon-7132.out.log
08:13:44.959 [INFO] [org.gradle.launcher.daemon.server.exec.ExecuteBuild] Executing build with daemon context: DefaultDaemonContext[uid=d498cfff-1d60-4c60-94bf-4c88d6cb10cf,javaHome=C:\ar-work\devenv\tools\java\jdk\jdk-7u1,daemonRegistryDir=C:\Users\andy.redhead\.gradle\daemon,pid=7132,idleTimeout=10800000,daemonOpts=-XX:MaxPermSize=256m,-XX:+HeapDumpOnOutOfMemoryError,-Xmx1024m,-Dfile.encoding=windows-1252]
08:13:44.962 [DEBUG] [org.gradle.logging.internal.DefaultLoggingConfigurer] Finished configuring with level: DEBUG, configurers: [org.gradle.logging.internal.OutputEventRenderer@9ed62a5, org.gradle.logging.internal.logback.LogbackLoggingConfigurer@3fe743ba, org.gradle.logging.internal.JavaUtilLoggingConfigurer@680f891c]
08:13:44.962 [INFO] [org.gradle.BuildLogger] Starting Build
08:13:44.963 [DEBUG] [org.gradle.BuildLogger] Gradle user home: C:\Users\andy.redhead\.gradle
08:13:44.963 [DEBUG] [org.gradle.BuildLogger] Current dir: C:\Users\andy.redhead\git\demo-numberguess\numberguess
08:13:44.963 [DEBUG] [org.gradle.BuildLogger] Settings file: null
08:13:44.964 [DEBUG] [org.gradle.BuildLogger] Build file: null
08:13:44.965 [DEBUG] [org.gradle.initialization.BuildSourceBuilder] Starting to build the build sources.

(Luke Daley) #4

You can try clearing ‘~/.gradle/daemon/1.1/’. There’s a known issue where if a daemon crashes its entry in ‘~/.gradle/daemon/1.1/registry.bin’ is not cleared which means future clients try to connect to it.

It’s a known problem and on our schedule to be fixed.


(andy) #5

That’s fixed it :slight_smile:

Three consecutive with-daemon runs (from cold): Total time: 7.082 secs Total time: 1.389 secs Total time: 1.123 secs

Thank you.


(Adam Murdoch) #6

This issue is fixed in master and will be included in Gradle 1.3. If you run into it the problem again, could you try using a nightly build: http://gradle.org/nightly?


(Szczepan Faber) #7

I don’t think we have fixed it (we fixed something very similar). I’ve created a ticket: GRADLE-2464. I plan to fix it because it is little work. Current workaround is removing the daemon folder as mentioned by Luke.


(andy) #8

Hi,

I could probably have a go with a nightly build once this is fixed (I’m really just getting started with Gradle at the moment) - I’ll watch out for the fix.

Thanks, once again.

Cheers, Andy