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
Incremental Java compilation on public constant change #16495
Conversation
I know this is a big change, so I expect few iterations to make this in to Gradle. But I believe this will benefit Gradle and it's users. I probably missed some cases when I was writing tests, or there are parts that are not done by Gradle conventions or can be done better so I am open for any comment. Also currently this feature is automatically enabled, maybe it deserves some flag to make it enabled/disabled. Some more info:
On next run:
Main changes: Also is there a reason that source-class mapping is not in cache and it's written to file? This breaks build-cache for compileJava task. |
I've had a quick look at this and the changes make sense to me. It would be great to test this on some real world scenarios. For example, what about Android builds where the |
...e/java/compile/incremental/AbstractCrossTaskIncrementalJavaCompilationIntegrationTest.groovy
Outdated
Show resolved
Hide resolved
...e/java/compile/incremental/AbstractCrossTaskIncrementalJavaCompilationIntegrationTest.groovy
Show resolved
Hide resolved
e1ba63f
to
8dfeacf
Compare
...a/src/main/java/org/gradle/api/internal/tasks/compile/incremental/deps/ClassSetAnalysis.java
Outdated
Show resolved
Hide resolved
9b561f1
to
eb85136
Compare
@asodja Thank you for this PR. The Gradle team is busy wrapping up the Gradle 7.0 release. This will not get attention until that release is out. |
Thanks for letting me know. No problem |
@melix I think you missed his previous message, he's already looking into it :) I'd be happy to help too, if needed. It was my changes that caused this mess after all :) |
Indeed, after refreshing the page they showed up 🤦 Sorry for the noise D |
eb85136
to
9fc86ba
Compare
So I rebased it to latest master, it wasn't that bad in the end. But it still needs some work, some Groovy tests fail and previous compilation data is read twice now since that logic was changed a bit. And I just did a quick dirty fix for that so I could run tests. I will fix it in next days. |
bf1394e
to
ef6cb36
Compare
Hey @melix, this is now ready for a review. One note: I also did an optimization that adds a bit of complexity but it's imo worth it: for every constant I find "accessible" and "private" dependents. So accessible dependents are dependents that have accessible constant calculated from constant, e.g.:
And "private" dependents are all other cases. When collecting classes to compile I then check accessible dependents transitively, but for private dependents transitive check is not needed. I also did a simple optimization: constants that are calculated from method call, result in "private" dependent, e.g.:
Let me know if this analysis can produce an incorrect compilation result. |
Thanks, let me take a look at this! |
...rnal/tasks/compile/incremental/compilerapi/constants/ConstantToDependentsMappingBuilder.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Anze Sodja <anze.36@gmail.com>
Oh it needs to rebase
It's part of the |
@blindpirate please avoid rebasing branches when we are collaborating on a branch. Typically I thought I had to merge master into this branch, which I did, but then I realized I couldn't push anymore because you had force pushed this branch. No big deal, but it's easier to rebase only if you're the only collaborator, otherwise just use regular merges. |
The current failure indicates that we can't generate the TC DSL because of the removal of all the performance tests from It would probably be best of @blindpirate took a look at this failure and try to fix it. Or you publish a snapshot from this branch and rebaseline the performance tests on that snapshot before merging. |
@melix sorry for that - I knew I shouldn't but I usually work on my own branch and I was so accustomed to it. Will never happen again. I'm looking into the failures - also I think there might be some corner cases for the bot to handle contributor PRs. If you think this is good to go, I can do my best to make everything pass. |
@blindpirate I'm taking care of this, I'll ping you tomorrow if I need help, get rest, thanks! |
@bot-gradle test RFN |
OK, I've already triggered ReadyForNightly build for you. |
@bot-gradle test RFM |
OK, I've already triggered ReadyForMerge build for you. |
@asodja Finally got this merged, thanks a lot for your efforts! |
Thank you for the help and accepting PR! |
Incremental Java compilation on public constant change
Signed-off-by: Anze Sodja anze.36@gmail.com
Fixes #13493
Fixes #6482
Context
Currently on any change for class with public constant Gradle does full recompilation for Java. This makes incremental compilation with Gradle very tricky, since you have to follow some rules: like no public constant. Even worse, in some cases that is not possible (constants used on annotations).
This PR takes in to account constant changes for incremental builds so full rebuild is not necessary.
It's using Compiler api plugin, similar as class file to name mapping. Currently only constant origins are tracked.
So change to any constant will affect also others. To track all constants separately is possible, but it's expensive, so it might require some tricks. So I did not implement it in this PR.
Slack discussion:
https://gradle-community.slack.com/archives/CA7UM03V3/p1614676803095900?thread_ts=1614009425.009300&cid=CA7UM03V3
Contributor Checklist
<subproject>/src/integTest
) to verify changes from a user perspective<subproject>/src/test
) to verify logic./gradlew sanityCheck
(somejmh
task fails with--release flag not found
, I don't think this is related to my change)./gradlew <changed-subproject>:quickTest
Gradle Core Team Checklist