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

Backports for 1.12 #57444

Open
wants to merge 6 commits into
base: release-1.12
Choose a base branch
from
Open

Backports for 1.12 #57444

wants to merge 6 commits into from

Conversation

…57421)

When loading a pkgimage, the new bpart validation code needs to check if
the export set of any using'd packages differs from what it would have
been during precompile. This could e.g. happen if somebody (or Revise)
eval'd a new `export` statement into a package that was `using`'d.
However, this case is somewhat rare, so let's optimize it by keeping a
bit in `Module` that keeps track of whether anything like that has
happened and if not skipping the revalidation. This slightly improves
pkgimage load time in the ordinary case. More optimizations to follow.

(cherry picked from commit 39255d4)
@KristofferC KristofferC added the release Release management and versioning. label Feb 17, 2025
Keno added 4 commits February 17, 2025 19:36
This addresses post-commit review
#57230 (comment).
This change was left-over from before I decided to also change the type
of the `source` argument (at which point `source.module` was unavailable
in the function). This module was supposed to be the same, but it turns
out that both the julia tests and several packages use this code
manually and use different modules for the two places. Use the same one
we used before (which is probably more correct anyway) to fix #57417

(cherry picked from commit 0c5372f)
)

This applies the existing prohibition against introducing new bindings
in a closed module to binding replacement as well (for the same reason -
the change won't be persisted after reload). It is pretty hard to even
reach this point, since `eval` into closed modules is already prohibited
and there's no surface syntax for cross-module declaration, but it is
technically reachable from lowered IR. Further, in the future we may
make all of these builtins, which would make it easier. Thus, be
consistent now and fully disallow binding replacement in closed modules
during precompile.

(cherry picked from commit 56aed62)
…57426)

An upcoming optimization will skip most binding validation if no binding
replacement has taken place in (sysimage, pkgimage) modules. However, as
a special case, we would like to treat `Main` as a non-sysimage module
because the addition of new bindings in `Main` is common and we would
like this to not ruin the optimization. To make this legal, we have to
prohibit `import`ing or `using` any `Main` bindings in pkgimages. I
don't think anybody actually does this, particularly, since `Main` is
not considered loading during precompile (so you have to use the main
binding via (Core|Base|).Main), and I can't think of any good semantic
reason to want to do this, but regardless, it does add additional
restrictions to `using`/`import`, so I wanted to break it out into its
own PR.

(cherry picked from commit 726c816)
…dules (#57433)

This implements the optimization proposed in #57426 by keeping track of
whether any bindings were replaced in image modules (excluding `Main` as
facilitated by #57426). In addition, we augment serialization to keep
track of whether a method body contains any GlobalRefs that point to a
loaded (system or package) image. If both of these flags are true, we
can skip scanning the body of the method, since we know that we neither
need to add any additional backedges nor were any of the referenced
bindings invalidated. The performance impact on end-to-end load time is
small, but measurable. Overall `@time using ModelingToolkit`
consistently improves about 5% using this PR. However, I should note
that using time is still about 40% slower than 1.11. This is not
necessarily an Apples-to-Apples comparison as there were substantial
other changes on 1.12 (as well as current load-time-tunings targeting
older versions), but I wanted to put the number context.

(cherry picked from commit f6e2b98)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release Release management and versioning.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants