Skip to content

Backports for 1.12.0-rc1 #58655

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

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

Conversation

KristofferC
Copy link
Member

@KristofferC KristofferC commented Jun 6, 2025

Backported PRs:

Need manual backport:

Contains multiple commits, manual intervention needed:

Non-merged PRs with backport label:

topolarity and others added 15 commits June 5, 2025 17:10
This code was checking for the old edge type (`MethodInstance`) instead
of the new one (`CodeInstance`), causing duplicate non-invoke edges to
accumulate in our `backedges`.

(cherry picked from commit cf875c1)
Since the caller CodeInstance is always part of the identity that we are
de-duplicating on, this makes the linear scan much faster than it is
in `gf.c`

(cherry picked from commit 366a224)
…Table`

These are restored in their entirety by staticdata.jl, so there's no
need to serialize them. Dropping them has the additional advantage of
making it unnecessary to de-duplicate edges in `gf.c`

(cherry picked from commit 5c66152)
On my system, this saves ~500 ms when loading CairoMakie (and all
dependent packages)

(cherry picked from commit bf725f1)
DRY code somewhat by consolidating builtin declarations to use a table
or macro definition to auto-generate the required reflection metadata.
Mostly NFC, but does include a couple bugfixes caused by the consistency
this enforces. Adding a new `Builtin` is now simply a matter of
declaring it in `builtin_proto.h` and defining it in `builtins.c` and
any relevant declarations are handled automatically.

(cherry picked from commit 907b201)
After the bindings change, there is quite a lot of garbage in here now
at runtime (it does not de-duplicate entries added for bindings), so
attempt to do a bit of that during serialization.

Re-landing part of #58078

(cherry picked from commit 3ea60d2)
Instead of hiding the fragments of the method table in each TypeName, make one
variable `Core.GlobalMethods` with access to all methods. The need to split
them early for performance apparently had been long past since kwargs and
constructors were already using a single table and cache anyways. Some new
concepts introduced here:

 - A single Method can now be added to multiple functions. So instead of using
   eval in a for loop, we could define it just once (see example below).
 - Several fields (`max_args`, `name`, and `backedges`) were moved from
   MethodTable to their TypeName.
 - TypeName currently has a (user-modifiable) field called `singletonname`. If
   set to something other than `name`, it may be used for pretty printing of a
   singleton object using its "canonical" (unmangled) name, particularly for
   `function`.
 - `Core.Builtin` method table entries are even more normal now, with valid
   `sig` fields, and special logic to specifically prevent adding methods which
   would become ambiguous with them (as that would violate the tfuncs we have
   for them).
 - `Core.GlobalMethods` is a `Base.Experimental.@MethodTable GlobalMethods`.
 - Each `MethodTable` contains a separate `MethodCache` object for managing
   fast dispatch lookups. We may want to use this for the `Method` field
   containing the `invokes` list so that lookups there get more of the same
   optimizations as global calls.
 - Methods could be put into any number of different MethodTables (or none).
   The `Method.primary_world` field is intended to reflect whether it is
   currently put into the GlobalMethods table, and what world to use in the
   GlobalMethods table for running its generator, and otherwise is meaningless.
 - The lock for TypeName backedges is a single global lock now, in
   `Core.GlobalMethods.mc`.
 - The `backedges` in TypeName are stored on the "top-most" typename in the
   hierarchy, to enable efficient lookup (although we might want to consider
   replacing this entirely with a TypeMap). The "top-most" typename is the
   typename of the type closest to Any, after union-splitting, which doesn't
   have an intersection with Builtin (so Function and Any by implication
   continue to not require scanning for missing backedges since it is not
   permitted to add a Method applicable to all functions).
 - Support for having backedges from experimental method tables was removed
   since it was unsound and had been already replaced with staticdata.jl
   several months ago.
 - Documentation lookup for `IncludeInto` is fixed (previously attached only to
   `Main.include` instead of all `include` functions).

Example: given this existing code in base/operators:

    for op in (:+, :*, :&, :|, :xor, :min, :max, :kron)
        @eval begin
            ($op)(a, b, c, xs...) = (@inline; afoldl($op, ($op)(($op)(a,b),c), xs...))
        end
    end

It could now instead be equivalently written as:

    let ops = Union{typeof(+), typeof(*), typeof(&), typeof(|), typeof(xor), typeof(min), typeof(max), typeof(kron)}
        (op::ops)(a, b, c, xs...) = (@inline; afoldl(op, (op)((op)(a,b),c), xs...))
    end

Fixes #57560

(cherry picked from commit 1735d8f)
Missed updates from early designs in #58131.

Fix #58557

(cherry picked from commit 8ce50a0)
Introduce a new `jl_get_global_value` to do the new world-aware
behavior, while preserving the old behavior for `jl_get_global`. Choose
between `jl_get_global`, `jl_get_global_value`, and
`jl_eval_global_var`, depending on what behavior is required. Also take
this opportunity to fix some data race mistakes introduced by bindings
(relaxed loads of jl_world_counter outside of assert) and lacking type
asserts / unnecessary globals in precompile code.

Fix #58097
Addresses post-review comment
#57213 (comment), so
this is already tested against by existing logic

(cherry picked from commit 965d007)
The A15 was detected as M2; added codenames for easier future updates.

Sources:
- https://asahilinux.org/docs/hw/soc/soc-codenames/#socs
-
https://github.com/apple-oss-distributions/xnu/blob/main/osfmk/arm/cpuid.h
-
https://github.com/llvm/llvm-project/blob/main/llvm/lib/Target/AArch64/AArch64Processors.td#L428

Missing:
- the M4 Pro and Max are missing (because they are missing from Apple's
`cpuid.h`)

Resolves #58278

---------

Co-authored-by: Christian Guinard <[email protected]>
(cherry picked from commit 7cb88d6)
Specifically, content in an `__init__` block is handled by secret
duplicate precompile logic, and any content generated by it was
previously not eligible to be included into cache files.

Fix #58449

(cherry picked from commit 2e158a4)
This makes two changes to the backdate-warning-turned-error (#58266):
1. Fix a bug where the error would only trigger the first time. We do
only want to print once per process, but of course, we do want to error
every time if enabled.
2. If we are in speculative execution context (generators and
speculatively run functions during inference), always use the
UndefVarError. Effects from these functions are not supposed to be
observable, and it's very confusing if the printed warning goes away
when depwarns are enabled. This is marginally more breaking, but the
burden is on generated function authors (which already have to be
world-age aware and are somewhat more regularly broken) and is
consistent with other things that are stronger errors in pure context.

Fixes #58648

(cherry picked from commit d2cc061)
KristofferC and others added 7 commits June 11, 2025 14:22
This dodges the issue on my machine, let's see if it works for everyone.

(cherry picked from commit dda37f9)
It turns out that there are two path types in applescript, and I had mixed two of them in my previous patch.  Annoyingly, things seemed to work when editing locally, unsure why.

(cherry picked from commit c759aa9)
Manage a single dictionary (keyed by TypeName) instead of scattering
this info into each TypeName scattered across the system. This makes it
much easier to scan the whole table when required and to split it up
better, so that all kwcalls and all constructors don't end up stuck into
just one table. While not enormous (or even the largest) just using the
REPL and Pkg, they are clearly larger than intended for a linear scan:

```
julia> length(Type.body.name.backedges)
1024

julia> length(typeof(Core.kwcall).name.backedges)
196

julia> length(typeof(convert).name.backedges)
1510
```

(cherry picked from commit 1c26f43)
When this API was added, this function inlined, which is important,
because the API relies on the allocation of the `Ref` being elided. At
some point (I went back to 1.8) this regressed. For example, it is
currently responsible for substantially all non-Expr allocations in
JuliaParser. Before (parsing all of Base with JuliaParser):
```
│     Memory estimate: 76.93 MiB, allocs estimate: 719922.
```
After:
```
│     Memory estimate: 53.31 MiB, allocs estimate: 156.
```

Also add a test to make sure this doesn't regress again.

(cherry picked from commit d6294ba)
@KristofferC
Copy link
Member Author

Gonna try the packages timing out in isolation

@nanosoldier runtests(["SymbolicIndexingInterface", "OSQP", "SoleBase", "FastCholesky", "EnergySamplers", "JUDI", "GMT", "NeutralLandscapes", "PRASCapacityCredits", "DataToolkitCommon", "WaveOpticsPropagation", "AdmittanceModels", "YAAD", "Quante", "ParaReal", "LaserTypes", "GEOTRACES", "Mango", "Sensemakr", "XCALibre", "ExplainableAI", "SimulationLogs", "GeometricalOptics", "DynamicMovementPrimitives", "DistributedStwdLDA", "DiffusionGarnet", "MultiStateSystems", "vSmartMOM", "WGPUgfx", "MAGEMinApp", "MRINavigator", "CropRootBox", "FSimPlots"], vs = ":release-1.11")

@nanosoldier
Copy link
Collaborator

The package evaluation job you requested has completed - possible new issues were detected.
The full report is available.

Report summary

✖ Packages that failed

19 packages failed only on the current version.

  • Package fails to precompile: 3 packages
  • Illegal method overwrites during precompilation: 1 packages
  • Package has test failures: 3 packages
  • Package tests unexpectedly errored: 1 packages
  • Test duration exceeded the time limit: 11 packages

1 packages failed on the previous version too.

✔ Packages that passed tests

11 packages passed tests on the previous version too.

➖ Packages that were skipped altogether

1 packages were skipped only on the current version.

  • Package could not be installed: 1 packages

1 packages were skipped on the previous version too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.