This message was deleted.
# configuration-cache
s
This message was deleted.
🧠 1
m
The idea, which seems to work pretty well, is to benefit from the ability of the configuration cache to run tasks in parallel
it works well except for one thing: if I move a class to another (new) package and run
check
or
test
, the configuration cache is reused, so the task graph is the same, but it shouldn't
I'm not sure if it can be detected as an error, but obviously no error is thrown, and the issue is that tests wouldn't be executed if the cache is reused. How can I explain that to the configuration cache?
v
Not an answer actually, but did you consider using Spocks ability to run tests in parallel instead?
m
but did you consider using Spocks ability to run tests in parallel instead?
Yes, but that's not the same. AFAIK Spock would run in-process, vs out of process. This could cause potential issues with shared state. Also I would benefit from individual caching of tests and predictive test selection with my technique. But the drawback is that it is also more resource intensitve.
a
interesting idea, I like the sound of it. I've wondered before if tests could be improved by more tightly integrating with Gradle tasks. The easiest workaround that I can think of is to opt-out of CC for those custom tasks https://docs.gradle.org/current/userguide/configuration_cache.html#config_cache:task_opt_out. I presume the tasks will still run in parallel... For a more 'correct' implementation, but complicated: Use incremental task inputs to get the packages, and for each added/modified package launch the tests in parallel via the Worker API.
v
AFAIK Spock would run in-process, vs out of process.
That's correct.
This could cause potential issues with shared state.
Of course the tests have to properly support it, yes, or define that they need a specific resource.
Also I would benefit from individual caching of tests
Yeah, that's true of course
and predictive test selection with my technique.
I'm curious, as I'm not working with GE, why does your technique benefit from it and just using Spock parallel support not? Afair it selects individual tests from the whole test suite, not only specific test tasks.
But the drawback is that it is also more resource intensitve.
And more complex to setup and so far not CC compatible. 😄
For a more 'correct' implementation, but complicated: Use incremental task inputs to get the packages, and for each added/modified package launch the tests in parallel via the Worker API.
But that would then not integrate with test reporting, would it? Unless maybe you use internal Gradle API to somehow forward it.
m
let's keep this thread on the original topic 🙂
v
Yeah, right, sorry for the little side-question
p
It looks like calls to traverse directories are not properly captured as configuration inputs. There have been lots of progress on this in 8.1, it might be worth trying it out and reporting issues if need be.
w
The idea, which seems to work pretty well, is to benefit from the ability of the configuration cache to run tasks in parallel
Gradle already runs tests in parallel on different JVMs. What is the advantage of using separate tasks per package?
m
I have complete control on what runs in parallel, and each test task can be cached independently, which is not the case with internal parallel forking
t looks like calls to traverse directories are not properly captured as configuration inputs. There have been lots of progress on this in 8.1, it might be worth trying it out and reporting issues if need be.
mmm, right, but is there a way I can declare the inputs to configuration manually?
v
If nothing else, maybe write your traversal out to a file and read it using
TextResource#fileContent
?
m
indeed this works... not great but it works
actually no, because I have to delete the file in between builds, and even if I regenerate the file with the same contents Gradle thinks it has changed
going to try with my own
ValueSource
👍 1
that works!
👌 1
m
A bit late to the party... As Paul said, Gradle 8.1 will have input detection for directory and file collection traversals, but in this case a custom
ValueSource
seems more fitting anyway - it looks like adding a file to an existing directory should not invalidate the configuration, and this is something you won't get with just
listdir
- Gradle has no way of knowing what you're going to do with the listing, so all directory's contents become part of the cache fingerprint. The
ValueSource
only invalidates the cache if its output changes, so you have a chance to ignore irrelevant differences.
a way I can declare the inputs to configuration manually?
ValueSource
is the recommended way to do that.
👍 3