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

[release 1.8] backport of precompile: serialize the full edges graph (#46920) #47741

Merged
merged 8 commits into from
Dec 14, 2022

Conversation

vtjnash
Copy link
Member

@vtjnash vtjnash commented Nov 29, 2022

Hopefully fixes #47685 (from brief local testing, it seems to)

timholy and others added 8 commits November 29, 2022 16:22
This includes only the changes to `dump.c` for this change, but excludes
the functional part of the change (except for the additional bugfixes
mentioned below).

ORIGINAL COMMIT TEXT:
    This fixes a long-standing issue with how we've handled `invoke` calls
    with respect to method invalidation.  When we load a package, we need
    to ask whether a given MethodInstance would be compiled in the same
    way now (aka, in the user's running session) as when the package was
    precompiled; in practice, the way we do that is to test whether the
    dispatches would be to the same methods in the current
    world-age. `invoke` presents special challenges because it allows the
    coder to deliberately select a different method than the one that
    would be chosen by ordinary dispatch; if there is no record of how
    this choice was made, it can look like it resolves to the wrong method
    and this can trigger invalidation.

    This allows a MethodInstance to store dispatch tuples as well as other
    MethodInstances among their backedges.

Additionally:

- provide backedge-iterators for both C and Julia that abstracts
  the specific storage mechanism.

- fix a bug in the CodeInstance `relocatability` field, where methods
  that only return a constant (and hence store `nothing` for
  `inferred`) were deemed non-relocatable.

- fix a bug in which #43990 should have checked that the method had
  not been deleted. Tests passed formerly simply because we weren't
  caching external CodeInstances that inferred down to a `Const`;
  fixing that exposed the bug.  This bug has been exposed since
  merging #43990 for non-`Const` inference, and would affect Revise
  etc.

Co-authored-by: Jameson Nash <[email protected]>

(cherry picked from commits dd375e1,
cb0721b, 9e39fe9)
SnoopCompile attempts to attribute invalidations to specific causes,
but until now it has not generally been able to handle what it called
"delayed" invalidations, which arose when a MethodInstance backedge
wasn't valid anymore. This dumps more data to the reporting stream
and should allow SnoopCompile to assemble the full chain of causes.

This also adds invalidation of the backedges of methods that fail
to validate their external edges.

(cherry picked from commit b43bc62)
This fixes backedge-based invalidation when a precompiled `invoke`
is followed by loading a package that adds new specializations
for the `invoke`d method. An example is LowRankApprox.jl, where
FillArrays adds a specialization to `unique`.

(cherry picked from commit 698beed)
Previously, we would flatten the edges graph during serialization, to
simplify the deserialization codes, but that now was adding complexity
and confusion and uncertainty to the code paths. Clean that all up, so
that we do not do that. Validation is performed while they are represented
as forward edges, so avoids needing to interact with backedges at all.

This uses the same algorithm now as #46749 for cycle convergence.

(cherry picked from commit fbd5a72)
Co-authored-by: Jameson Nash <[email protected]>
Co-authored-by: Valentin Churavy <[email protected]>
(cherry picked from commit 0daab8a)
@vtjnash vtjnash added backport 1.8 Change should be backported to release-1.8 don't squash Don't squash merge labels Nov 29, 2022
@vtjnash vtjnash requested a review from KristofferC November 30, 2022 19:16
@KristofferC KristofferC mentioned this pull request Dec 14, 2022
26 tasks
@KristofferC KristofferC changed the base branch from release-1.8 to backports-release-1.8 December 14, 2022 08:01
@KristofferC KristofferC merged commit f79b6ea into backports-release-1.8 Dec 14, 2022
@KristofferC KristofferC deleted the jn/backports-release-1.8-47685 branch December 14, 2022 08:01
KristofferC added a commit that referenced this pull request Dec 14, 2022
[release 1.8] backport of precompile: serialize the full edges graph (#46920)
@KristofferC KristofferC removed the backport 1.8 Change should be backported to release-1.8 label Dec 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
don't squash Don't squash merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants