tbroyer / gradle-errorprone-plugin

Gradle plugin to use the error-prone compiler for Java
Apache License 2.0
367 stars 32 forks source link

Gradle Build Cache Misses due to errorProne compileArgumentProvider #101

Open simschla opened 1 month ago

simschla commented 1 month ago

Using the latest 4.0.1 version, we see the following issue regarding our build: On compileJava tasks where errorProne plugin is applied, the calculated cache key for this input differs between developer machines and the CI, leading to cache misses and therefore (unnecessary) task execution.

While investigating these cache misses, the discovered issue seems to be options.compilerArgumentProviders.errorprone$0.errorproneOptions.

Running the gradle command with -Dorg.gradle.caching.debug=true we see the following output (on the exact same code version):

CI

<snip>
Appending input value fingerprint for 'options.compilerArgs' to build cache key: 8222d82255460164427051d7537fa305
Appending input value fingerprint for 'options.compilerArgumentProviders.errorprone$0' to build cache key: 482194bd82177370c0aa4de0611711b1
Appending input value fingerprint for 'options.compilerArgumentProviders.errorprone$0.errorproneOptions' to build cache key: 42061d0c8586e88cfe001e1553e25e02
Appending input value fingerprint for 'options.compilerArgumentProviders.errorprone$0.errorproneOptions.allDisabledChecksAsWarnings' to build cache key: c06857e9ea338f3f3a24bb78f8fbdf6f
Appending input value fingerprint for 'options.compilerArgumentProviders.errorprone$0.errorproneOptions.allErrorsAsWarnings' to build cache key: c06857e9ea338f3f3a24bb78f8fbdf6f
Appending input value fingerprint for 'options.compilerArgumentProviders.errorprone$0.errorproneOptions.checkOptions' to build cache key: cfcc5f871f42c7c797557fd17748dc17
Appending input value fingerprint for 'options.compilerArgumentProviders.errorprone$0.errorproneOptions.checks' to build cache key: 3fb1f830072cc673a4c4d28e1ec08801
Appending input value fingerprint for 'options.compilerArgumentProviders.errorprone$0.errorproneOptions.compilingTestOnlyCode' to build cache key: c06857e9ea338f3f3a24bb78f8fbdf6f
Appending input value fingerprint for 'options.compilerArgumentProviders.errorprone$0.errorproneOptions.disableAllChecks' to build cache key: f6d7ed39fe24031e22d54f3fe65b901c
Appending input value fingerprint for 'options.compilerArgumentProviders.errorprone$0.errorproneOptions.disableAllWarnings' to build cache key: c06857e9ea338f3f3a24bb78f8fbdf6f
Appending input value fingerprint for 'options.compilerArgumentProviders.errorprone$0.errorproneOptions.disableWarningsInGeneratedCode' to build cache key: f6d7ed39fe24031e22d54f3fe65b901c
Appending input value fingerprint for 'options.compilerArgumentProviders.errorprone$0.errorproneOptions.enabled' to build cache key: f6d7ed39fe24031e22d54f3fe65b901c
Appending input value fingerprint for 'options.compilerArgumentProviders.errorprone$0.errorproneOptions.errorproneArgs' to build cache key: 8222d82255460164427051d7537fa305
Appending input value fingerprint for 'options.compilerArgumentProviders.errorprone$0.errorproneOptions.excludedPaths' to build cache key: 13e6fa94b7591e9078168521fc23b783
Appending input value fingerprint for 'options.compilerArgumentProviders.errorprone$0.errorproneOptions.ignoreSuppressionAnnotations' to build cache key: c06857e9ea338f3f3a24bb78f8fbdf6f
Appending input value fingerprint for 'options.compilerArgumentProviders.errorprone$0.errorproneOptions.ignoreUnknownCheckNames' to build cache key: c06857e9ea338f3f3a24bb78f8fbdf6f
<snip>

Local developer machine:

<snip>
Appending input value fingerprint for 'options.compilerArgs' to build cache key: 8222d82255460164427051d7537fa305
Appending input value fingerprint for 'options.compilerArgumentProviders.errorprone$0' to build cache key: 1ec70c21c8cef529e40980bf67375a24
Appending input value fingerprint for 'options.compilerArgumentProviders.errorprone$0.errorproneOptions' to build cache key: d34ccfacb244f1e4266aaa57615fb609
Appending input value fingerprint for 'options.compilerArgumentProviders.errorprone$0.errorproneOptions.allDisabledChecksAsWarnings' to build cache key: c06857e9ea338f3f3a24bb78f8fbdf6f
Appending input value fingerprint for 'options.compilerArgumentProviders.errorprone$0.errorproneOptions.allErrorsAsWarnings' to build cache key: c06857e9ea338f3f3a24bb78f8fbdf6f
Appending input value fingerprint for 'options.compilerArgumentProviders.errorprone$0.errorproneOptions.checkOptions' to build cache key: cfcc5f871f42c7c797557fd17748dc17
Appending input value fingerprint for 'options.compilerArgumentProviders.errorprone$0.errorproneOptions.checks' to build cache key: 3fb1f830072cc673a4c4d28e1ec08801
Appending input value fingerprint for 'options.compilerArgumentProviders.errorprone$0.errorproneOptions.compilingTestOnlyCode' to build cache key: c06857e9ea338f3f3a24bb78f8fbdf6f
Appending input value fingerprint for 'options.compilerArgumentProviders.errorprone$0.errorproneOptions.disableAllChecks' to build cache key: f6d7ed39fe24031e22d54f3fe65b901c
Appending input value fingerprint for 'options.compilerArgumentProviders.errorprone$0.errorproneOptions.disableAllWarnings' to build cache key: c06857e9ea338f3f3a24bb78f8fbdf6f
Appending input value fingerprint for 'options.compilerArgumentProviders.errorprone$0.errorproneOptions.disableWarningsInGeneratedCode' to build cache key: f6d7ed39fe24031e22d54f3fe65b901c
Appending input value fingerprint for 'options.compilerArgumentProviders.errorprone$0.errorproneOptions.enabled' to build cache key: f6d7ed39fe24031e22d54f3fe65b901c
Appending input value fingerprint for 'options.compilerArgumentProviders.errorprone$0.errorproneOptions.errorproneArgs' to build cache key: 8222d82255460164427051d7537fa305
Appending input value fingerprint for 'options.compilerArgumentProviders.errorprone$0.errorproneOptions.excludedPaths' to build cache key: 13e6fa94b7591e9078168521fc23b783
Appending input value fingerprint for 'options.compilerArgumentProviders.errorprone$0.errorproneOptions.ignoreSuppressionAnnotations' to build cache key: c06857e9ea338f3f3a24bb78f8fbdf6f
Appending input value fingerprint for 'options.compilerArgumentProviders.errorprone$0.errorproneOptions.ignoreUnknownCheckNames' to build cache key: c06857e9ea338f3f3a24bb78f8fbdf6f
<snip>

The difference being in these lines:

Appending input value fingerprint for 'options.compilerArgumentProviders.errorprone$0' to build cache key: 1ec70c21c8cef529e40980bf67375a24 //<-- this is 482194bd82177370c0aa4de0611711b1 on CI
Appending input value fingerprint for 'options.compilerArgumentProviders.errorprone$0.errorproneOptions' to build cache key: d34ccfacb244f1e4266aaa57615fb609 //<-- this is 42061d0c8586e88cfe001e1553e25e02 on CI

This must be a regression introduced in 4.0 or 4.0.1 since the issue was not there with 3.1.0 Sorry, no regression, is already present in 2.0.2

Is there an easy way this can be fixed?

tbroyer commented 1 month ago

IIUC, the way Gradle will snapshot that is dependent on the classloaders. Could there be a difference between the machines that could influence that?

Anyway, I'm not sure there's something I can do …until someone (from Gradle ideally) tells me what to do :man_shrugging: I'd suggest debugging the Gradle daemon process if you can to better understand how the cache key is computed (I'd look at DefaultValueSnapshotter, IIUC it should use ImplementationSnapshot) and/or reporting that to Gradle so they can investigate. They're using this plugin as part of smoke tests so might want to see whether this is a bug in Gradle or not; but first make sure environments are equivalent/comparable.