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

Do not canonicalize path of persistent cache #29201

Merged
merged 2 commits into from
May 17, 2024

Conversation

lptr
Copy link
Member

@lptr lptr commented May 17, 2024

This is consolidate how the location of the directory is handled between a PersistentCache and a SingleDepthFileAccessTracker. Before the change only the cache factory would canonicalize the location, and this could lead to the access tracker trying to track files under a different path. Now they both use the same path, and callers can decide whether they want to canonicalize or not.

Reviewing cheatsheet

Before merging the PR, comments starting with

  • ❌ ❓must be fixed
  • 🤔 💅 should be fixed
  • 💭 may be fixed
  • 🎉 celebrate happy things

This is consolidate how the location of the directory is handled between a PersistentCache and a SingleDepthFileAccessTracker.
@lptr lptr added the in:execution-engine incremental, up-to-date, overlapping outputs label May 17, 2024
@lptr lptr added this to the 8.9 RC1 milestone May 17, 2024
@lptr lptr self-assigned this May 17, 2024
@lptr lptr requested a review from a team as a code owner May 17, 2024 14:21
@lptr
Copy link
Member Author

lptr commented May 17, 2024

@bot-gradle test QF please.

@bot-gradle
Copy link
Collaborator

I've triggered the following builds for you. Click here to see all build failures.

throw new UncheckedIOException(e);
}
DirCacheReference dirCacheReference = dirCaches.get(canonicalDir);
DirCacheReference dirCacheReference = dirCaches.get(cacheDir);
Copy link
Member

@asodja asodja May 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❓ Woudn't that make it a bit more fragile depending on how File path is constructed?

Since for example:

new File("./cache").equals(new File("cache")); // returns false
new File("./cache").getCanonicalFile().equals(new File("cache").getCanonicalFile()); // returns true

So dirCaches.get(canonicalDir) could return different results.

Copy link
Member

@asodja asodja May 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if that is a problem in practice though for this part of code

Copy link
Member Author

@lptr lptr May 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The canincalization was added in 2009, I don't think it matters. User code does not create these caches, so we control all creation. So if tests pass, I think we should be okay.

For the directory build cache there isn't any change either: we've been canonicalizing the directory build cache's location already, that's why it didn't cause any trouble (Maven didn't, that's how we found the discrepancy).

In theory, we could canonicalize everywhere where we resolve a location, but that'd be defensive coding.

@lptr lptr requested a review from welandaz May 17, 2024 15:55
@lptr lptr added this pull request to the merge queue May 17, 2024
@lptr
Copy link
Member Author

lptr commented May 17, 2024

Tests pass so I triggered the merge. Let me know if you think we should reconsider.

Copy link
Member

@asodja asodja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Merged via the queue into master with commit 71570e9 May 17, 2024
26 checks passed
@lptr lptr deleted the lptr/persistent-cache/do-not-canonicalize-path branch May 17, 2024 20:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in:execution-engine incremental, up-to-date, overlapping outputs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants