Queue tasks for the Gradle daemon


(Attila Kelemen) #1

The Gradle daemon consumes a lot of memory, therefore I propose to enable specifying if a task is queueable. By task I mean a job passed to the daemon and not a single Gradle task. In my mind, this queueable property would work as follows: If the daemon is currently processing a queueable task and has only queueable task in its queue: Attempting to execute another task does not start another daemon but passes the task to the already running daemon which will execute it once it completed the previously queued tasks.

An example for a queueable task is build and probably any task executed by a build server. More generally, a task should be marked as queueable if it’s complation does not rely on unknown circumstances. For example, a “run” command s a bad candidate for a queueable if it needs to interact the user in any way.

The rational behind this is, that in an IDE (NetBeans in my case), you might accidentally execute multiple build commands which will spawn multiple daemons and those daemons might severly affect performance due to the high memory consumption.

The only drawback I can think of is that if a task never completes, it will block every other queued task. I believe however that this is not much of an issue because such a task will most likely require manual help and if manual help is necessary, the blocked tasks can be restarted manually as well.

ps.: If this feature will be implemented, I will need to be able to specify if a task is queueable through the Tooling API.