Gradle compileJava very slow (90s) for very small project

performance

(Marcel Overdijk) #1

I have a very small project using Gradle 2.13 wrapper but the compileJava is very slow.

I tried with ./gradlew clean compileJava -i --profile and the output is:

Description	Duration
Total Build Time	1m29.17s
Startup	0.729s
Settings and BuildSrc	0.156s
Loading Projects	0.005s
Configuring Projects	0.102s
Task Execution	1m28.16s

Also looking at the other tabs gives no clue where it is taking so long.
E.g. dependency resolution took:

Dependencies	Duration
All dependencies	1.058s

What else could I do do figure out what is going on.
I’m running on OSX.

Regards,
Marcel


(Dimitar Dimitrov) #2

Try using --profile and when you identify what is slow, try to get more info about that using --debug.

The output of the profile option goes under /build/reports/profile.*


(Marcel Overdijk) #3

Yes Dimitar, I already did the --profile thing. The summary of the report are already included.
But I cannot see where the 1m28 is spend.
All individual tasks in de profile report only take 0.1s so I wonder what I can do more to get better insights.


(Lance Java) #4

You could try DEBUG logging instead of INFO (eg -d instead of -i)


(Marcel Overdijk) #5

With the -d option I don’t see anything special in the generated report.

However looking at the console I see this:

11:37:18.681 [INFO] [org.gradle.api.internal.tasks.compile.JdkJavaCompiler] Compiling with JDK Java compiler API.
11:38:51.277 [ERROR] [system.err] Note: Some input files use unchecked or unsafe operations.
11:38:51.278 [ERROR] [system.err] Note: Recompile with -Xlint:unchecked for details.
11:38:51.319 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Finished executing task ':compileJava'
11:38:51.320 [INFO] [org.gradle.execution.taskgraph.AbstractTaskPlanExecutor] :compileJava (Thread[Daemon worker,5,main]) completed. Took 1 mins 35.17 secs.
11:38:51.321 [DEBUG] [org.gradle.execution.taskgraph.AbstractTaskPlanExecutor] Task worker [Thread[Daemon worker,5,main]] finished, busy: 1 mins 35.18 secs, idle: 0.002 secs
11:38:51.321 [DEBUG] [org.gradle.execution.taskgraph.DefaultTaskGraphExecuter] Timing: Executing the DAG took 1 mins 35.185 secs
11:38:51.321 [LIFECYCLE] [org.gradle.BuildResultLogger] 
11:38:51.324 [LIFECYCLE] [org.gradle.BuildResultLogger] BUILD SUCCESSFUL
11:38:51.324 [LIFECYCLE] [org.gradle.BuildResultLogger] 
11:38:51.324 [LIFECYCLE] [org.gradle.BuildResultLogger] Total time: 1 mins 41.273 secs

This is where the time is lost, but I have no idea where to look.


(Lance Java) #6

How many java files is it compiling?


(Marcel Overdijk) #7

Only 56…
I also don’t have additional configuration for the Java compile task.


(lu.shunshun) #8

You can look into your “build/report” folder for the profile report. Gradle should generate a much more detailed report in HTM with “–profile” flag.


(Dimitar Dimitrov) #9

Few things you can do:

Run the build with -m and see if the build is much faster.

If yes - then it’s a task that is slowing you down. Start excluding the executed tasks with -x until you find which task is slow.

If -m is slow, then it is your build configuration. Start commenting out parts of the build until you find the minimum change that makes it fast again.

These shall give you more ideas about what to do next (feel free to post here).


(Marcel Overdijk) #10

Hi,

I tried disabling almost everything from my build.gradle file (plugin, tasks) and was only executing the compileJava task, and it remained slow.

Desperately I started removing class by class and suddenly the build got faster when removing Repository classes using Jooq. To isolate the problem a little bit of Googling resulted in http://stackoverflow.com/questions/34223249/slow-compilation-with-jooq-3-6-plain-sql-and-the-javac-compiler.

Thanks for your help, much appreciated!