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

Allow include() and include_dependency() files to resolve to different depots #52750

Merged
merged 6 commits into from
Jan 8, 2024

Conversation

fatteneder
Copy link
Member

@fatteneder fatteneder commented Jan 4, 2024

Fixes #52161

#52161 is an awkward use of the relocation feature in the sense that it attempts to load the include() and include_dependency files of a pkg from two separate depots.
The problem there is that the value with which we replace the @depot tag for both include() and include_dependency() files is determined by trying to relocate only the include() files. We then end up not finding the include_dependency() files.

Solution:
@staticfloat noted that the pkg slugs in depot paths like @depot/packages/Foo/1a2b3c/src/Foo.jl are already enough to (weakly) content-address a depot.
This means that we should be able to load any include() file of a pkg from any depot that contains a precompile cache, provided the hashes match.
The same logic can be extended to include_dependency() files, which this PR does.

Note that we continue to use only one file from the include() files to determine the depot which we use to relocate all include() files. [this behavior is kept from master]
But for include_dependency() files we allow each file to resolve to a different depot. This way the MWE given in #52161 should be extendable to two README files being located in two different pkgs that lie in two different depots.


Side note: #49866 started with explicitly verifying that all include() files come from the same depot. In #52346 this was already relaxed to pick the first depot for which any include() file can be resolved to. This works, because if any other file might be missing from that depot then this is caught in stalecache().

@fatteneder fatteneder added compiler:precompilation Precompilation of modules needs tests Unit tests are required for this change labels Jan 4, 2024
Copy link
Member

@staticfloat staticfloat left a comment

Choose a reason for hiding this comment

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

LGTM! Also, can confirm this fixes the constant precompilation issue referenced in #52161 (comment)

@staticfloat
Copy link
Member

Looks like some tests might need some adjustment though: https://buildkite.com/julialang/julia-master/builds/31836#018cd6aa-caa1-4e75-aa48-3eea5e857605/802-1575

@fatteneder fatteneder force-pushed the fa/incldeps-depot-search branch 2 times, most recently from eba00a2 to 860596a Compare January 6, 2024 13:50
@fatteneder fatteneder removed the needs tests Unit tests are required for this change label Jan 6, 2024
@staticfloat
Copy link
Member

x86_64-apple-darwin failure should be fixed by #52782, but I don't understand why it only appears on that platform.

Allow include() and include_dependency() files to resolve to different
depots. We use one and the same depot for all include() files, but
include_dependency() files can each resolve to a different depot.

Co-authored-by: staticfloat [email protected]
@staticfloat
Copy link
Member

Windows failures look real.

@DilumAluthge DilumAluthge requested review from vchuravy and removed request for vchuravy January 7, 2024 18:25
@fatteneder
Copy link
Member Author

I could not spot an obvious problem with the test.
My theory is that its related to these warnings

From worker 9:	┌ Warning: RelocationTestPkg1 [854e1adb-5a97-46bf-a391-1cfe05ac726d] is already loaded from a different path:
      From worker 9:	│   loaded:    v0.1.0 "C:\\buildkite-agent\\builds\\win2k22-amdci6-5\\julialang\\julia-master\\julia-edb66b8b14\\share\\julia\\test\\RelocationTestPkg1\\src\\RelocationTestPkg1.jl"

so I updated the test to work with temporarily generated example pkgs to avoid that.

loading of already loaded pkg

fixup version tag; use open() instead of write()
@staticfloat staticfloat merged commit 55113b5 into JuliaLang:master Jan 8, 2024
5 of 7 checks passed
Comment on lines +155 to +156
@show srcfile1
@show srcfile2
Copy link
Contributor

Choose a reason for hiding this comment

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

Are these @show's necessary? They're spamming all tests.

Copy link
Member Author

Choose a reason for hiding this comment

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

Are these @show's necessary?

No.

@fatteneder fatteneder deleted the fa/incldeps-depot-search branch January 18, 2024 17:14
KristofferC pushed a commit that referenced this pull request Jan 20, 2024
fatteneder added a commit that referenced this pull request Apr 2, 2024
…files (#53905)

Fixes
#53859 (comment),
which was actually fixed before in
#52346, but
#52750 undid that fix.

This PR does not directly address #53859, because I can not reproduce it
atm.

---

The `@depot` resolution logic for `include()` files is adjusted as
follows:

1. (new behavior) If the cache is not relocatable because of an absolute
path, we ignore that path for the depot search. Recompilation will be
triggered by `stale_cachefile()` if that absolute path does not exist.
Previously this caused any `@depot` tags to be not resolved and so
trigger recompilation.
2. (new behavior) If we can't find a depot for a relocatable path, we
still replace it with the depot we found from other files. Recompilation
will be triggered by `stale_cachefile()` because the resolved path does
not exist.
3. (this behavior is kept) We require that relocatable paths all resolve
to the same depot.
4. (new behavior) We no longer use the first matching depot for
replacement, but instead we explicitly check that all resolve to the
same depot. This has two reasons:
- We want to scan all source files anyways in order to provide logs for
1. and 2. above, so the check is free.
- It is possible that a depot might be missing source files. Assume that
we have two depots on `DEPOT_PATH`, `depot_complete` and
`depot_incomplete`.
If `DEPOT_PATH=["depot_complete","depot_incomplete"]` then no
recompilation shall happen, because `depot_complete` will be picked.
If `DEPOT_PATH=["depot_incomplete","depot_complete"]` we trigger
recompilation and hopefully a meaningful error about missing files is
thrown. If we were to just select the first depot we find, then whether
recompilation happens would depend on whether the first relocatable file
resolves to `depot_complete` or `depot_incomplete`.
KristofferC pushed a commit that referenced this pull request Apr 9, 2024
…files (#53905)

Fixes
#53859 (comment),
which was actually fixed before in
#52346, but
#52750 undid that fix.

This PR does not directly address #53859, because I can not reproduce it
atm.

---

The `@depot` resolution logic for `include()` files is adjusted as
follows:

1. (new behavior) If the cache is not relocatable because of an absolute
path, we ignore that path for the depot search. Recompilation will be
triggered by `stale_cachefile()` if that absolute path does not exist.
Previously this caused any `@depot` tags to be not resolved and so
trigger recompilation.
2. (new behavior) If we can't find a depot for a relocatable path, we
still replace it with the depot we found from other files. Recompilation
will be triggered by `stale_cachefile()` because the resolved path does
not exist.
3. (this behavior is kept) We require that relocatable paths all resolve
to the same depot.
4. (new behavior) We no longer use the first matching depot for
replacement, but instead we explicitly check that all resolve to the
same depot. This has two reasons:
- We want to scan all source files anyways in order to provide logs for
1. and 2. above, so the check is free.
- It is possible that a depot might be missing source files. Assume that
we have two depots on `DEPOT_PATH`, `depot_complete` and
`depot_incomplete`.
If `DEPOT_PATH=["depot_complete","depot_incomplete"]` then no
recompilation shall happen, because `depot_complete` will be picked.
If `DEPOT_PATH=["depot_incomplete","depot_complete"]` we trigger
recompilation and hopefully a meaningful error about missing files is
thrown. If we were to just select the first depot we find, then whether
recompilation happens would depend on whether the first relocatable file
resolves to `depot_complete` or `depot_incomplete`.

(cherry picked from commit d8d3842)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler:precompilation Precompilation of modules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

include_dependency files that are in a different depot from the package are not found during loading
3 participants