GoogleContainerTools / GoogleContainerTools/jib
[Q] Jib CLI vs Jib Gradle plugin performance
- Dominant language
- Java
- Stars
- 14.5k
- Forks
- 1.5k
- PR merge metrics
- No merged PRs in 30d
Description
I want to get public opinion and know how others see and organize this.
_Given:_
* a big Kotlin/Java project - 5 minutes for `./gradlew assemble` from scratch, many submodules
* CI/CD: build - test - build-image
* We consider here `build-image` job where we run build Docker image with `jibDockerBuild` and push it
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:
* We don't have redundant Java processes, Gradle tasks - so we can delete some cache pull/push
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
The layers/start difference:
* main-class:
* Jib Gradle plugin: the Spring Boot main application class
* Jib CLI: Spring Boot JarLaucher class
* docker entrypoint:
* Jib Gradle plugin: [ "java", "-cp", "@/app/jib-classpath-file", "com.iptiq.apptemplate.AppTemplateApplicationKt" ]
* Jib CLI: [ "java", "-cp", "@/app", "org.springframework.boot.loader.JarLauncher" ]
* layers:
* Jib Gradle produces 5 layers:
* third-party jars
* application jars
* classpath resources
* classes
* run files
* Jib CLI produces 3 layers:
* third-party jars
* Spring Boot loader classes
* application jars, classpath resources, classes, run files
**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
Contributor guide
Assessment
This issue has not been assessed yet.