Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop invoking bitrise cache for tasks Gradle task. #62

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

designedbyz
Copy link

I was poking around at the cache utilization diagnostics where I work and noticed a rather interesting trend: approximately 25% of our cache invocations were for tasks --all, a gradle task that the diagnostics report is not cacheable because it takes the entire project state as an input:

image

We don't directly invoke the tasks task in any of our workflows, so I started tracing it down and found that it was mostly called by the Android lint and unit test Bitrise steps. Those steps in turn make use of the GetVariants function defined in this repository, which appears to be where tasks --all is invoked.

Passing the --no-build-cache flag to Gradle at execution time should disable the build cache for the tasks task and fix the problem. There may be a slight risk that this increases build times for customers with significantly complex buildSrc or included build logic, but in testing with a local cache in our project I couldn't figure out a way to cause those tasks to come from the cache anyways.

This may also might not be the only solution, there'd be several efficient ways to do this with a custom Gradle plugin, this is just what appeared to me to be the simplest solution given my lack of experience with the step framework

The Gradle `tasks` task is never cacheable because, according to the Gradle diagnostics, it "Uses the whole project state as an input". Attempting to cache it leads to significant cache invocation utilization against our quota; approximately 25% of the cache invocations where I work are for `./gradlew tasks --all`
@zsolt-marta-bitrise
Copy link

zsolt-marta-bitrise commented Nov 26, 2024

Thank you for your contribution!

The invocation you see in your list comes from the analytics plugin and we don't apply any kind of filter on the commands (as you can call this task deliberately too). If you disable the build cache, it will just disable the build cache plugin, not the analytics, so it will still show up. There is no way of disabling the plugin for a single invocation, since it's not a standard Gradle feature but our own analytics plugin applied by the init script.

You can opt out from analytics by setting the Collect Gradle build metrics flag to false in the Activate Bitrise Build Cache Add-On for Gradle step. But I discourage this as the analytics provides useful insights into task performance, dependencies (critical path), execution reasons, build performance and cache utilization trends.

You can apply configuration cache if your project supports it to speed this task up (as basically this task doesn't do anything significant after that)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants