Skip to content
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

runDatagen task dependent on random variable, invalidating caching #1135

Closed
Ampflower opened this issue Jun 25, 2024 · 0 comments · Fixed by #1226
Closed

runDatagen task dependent on random variable, invalidating caching #1135

Ampflower opened this issue Jun 25, 2024 · 0 comments · Fixed by #1226

Comments

@Ampflower
Copy link

Within the runDatagen task, a task expected to be able to be cached, there's the /tmp/loom-classpath<rng.long>.args within the jvmArgs field, which due to its random nature, practically invalidates the cache.

Expected Results

Gradle to be able to not need to run the datagen task after the first or second time.

Actual Results

Gradle can't not run the datagen task due to the mentioned argument above.

Possible Fix

Replace the Files.createTempFile with a custom call, creating a hash depending on the running user and the to-be file contents.

It maybe considered to then hold a write/delete lock to prevent competing Looms causing problems, letting only the last one releasing the lock to delete it, not that I expect there to be a case of this happening under normal conditions.

Other

try {
final Path argsFile = Files.createTempFile("loom-classpath", ".args");
Files.writeString(argsFile, content, StandardCharsets.UTF_8);
args.add("@" + argsFile.toAbsolutePath());
} catch (IOException e) {
throw new UncheckedIOException("Failed to create classpath file", e);
}

One thing to keep in mind is we wouldn't want to start skipping the normal run game tasks if their inputs havent changed
It is possible to tell Gradle that the task is not cacheable with Task.notCompatibleWithConfigurationCache(String), which would be applicable to the runClient and runServer tasks.

To accommodate it, the run configs should default to not compatible for the reason of "Application/Game Runner", with the datagen run defaulting to cacheable. It may be ideal to allow new run configs to be declared as cacheable if the dev needs it to be.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants