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

[Feature]: Improved caching #191

Merged
merged 8 commits into from
May 29, 2024
Merged

[Feature]: Improved caching #191

merged 8 commits into from
May 29, 2024

Conversation

marchermans
Copy link
Contributor

TLDR:

  • Support for caching artifacts of tasks
  • Support for configuration caching
  • Better handling of multiple sibling projects
  • Requires JDK 17 or higher to run

Config Cache support

Due to changes to how we process files (mostly, for now through a method handle to the relevant files) we can create the virtual repository automatically without Gradle getting mad at us for creating files during the config phase.

This solves the major issue and allows most, if not all interactions related to the config cache to fully work.

The support for this is experimental, please open tickets if you run into issues with specific tasks, or other subsystems of NG7 that don't support it yet.

Cache stability

By design we achieve a 3 run cache stability.
This means that the config cache will reuse the configuration data from the 3. run forward, mainly for two reason. Stability less then 2 is not possible natively in gradle. However, we need one extra run because gradle detects that the first run properly filled up the virtual repository with all needed files. Regardless, it will still reuse a lot of the task data, just not the configuration phase data, causing only a minor slow down.

Central task caching

This PR introduces caching for task executions and formalizes a caching procedure for central caching services.

Based on the OS a specific locking mechanism is used:

  • On windows we use its native file locking, which is implemented on OS and FS level, none shared, and exclusive.
  • On none windows, we use PID file based locking, with several recovery techniques to prevent cache busting problems.

Additionally we mark any successful execution of the cache using a healthy marker file, which we track during follow up executions to make sure that the resulting output is actually healthy or not.

Cache id calculation

We use the same algorithm and implementation that gradle does, with some minor changes. First of all we do not cache the classpath, but the task class name, second of all our algorithm caches file inputs seperately, and skips value objects, which are anyway unpacked in the input map anyway. So it would be double caching.

Fixed bugs:

Closes: #187
Closes: #186
Closes: #182

@neoforged-pr-publishing
Copy link

neoforged-pr-publishing bot commented May 28, 2024

  • Publish PR to GitHub Packages

Last commit published: 1a246d5311dc76239f9e04a4b221e233e8ad6eab.

PR Publishing

The artifacts published by this PR:

Repository Declaration

In order to use the artifacts published by the PR, add the following repository to your buildscript:

repositories {
    maven {
        name 'Maven for PR #191' // https://github.com/neoforged/NeoGradle/pull/191
        url 'https://prmaven.neoforged.net/NeoGradle/pr191'
        content {
            includeModule('net.neoforged.gradle', 'mixin')
            includeModule('net.neoforged.gradle', 'common')
            includeModule('net.neoforged.gradle', 'dsl-mixin')
            includeModule('net.neoforged.gradle', 'neoform')
            includeModule('net.neoforged.gradle', 'dsl-platform')
            includeModule('net.neoforged.gradle', 'dsl-common')
            includeModule('net.neoforged.gradle.common', 'net.neoforged.gradle.common.gradle.plugin')
            includeModule('net.neoforged.gradle', 'userdev')
            includeModule('net.neoforged.gradle', 'dsl-userdev')
            includeModule('net.neoforged.gradle.userdev', 'net.neoforged.gradle.userdev.gradle.plugin')
            includeModule('net.neoforged.gradle', 'utils')
            includeModule('net.neoforged.gradle', 'dsl-vanilla')
            includeModule('net.neoforged.gradle', 'vanilla')
            includeModule('net.neoforged.gradle.mixin', 'net.neoforged.gradle.mixin.gradle.plugin')
            includeModule('net.neoforged.gradle.vanilla', 'net.neoforged.gradle.vanilla.gradle.plugin')
            includeModule('net.neoforged.gradle.platform', 'net.neoforged.gradle.platform.gradle.plugin')
            includeModule('net.neoforged.gradle', 'platform')
            includeModule('net.neoforged.gradle.neoform', 'net.neoforged.gradle.neoform.gradle.plugin')
            includeModule('net.neoforged.gradle', 'dsl-neoform')
        }
    }
}

@marchermans marchermans merged commit e8c6d92 into NG_7.0 May 29, 2024
36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant