Gradle compileJava task is incredible slow on macos


(Michael Bohn) #1

any hints what could make it so slow? I already added -XX:MaxPermSize=1024m -Xmx2048m -Xms256m to GRADLE_OPTS, but that doesn’t help.


(Peter Niederwieser) #2

Please provide output of ‘gradle -v’ (enclosed in HTML ‘code’ tags) and any configuration you have applied to the ‘compileJava’ task. Run ‘gradle compileJava -i --profile’. Check the log output and the generated profiling report (under ‘build’). Is it compilation or maybe dependency resolution that’s taking up the time?


(Michael Bohn) #3

Here are the data:

------------------------------------------------------------
Gradle 1.2
------------------------------------------------------------
  Gradle build time: Wednesday, September 12, 2012 10:46:02 AM UTC
Groovy: 1.8.6
Ant: Apache Ant(TM) version 1.8.4 compiled on May 22 2012
Ivy: 2.2.0
JVM: 1.6.0_37 (Apple Inc. 20.12-b01-434)
OS: Mac OS X 10.8.2 x86_64

Profiling Report:

Description Duration
Total Build Time
8m17.92s
Startup
0.659s
Settings and BuildSrc
0.685s
Loading Projects
0.002s
Configuring Projects
1.250s
Task Execution
8m15.26s

(Peter Niederwieser) #4

There should be more data in the report, like how long dependency resolution took. What can you see in the info log?


(Peter Niederwieser) #5

There should be more data in the report, like how long dependency resolution took. What can you see in the info log? How many source files do you compile? What’s the expected compile time? Have you configured the ‘compileJava’ task in any way? I really need more information in order to be able to help.


(Michael Bohn) #6

Depdendcy Resolution took this time:

Dependencies Duration
All dependencies
0.234s
:classpath
0.232s
:compile
0.001s
:driver
0.001s
classpath
0s

The compileJava Task looks like this: compileJava {

dependsOn << [ ‘generate’ ]

options.encoding = ‘UTF-8’ }

It is a big project with many source files. It should take less than 2 minutes to compile (on my colleague machines it in this time range). I had times up to 15 minutes.


(Peter Niederwieser) #7

Can you check if the problem occurs on other Macs too? What OS are your colleagues using? Does the info log reveal anything?

Does this improve performance?

tasks.withType(Compile) {
  options.fork = true
  options.forkOptions.with {
    memoryMaximumSize = "2048m" // try different values
  }
}

Or this?

tasks.withType(Compile) {
  options.useAnt = true
}

(Rolf Suurd) #8

Perhaps unrelated but after installing anti-virus software, my builds were incredibly slow.

After configuring gradle (among others) as an exception in my virusscanner, my builds were fast again.


(Michael Bohn) #9

With the fork options I’m down to: Total time: 6 mins 28.743 secs With useAnt its similar: 6 mins 37.054 secs

I don’t have a antivirus software installed.

The strange thing is that we have another Mac with gradle -v:

------------------------------------------------------------
Gradle 1.2
------------------------------------------------------------
  Gradle build time: Mittwoch, 12. September 2012 10:46 Uhr UTC
Groovy: 1.8.6
Ant: Apache Ant(TM) version 1.8.4 compiled on May 22 2012
Ivy: 2.2.0
JVM: 1.6.0_33 (Apple Inc. 20.8-b03-424)
OS: Mac OS X 10.8.1 x86_64

where the same build takes less than 2 minutes.


(Peter Niederwieser) #10

Hard to say, then. It’s certainly not something we have seen ourselves. (Most Gradle devs work on a Mac.) Maybe you have a slow disk, or some background process is eating up CPU time. I also recommend to give Oracle JDK 7 a try.


(Ramon Nogueira) #11

Had similar problems (long compile times compared to Ant). The secret sauce to get incremental compilation (with 1.8) is:

tasks.withType(Compile) {

options.useAnt = true

options.useDepend = true

}

Unfortunately, this generates a deprecation warning :frowning: