GoogleContainerTools / jib

🏗 Build container images for your Java applications.
Apache License 2.0
13.64k stars 1.44k forks source link

[Q] Jib CLI vs Jib Gradle plugin performance #4107

Open artemptushkin opened 1 year ago

artemptushkin commented 1 year ago

I want to get public opinion and know how others see and organize this.

Given:

The reality is that Gradle defines the chain tasks so we always pass redundant configuration steps, and we can easily get into a situation where we recompile something just because the task is not incremental from Gradle's perspective (another story).

What's this for pipeline?

We have to pull and push the Gradle cache for other non-significant tasks (compile) -> for the big project it's time-consuming

Assumption

If we get rid of the plugin and replace it with just Jib CLI jib jar the job will be faster keeping the same functionality

Practice

It's faster confirmed:

From 3-5 minutes of running the Gitlab CI/CD job we have now 1-2 minutes

But....

The startup changes from ~25 seconds to ~40 seconds, you can see the Spring log startup degradation on the screenshot

image

The layers/start difference:

Questions.

Why is Spring start-up time so different between Jib CLI and Jib Gradle plugin build?

Are there any known best practices to optimize the build and startup time?

Is Jib approach documented? I want to know better how and why you build like this

wwadge commented 1 year ago

Issue feels a bit all over the place. In my builds, gradle skips over all tasks that it knows it doesn't need to do work on, this includes jib plugin (pass the skip option) to avoid pushing images for things that haven't changed.

Re startup time and differences, I'm going to guess this is Spring boot's plugin adding additional stuff when done via a gradle task (which doesn't execute in the CLI). Things you may want to explore to improve your startup cost:

artemptushkin commented 9 months ago

I want to get back to the topic and say that for one of my projects I have set up jib cli (jar) without the Gradle plugin and it's amount ~2 times more efficient because we ignore all the gradle scanning and configurations as they are irrelevant.

This plugin only needs the JAR, which can be produced as an artifact of a separate job.

wwadge commented 9 months ago

Gradle can also be told to cache configurations too in gradle.properties if you want to see the same effect. Takes some effort to get everything cached correctly however.