-
Notifications
You must be signed in to change notification settings - Fork 460
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
Make spotless tasks all cacheable with the Gradle Build Cache #280
Comments
I'm skeptical that this will be a performance improvement. I'd want to see a benchmark before merging. |
I'm guessing that the performance benefits won't be that large on a project with few sources, but on a project with thousands of files, I'm guessing that the build cache will provide a nice short circuit for an initial checkout and run of |
@nedtwigg We have a customer that is currently working at optimizing their build using Gradle Enterprize. At this stage when they run I can share a GE screenshot directly with you if necessary. |
I did a quick investigation, and it looks like we can probably support this usecase by bumping our minimum-required gradle to No need for a screenshot, a gradle engineer with a real customer usecase is proof-enough for me that there's value in bumping the minimum. I'm definitely on-board with bumping to |
Thanks @nedtwigg. I took a deeper look and it's not going to be as simple as I'd hoped. It looks like I don't think this model is really correct:
Caching for the check case makes sense, with the cache key being made up of the hash of all or the source files, plus any other input parameters. What do you think? Would it make sense to split these 2 cases into 2 separate task implementations, thus allowing the inputs/outputs to be more correctly modelled? |
I agree that it doesn't make sense to cache I also agree that Spotless does not model the task correctly. I'm grateful to have a gradle dev look at it - the reason for the weird model that we chose is a limitation (as I understand it) in the Gradle incremental API. The downside of breaking it into two tasks is that you duplicate incremental-change tracking in A best-of-both-worlds answer might be this:
The hard part of the structure I outlined above is that I'm happy to split |
Thanks for the detailed analysis. First up, I would caution against making too strong assumptions when optimizing for "normal usage". In my experience, people tend to use tools in many varied and unexpected ways!
Proposed solutionI think the solution you outline could work. What I like about this mechanism is that there's no single task that has the same inputs and outputs. However, if I understand correctly, one downside is that the analysis for any badly formatted file would need to be executed twice: once to generate the An alternativeAnother possible solution would be for the main Instead of using patch files, it would also be possible for the main WDYT? |
^^^ All excellent points. A few comments: I love the patch idea, but I think that just writing-out the plain fixed content is probably easier to implement, debug, and maintain. If you're writing out the "clean" state for every file, whether it is dirty or not, then you're copying the entire source tree on every run of My instinct is that the formatter runs fast, and the disk is slow, but your caching results show that I'm wrong about that. I'm sure a gradle engineer has better heuristics around that than me. I'm always happy to merge performance-enhancing PRs with a real-world usecase that shows a speed increase. I definitely believe that caching |
An issue that we're going to have (just popped up in #559) is that most of our |
Just did a little experiment. Now that @bigdaz has implemented #576, it makes sense to mark |
Do you mean that even local cache doesn't work in many instances? |
Local cache will work in all instances. My impression was that the value came from the using the remote cache results on dev builds. I assumed that it was expensive to fill a remote build cache with stuff that will never hit anywhere besides the CI checkout path it was built on. But it's very easy to turn on, so here it is! 971e32c. Hopefully we'll have a fix soon, so that even if we are thrashing a cache, we won't be for long. |
The local build cache works as of plugin-gradle |
As of |
This should be as simple as adding the
@CachableTask
annotation to all of the relevant tasks.The text was updated successfully, but these errors were encountered: