-
Notifications
You must be signed in to change notification settings - Fork 459
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
Consider migrating Spotless Gradle plugin to use Task Configuration Avoidance #269
Comments
@nedtwigg I'm in the middle of playing around with the Spotless source code to see if I can resolve this issue myself, but I'm unsure how to build the Spotless plugin and then expose it to jupiter-collection-testers to see if my changes work. Do you have any advice as to how I could do this? |
I would setup I think it might also work to use composite builds and add |
Thanks @nedtwigg! I'll give |
Hmm, small problem: since Task Configuration Avoidance is a Gradle 4.9 feature, if I try to swap out eager I've considered changing this line in I've also considered using reflection, but I don't know if it's appropriate or even where to begin with it, as my knowledge of reflection is still beginner-level. @nedtwigg Thoughts? |
Would something like JOOR's |
I would update gradle for your local build to 4.9, and not worry about compatibility. Then I would benchmark. For gradle 4.9, how much faster is a build with task configuration avoidance than without it? My suspicion is that Spotless will gain little from it, because we already went to great lengths with the If we need to drop support for 2.14, 3, or even 4.8 so that we can get a significant performance improvement, then that might be worth it. But if we're looking at a 10ms perf gain on a 5,000ms build, then I don't think it's worth taking on the maintenance burden of supporting an incubating API. If the performance gains are substantial, we can then evaluate whether we do reflection, drop compat, etc. |
Cool, thanks for sharing your thoughts @nedtwigg! I'll see how far I can go with making Spotless depend on Gradle 4.9. I'll profile things at a later date, but (as I'll explain in my next comment), I'll profile Spotless against my project jupiter-collection-testers as well, as I believe that will be the best indicator of whether it's worth supporting the incubating API. |
tl;dr: I agree that Spotless itself won’t gain much from task configuration avoidance, but I think it'll help most in situations where users (such as myself) use Spotless with other plugins that “plug” into the To explain what I mean, my project jupiter-collection-testers has a custom Like Spotless, these two tasks respectively apply code refactorings and check if the code is already refactored. Also like Spotless, However, my plugin actually runs Refaster n * k times every time
Under the hood, my plugin creates one And since my project imports Spotless, it eagerly configures (creates) all these tasks each and every time, even if I’m running an unrelated task like Long story short, if Spotless can avoid configuring |
My vote is to close it. Search will dig it up if it becomes relevant again. Thanks for the hard work implementing and benchmarking, good to know the results :) |
You're very welcome, and cheers @nedtwigg. :) |
I'm re-opening this issue for now, to hopefully remind me to run the benchmarks again, which I now believe are misleading after a helpful comment from @thc202 implied that I benchmarked the wrong Gradle command! |
We have noticed a rather large difference when configuration a custom format (the difference with just java isn't as remarkable). |
Thank you @litpho, that's good to know! I'm pretty sure now that I just messed up with my earlier benchmarking, so re-benchmarking this PR is at the top of my open-source todo list. And apologies for the overall lack of activity. I started a new job recently, so I'm not sure yet when I'll have the time and energy to continue working on this PR. But stay tuned, nonetheless. :) |
Just an aside, #348 revealed an oopsie that was causing Spotless' configuration times to be way higher than necessary. With that fixed, and our built-in lazy evaluation, my skepticism that this is a worthwhile investment for Spotless is renewed. |
Looks like grolifant added a utility library for this. |
This issue and its PR's have been a bit of a time sink, so I'm closing this issue. I'm happy to reopen iff you have a build where configuration avoidance would improve performance, with profiling data to back it up. Spotless already has built-in lazy configuration, so I'm skeptical that we gain anything with this change. If we ever need to release a |
@nedtwigg Agreed. Let's wait until if or when task configuration avoidance becomes the only option available. :) |
Hi @nedtwigg, since this issue already exists, I'm not opening a new one, but I still think that Spotless plugin not playing well with Gradle's configuration avoidance is an issue. I recently stumbled upon this when I tried to use configuration avoidance to simplify our build script and realized it's not working. After some debugging I came to the very same conclusion as OP did - Spotless plugin actually causes some tasks to get configured, while these tasks would not get configured in its absence. This doesn't seem right to me. You see, I don't really care about how Spotless plugin is coded and whether or not it uses the configuration avoidance internally for it's own stuff, but I do think that it should not mess with other tasks which aren't associated with spotless in any way. Not only because it's not necessary, but because some people (such as myself) might actually want to benefit from configuration avoidance in some way and Spotless plugin breaks this. I didn't do any in-depth analysis, but just a quick check of the source code, yet I found this part of the code to be the cause of the problem. Obviously, iterating over these tasks makes Gradle configure them even though it normally wouldn't (using Gradle 5.6, btw.). Knowing that, I came up with a workaround: setting Since I haven't yet had the need to study Gradle's Plugin API, I can't tell how difficult it would be to fix this. Nevertheless, I think it should be fixed and wanted to bring this up as IMHO, this is not just a performance issue, but an issue in general. |
Thanks for making this distinction @davidmoidl. I've opened a different issue to handle this case. If it turns out that it is impossible to fix that other issue without implementing this issue as well, then I'll be happy to revisit the compatibility guarantees which have caused me to close this issue. |
For the benefit of issue subs, this has been released (partially, see #444 for details) in |
I'm in the middle of migrating my personal project jupiter-collection-testers to use a new feature introduced in Gradle 4.9 called Task Configuration Avoidance, over at this feature branch. However, I am currently stuck on the Spotless Gradle plugin, because even if I don't run
gradlew spotless[Check|Apply]
, the plugin seems to directly depend on and thus eagerly configure (create) a number of tasks whichspotless[Check|Apply]
needs but other tasks likehelp
don't need.The reason that I believe Spotless is eagerly configuring these tasks, whichever ones they are, is because when I comment out these lines, the command
gradlew help -Dorg.gradle.internal.tasks.stats
produces the following relatively small output,as opposed to the following larger output,
The text was updated successfully, but these errors were encountered: