Repository navigation
[pull] master from JuliaLang:master - #2879
Merged
Merged
Conversation
* loading: assign manifest typeasserts so the entry loops do not box
A statement-form typeassert such as `entries::Vector{Any}` refines the
slot type in inference, but slot2ssa only inserts pi nodes at basic-block
entry, so uses in the same block still see the `Any` value and the inlined
`_iterate_abstractarray` boxes a `Tuple{Int}` per iteration. Writing the
assert as an assignment gives the following uses the narrowed type. This
removes ~190k allocations from `using Plots` (manifest lookups for every
dependency) and ~330k from `using DifferentialEquations`.
Assisted-by: Claude Code (Opus 5)
Assisted-by: Codex (gpt-6-astra)
* Compiler: avoid a hash table per CodeInstance in `store_backedges`
`store_backedges` built an `IdDict{Any,Vector{Any}}` for every
CodeInstance to de-duplicate its edges. During package loading that is one
dictionary plus one vector per edge for tens of thousands of code
instances (1.2M of the 2.5M allocations of `using Plots`), although the
median edge list has three backedges and 95% have fewer than 60.
Short edge lists now de-duplicate by rescanning the list, which allocates
nothing. Long lists (above 64 slots) keep plain dispatch edges in an
`IdSet` and `invoke`/`MethodTable` edges keyed by item with their
signature stored bare, since almost every such item is seen with a single
signature. A caller storing many edge lists can pass one `IdSet` to reuse.
Assisted-by: Claude Code (Opus 5)
Assisted-by: Codex (gpt-6-astra)
* Compiler: memoize method lookups and reuse scratch in `verify_call`
Validating the code loaded from a package image calls `verify_call` once
per (caller, callee signature) edge, and most callee signatures appear in
many callers. Each call ran `_methods_by_ftype` afresh, allocating the
result vector, its `MethodMatch`es and their environments, plus three
`RefValue`s, and every `verify_method` allocated a `matches` vector.
The workspace now memoizes the lookup per signature. A cached result is
reused when its validity range covers the query world (the matches are the
same in every world of that range) and the limit matches; the memo is
dropped if the world counter moves between code instances, and is bypassed
while the invalidation debug log is on since that path mutates the result.
The `matches` vector, the `RefValue`s and the list of expected methods live
in the workspace; the latter also stops the interference loop from indexing
the edge `SimpleVector` per interference method, which boxes the index
(there is no inline codegen for `Core._svec_ref`) and was 300k boxed
`Int`s for `using DifferentialEquations`. The workspace also carries the
`IdSet` that `store_backedges` reuses for long edge lists.
Together with the `store_backedges` change this takes `using Plots` from
2.62M allocations / 149 MB to 1.16M / 81 MB and `using
DifferentialEquations` from 6.90M / 453 MB to 2.26M / 216 MB
(`Profile.Allocs` at sample rate 1), most of the reduction inside
`insert_backedges`. Load-time allocation is what shifted the GC pause
placement seen as the TTFX run(cold) regression in #62452.
Assisted-by: Claude Code (Opus 5)
Assisted-by: Codex (gpt-6-astra)
* Compiler: skip backedge de-duplication for restored code known to have none
Every package load de-duplicated the backedges of each restored CodeInstance, although only about
0.3% of backedges are duplicates (`using DataFrames, ForwardDiff`: 4k of 1.19M, nearly all one
MethodInstance targeted by two dispatch groups). Inference already de-duplicates when it first
stores the backedges, so it now records the outcome in a new CodeInstance flag,
`JL_CI_FLAGS_UNIQUE_BACKEDGES`, which package images keep. Restoring a flagged CodeInstance
registers its backedges directly; anything else still takes the checked path.
`using DataFrames` with the GC off goes from 300 ms to 283 ms on macOS (320 ms before this PR).
Assisted-by: Claude Code (Opus 5.5)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.4)
Can you help keep this open source service alive? 💖 Please sponsor : )