More detailed profiling of project/task configuration


We are trying to use our gradle for more things than just the regular build. Specifically, we add it as one of the builders in Eclipse projects, to generate some code. As a part of that effort we are trying to minimize the execution (build) time for our complex multiproject build. We are able to bring down the time of the task in question to about 8 seconds, about 3 of which are spent dealing with buildSrc and resolving dependencies and about 5 seconds are spent configuring the projects before the task in question does its thing in a small fraction of a second.

The plan is to move things out of buildSrc and into pre-built and published plugins, to address those 3 seconds, but we are having trouble figuring out where the 5 seconds of configuration is spent. For example, using --profile we see that 1.7 seconds is spent configuring the root project and about 0.7 seconds each for two other projects that spend time, but we cannot explain why - there are more complex projects that take less.

We tried using --debug timestamps to figure more detail out but it is very hard to determine the context - what is being done and what for. Other than attempting to run a java profiler on gradle, is there a good way to get more detail out of profiling - specifically the configuration time for each project part / task?



I even tried jprofiler on this but the identifiers are not preserved in any form so I have no clue what I am looking at…

(René Groeschke) #3

Have you tried the --profile option?


Yes, I have. That is what gives me the data I have. I need to drill down deeper than that. It only tells me that my time is spent in project configuration but I don’t know which part of it (and/or why).

(Stefan Oehme) #5

For more details I’d use a profiler as you already suggested.

Apart from hotspots in the code, I’d also look at file operations (at least YourKit tracks those for you). A very common cause of slow configuration time is file I/O.


I am almost 100% sure it is file I/O but can’t pinpoint it. I used a jprofiler but couldn’t make sense of things are all I saw was obfuscated/generic names that I could not relate to what I have in *.gradle (and *.groovy) files.


Are there any suggestions at all?