https://github.com/JuliaLang/julia

sort by:
Revision Author Date Message Commit Date
ae3bf27 Add tomlcc to loader 15 June 2023, 10:30:51 UTC
f8827f1 Structured display for adjoint/transpose (#49979) * Structured display for adjoint/transpose * structured display for Symmetric/Hermitian * tests with Symmetric and Transpose 09 June 2023, 14:46:41 UTC
2584b59 Fill zeros only if necessary in `Matrix(::Diagonal)` and friends (#50008) * delay filling zeros while convering (sym)tridiag to matrix * conditional zero fill for bidiagonal/diagonal 09 June 2023, 13:17:47 UTC
43d7f88 effects: audit `EFFECTS_UNKNOWN` usages (#50106) 09 June 2023, 04:28:41 UTC
d041162 Update mailmap (#50116) 09 June 2023, 01:42:26 UTC
7ceea13 Update Unicode.jl (#50087) Correct confusing typo in documentation 09 June 2023, 01:39:18 UTC
746a15b Fail gracefully when attempting pair destructuring (#49368) `a => b = x` was interpreted as a function definition. Now it's an error unless you `import Base: =>` 08 June 2023, 21:52:57 UTC
c4d162e mkpidlock: clarify that stale_age is given in seconds (#50014) 08 June 2023, 15:55:41 UTC
0a2d6fc Don't use exchange in the hot path of the GC (#50021) * Don't use exchange in the hot path of the GC and save one extra load 08 June 2023, 15:28:34 UTC
2c80455 Revert "allow artifact string macro to take an explicit path to the artifact file (#46755)" (#50036) This reverts commit 1720a54011f7520f30ae69088e5c1b6f9643b35e. 08 June 2023, 14:54:42 UTC
4200aa9 Unify and split the pass pipeline (#49798) Unify and split the pass pipeline 07 June 2023, 21:15:19 UTC
2e76fc4 Update return type in collect(::Dict) docs (#50056) 07 June 2023, 19:27:36 UTC
1f174a6 Fix typo in CONTRIBUTING.md (#50104) 07 June 2023, 19:14:20 UTC
d7d7ffa Invoke the passbuilder's extension point callbacks when possible (#50095) Invoke the passbuilder's extension point callbacks when possible 07 June 2023, 16:46:41 UTC
13e40af Skip flakey tests in CI (#50071) 07 June 2023, 14:01:12 UTC
36c5953 More `hash` optimization (#50041) * speed up hash of Float32/Float16 since they never are big numbers, and hash of arbitrary real types by not hashing the denominator when it is one 07 June 2023, 13:26:17 UTC
dbd82a4 Update newpm pass pipeline (#49747) Co-authored-by: Gabriel Baraldi <baraldigabriel@gmail.com> 07 June 2023, 04:40:07 UTC
0b47546 array: make `DimensionMismatch` lazy-string friendly (#50079) At the moment, the `msg` field of `DimensionMismatch` is typed as `String`. This means lazy strings passed to `DimensionMismatch` are instantly instantiated, defeating the whole purpose of using `LazyString`. This commit tweaks the field type to `AbstractString`. This way, lazy strings get instantiated during the exception handling later on. 07 June 2023, 01:04:05 UTC
e111c01 add default order for atomics to docstring (#50086) 06 June 2023, 23:34:53 UTC
bbbe8c3 missing: improve effects for some missing operations (#50080) 06 June 2023, 22:08:30 UTC
c3ea5dc fix `hash(::BigInt)` on 32 bit systems (#50076) * don't define hash(::BigInt) on 32 bit systems 06 June 2023, 17:26:20 UTC
4d2f35e Update URL for "lexical scoping" (#50085) 06 June 2023, 16:23:45 UTC
53bcb39 Fixup `hash(::Real)` broken by #49996 (#50067) * fixup for 49996 and add test from 50065 --------- Co-authored-by: Lilith Hafner <Lilith.Hafner@gmail.com> 06 June 2023, 13:25:00 UTC
1bb3d26 🤖 [master] Bump the Pkg stdlib from 9c01707a2 to 4de1826bc (#50078) 06 June 2023, 11:39:36 UTC
112554e [test] Automatically install `llvm-tools` when runnning `llvmpasses` (#49985) 06 June 2023, 00:01:44 UTC
c16891d Atomic pointer operations APIs (#49811) This provides and interface to `Intrinsics.atomic_pointerref` and `Intrinsics.atomic_pointerset` through `unsafe_load` and `unsafe_store!`. Added the following atomic pointer operations: unsafe_modify! unsafe_replace! unsafe_swap! elsize(::Type{<:Ptr}) Tests previously using the explicit intrinsic method here are replaced by the new user facing variants. Add notes about atomic implementation and refs to relevant field and property method docs. Move general atomic doc strings to kw doc and ref in multi-threading. Co-authored-by: Jameson Nash <vtjnash@gmail.com> Co-authored-by: Sukera <11753998+Seelengrab@users.noreply.github.com> 05 June 2023, 23:20:47 UTC
32e2986 Add LLVMExtra stubs for newpm (#50042) 05 June 2023, 22:44:49 UTC
3051f47 Use xchg to swap boxed values (#45147) * Use xchg to swap boxed values * Update src/cgutils.cpp Co-authored-by: Valentin Churavy <vchuravy@users.noreply.github.com> * Update src/cgutils.cpp Co-authored-by: Valentin Churavy <vchuravy@users.noreply.github.com> --------- Co-authored-by: Jameson Nash <vtjnash@gmail.com> Co-authored-by: Valentin Churavy <vchuravy@users.noreply.github.com> 05 June 2023, 18:29:23 UTC
270a1d8 Docs: simple docstring for `write(filename::AbstractString, x)` (#49835) * Docs: simple docstring for `write(filename::AbstractString, x)` * use `content` instead of `x` * Update base/io.jl Co-authored-by: Jameson Nash <vtjnash@gmail.com> * Update base/io.jl --------- Co-authored-by: Jameson Nash <vtjnash@gmail.com> 05 June 2023, 18:26:51 UTC
3c29942 Remove printlns from test/atexit.jl (#50066) 05 June 2023, 17:18:44 UTC
f407a4c inlining: allow callsite inlining with cached results (#50048) In some rare cases with callsite inlining, we try to inline an inferred result from a local cache (`inf_result::InferenceResult`), whose source has been transformed by `transform_result_for_cache`. At present, `inf_result.src` stays to be `OptimizationState` in such cases, causing `inlining_policy` to handle the callsite inlining. This commit adjusts `transform_result_for_cache` so that it stores the transformed source in `inf_result.src`, letting the callsite inliner use it. Down the line, we might revisit this change to align it with 532125d51d23f22c3fd117fe8a37c158fe16ac62, which isn't enabled yet. 04 June 2023, 03:20:02 UTC
ff23b37 add docs on task migration (#50047) 04 June 2023, 01:27:33 UTC
0c774c7 fix empty string error in Printf (#50011) * fix empty string error in Printf * Update runtests.jl * Update runtests.jl 03 June 2023, 05:13:14 UTC
c3d70e8 Update Printf.jl reference link (#50029) The old link described %g inaccurately. The new one is better (tho it mentions %n, which we don't support). 03 June 2023, 05:02:18 UTC
f4a264a Rename LLVM passes to be suffixed with Pass (#50043) 02 June 2023, 23:31:22 UTC
1961019 Optimize top_set_bit(::BigInt) and hash(::Real) (#49996) * implement top_set_bit in Julia for increased performance * simplify and optimize hash(::Real) --------- Co-authored-by: Lilith Hafner <Lilith.Hafner@gmail.com> 02 June 2023, 14:45:38 UTC
f09e46d add Compiler diagram (#49893) This is inspired by the diagram presented by Lionel Zoubritzky in his 2018 JuliaCon talk. This gives a visual overview of what is happening in the compiler. 02 June 2023, 13:27:26 UTC
0efb7c5 add docs for `Base.shred!` (#50032) It was mentioned in `Base.SecretBuffer`. 02 June 2023, 13:26:41 UTC
be2c35a mention `Cmd(::Vector{String})` in `Cmd` docstring (#49684) * mention `Cmd(::Vector{String})` in `Cmd` docstring This seems like a cyclical definition without it, and naively `Cmd` and `String` seem on the surface to be similar so it can be surprising that `Cmd("a string")` does not work. Adding this signature in the docstring should obviate the issues for first time users that read the docstring without having reviewed the manual. We also clarify the behavior of `exec` and command literals. --------- Co-authored-by: Steven G. Johnson <stevenj@mit.edu> 02 June 2023, 13:26:11 UTC
a35e53d Merge pull request #49901 from topolarity/julia-side-timing Allocate timing counts on-the-fly + support dynamic events 02 June 2023, 03:25:46 UTC
3c915f3 Sort jl_timing counts events before printing 01 June 2023, 19:38:42 UTC
3b90d5e Use `jl_timing_set_enable` instead of `DISABLE_SUBSYSTEM` 01 June 2023, 19:38:41 UTC
5850227 Add timing event locks + de-duplicate ITTAPI events 01 June 2023, 19:37:48 UTC
cb0537f timing: Allocate all timing events dynamically This paves the way for a Julia-side API that can create new events on-the-fly without having to modify timing.h The core of the change is to introduce two different structs: - An "event" stores all of the statically-determined attributes of a profiler event (typically, zone name and source location info) - A "timing block" stores the dynamic information relevant to a particular span/measurement in the timing run Events and timing blocks have a one-to-many relationship. The intended pattern for a Julia-side API is to construct an event once at parse-time using `jl_timing_event_create` (since this is relatively expensive due to profiler traffic and allocations) and then to create its own timing block on-the-fly for each block entry/exit. This also re-factors the API a bit to hopefully be more consistently named 01 June 2023, 19:37:46 UTC
f61bbfb Some mailmap updates (#49997) 01 June 2023, 12:45:04 UTC
e0761b3 inlining: some refactoring on the inlining code (#50016) - clean up the edge tracking: * removed `valid_worlds` tracking since it is never updated * removed `EdgeTracker` object and make `InliningEdgeTracker` update inlining edges always - clean up dead `OptimizationParams` arguments 01 June 2023, 04:37:51 UTC
304e9a0 Add GC metric `last_full_sweep` (#50018) Records the time that the last full sweep ran. 31 May 2023, 20:16:01 UTC
e4cf096 Merge pull request #50010 from JuliaLang/kc/profiling_changes Minor tweaks to the runtime profiling 31 May 2023, 18:50:46 UTC
28630ee Merge pull request #50002 from topolarity/clangsa-gcc-error Makefile: Use Clang CFLAGS when running `analyzegc` 31 May 2023, 18:39:13 UTC
dd44113 add `@inline` annotation to `Core.Compiler.specialize_method` (#50015) Since the return type of `Core.Compiler.specialize_method` relies on the boolean keyword argument `preexisting`, it is profitable to constant propagate it to get better inferrability. 31 May 2023, 17:25:03 UTC
9b27a8f errorshow: simplify printing of keyword argument types using a new macro format (#49959) In Julia, keyword arguments are represented as `Base.Pairs` objects. However, the object type often appears unnecessarily complex, especially when printed in a stack trace. This commit aims to simplify the printing of stack traces that involve keyword method calls, while still allowing us to reconstruct the actual method signature types from the printed signature types. The approach is similar to #49117: this commit introduces a new macro called `Base.@Kwargs`. It follows the same syntax as `@NamedTuple` and returns a `Base.Pairs` type that is used for keyword method calls. We use this syntax when printing keyword argument types. Here's an example of a stack trace: ```diff diff --git a/b.jl b/a.jl index 91dd6f0464..b804ae4be5 100644 --- a/b.jl +++ b/a.jl @@ -22,12 +22,11 @@ Stacktrace: @ Base ./reduce.jl:44 [inlined] [6] mapfoldl(f::typeof(identity), op::typeof(Base.add_sum), itr::String; init::Int64) @ Base ./reduce.jl:175 [inlined] - [7] mapreduce(f::typeof(identity), op::typeof(Base.add_sum), itr::String; kw::Base.Pairs{…}) + [7] mapreduce(f::typeof(identity), op::typeof(Base.add_sum), itr::String; kw::@Kwargs{init::Int64}) @ Base ./reduce.jl:307 [inlined] - [8] sum(f::typeof(identity), a::String; kw::Base.Pairs{Symbol, Int64, Tuple{Symbol}, @NamedTuple{init::Int64}}) + [8] sum(f::typeof(identity), a::String; kw::@Kwargs{init::Int64}) @ Base ./reduce.jl:535 [inlined] - [9] sum(a::String; kw::Base.Pairs{Symbol, Int64, Tuple{Symbol}, @NamedTuple{init::Int64}}) + [9] sum(a::String; kw::@Kwargs{init::Int64}) @ Base ./reduce.jl:564 [inlined] [10] top-level scope ``` --- * RFC: errorshow: simplify printing of keyword argument types using a new macro format * export and document `Base.@Kwargs` and further simplify the stack trace view * use the `@Kwargs` syntax only when printing kwmethod signature within stack trace view And add tests. * add news entry * more type stability * Apply suggestions from code review * enable the type-repr simplification unconditionally in the stack trace Since keyword pairs can appear within positional arguments, it can be confusing if we print the same type with different representations. * omit type annotation for splat keyword argument * add test for `@Kwargs` * clean up test/errorshow.jl 31 May 2023, 15:49:36 UTC
d3d09c1 add a timing zone for `call_require` (#49723) 31 May 2023, 14:04:41 UTC
d5145de fix and test sorting arrays with >1 dimension and custom `similar` (#49392) * fix and test sorting arrays with >1 dimension and custom `similar` * add PR number --------- Co-authored-by: Lilith Hafner <Lilith.Hafner@gmail.com> 31 May 2023, 13:44:55 UTC
faca5bd disable `TYPE_CACHE_INSERT` profile zone by default This one tend to be very fast, produce many entries and it tends to be not very interesting in most cases 31 May 2023, 11:16:15 UTC
b050ca9 only add an entry for `METHOD_MATCH` if it does some work 31 May 2023, 11:16:15 UTC
da98f54 move `jl_timing_apply_env` to a later place where it uses initialized data Also, move it after `DISABLE_SUBSYSTEM` to avoid it clobbering the results. 31 May 2023, 11:15:40 UTC
ca3270b lowering: apply let hygiene in let environment (#49999) Not just a regression, since this test also fails on old versions, but #49897 applied the wrong environment to make this hygiene correct which broke it worse. Fix #49984 31 May 2023, 09:33:03 UTC
7e25ebf 🤖 [master] Bump the Pkg stdlib from daf02a458 to 9c01707a2 (#50005) * 🤖 [master] Bump the Pkg stdlib from daf02a458 to 9c01707a2 * remove Pkg.LazilyInitializedFields from docs --------- Co-authored-by: Dilum Aluthge <dilum@aluthge.com> Co-authored-by: Ian <i.r.butterworth@gmail.com> 31 May 2023, 09:32:18 UTC
c3a08fe Makefile: For gcanalyze, use Clang's CFLAGS not GCC's It's supported to build the analysis plugin with GCC, but the flags we actually run it with need to match Clang. 31 May 2023, 02:47:09 UTC
84bf67c Support sorting iterators (#46104) * widen sort's type signature * throw on AbstractString * Throw on infinite iterator * make sort(::NTuple) return a tuple (use vector internally for sorting for large tuples) 30 May 2023, 19:55:28 UTC
d912d85 doc: simple docstring for `read(filename::AbstractString)` (#49836) 30 May 2023, 19:32:58 UTC
318f0ea docs: first describe simple `read` and `write` without streaming (#49834) 30 May 2023, 19:29:25 UTC
c63feee show: fix printing of "function (x...) end" (#49874) Previously, the parentheses were missing. 30 May 2023, 19:25:24 UTC
bd5e6da fix atomic intrinsics implementation issues (#49967) * jltypes: add missing GC root for cmpswap_type Tuple. This is called with a fieldtype, which might not even be a DataType. * support Ptr{Union{}} and Ptr{Cvoid} better 30 May 2023, 19:11:00 UTC
f6f637a cleanup: some fixes from effort to break up monolithic sysimg build (#49953) From #38119 30 May 2023, 19:09:40 UTC
20752db thread safety: lock around atexit_hooks global (#49868) Ensure the lock is precise, so that we are allowed to register new atexit hooks from inside an atexit hook. But then disable `atexit()` when shutting down after it finishes running. Add tests that cover all the cases: 1. registering a hook from inside a hook 2. registering a hook from another thread while hooks are running 3. attempting to register a hook after all hooks have finished (disallowed) Fixes #49841 Co-authored-by: Jameson Nash <vtjnash@gmail.com> 30 May 2023, 16:23:39 UTC
ed5bd4c Revert "Use `top_set_bit` to optimize `hash(Real)` (#49986)" (#49993) This reverts commit 18d02c249a90a7c2d25ac5a99a14cf7a414a3295. 30 May 2023, 06:09:08 UTC
18d02c2 Use `top_set_bit` to optimize `hash(Real)` (#49986) 29 May 2023, 23:23:15 UTC
957972e Expose the Julia JIT with a C API (#49858) 29 May 2023, 19:21:26 UTC
1cc10a6 refactor `Base.StackTraces.show_spec_linfo` (#49951) This commit separates the `MethodInstance` handling of `Base.StackTraces.show_spec_linfo` into `Base.StackTraces.show_spec_sig`, which can be generally useful for external code inspection tools or debuggers (like JET.jl). 29 May 2023, 09:20:39 UTC
0d5bd2f Add missing code formatting (#49983) 29 May 2023, 09:16:17 UTC
248ceda Abbreviate varinfo signature and re-order for consistency (#48860) 27 May 2023, 13:39:33 UTC
e727afb Move reflection documentation from devdocs to base (#47800) 27 May 2023, 11:36:10 UTC
fb3df69 Improve error when indexing is interpreted as a typed comprehension (#49939) * Improve errors for typed_hcat by adding a special error for indexing that gets resolved as a typed comprehension. * Add a test for issue #49676 26 May 2023, 22:56:56 UTC
ba2aa30 Enum: fix stackoverflow in `hash` for custom enum subtypes introduced in #49777 (#49964) 26 May 2023, 21:44:37 UTC
f8dd16e Add Libc methods for memmove/memcpy/memset/memcmp (#49550) These are used in many places (and are actually LLVM compiler intrinsics), so it probably makes more sense to define them one and export them to users. The Libc module contains some code that we might not care to have as part of bootstrapping. However, the C-memory methods are directly called throughout bootstrapping so these are now defined in a seperate "cmem.jl" file that is defined in Base then imported into `Libc` for the public interface. Co-authored-by: Jameson Nash <vtjnash@gmail.com> 26 May 2023, 18:53:31 UTC
ba1391a some minor hygiene fixes (#49897) This code does a bad job handling `(escape symbol)` in a lot of places. This attempts to fix some of them by peeking through it more. 26 May 2023, 18:51:09 UTC
23e0b2d Hide safepoint prologue and CFI instructions from reflection. (#49948) 26 May 2023, 17:09:12 UTC
666d325 Fix conversion of infinities to integers (#49624) Fixes #49422 26 May 2023, 12:53:34 UTC
4ef9fb1 When adopting a thread, spin until GC isn't running. (#49934) Co-authored-by: Valentin Churavy <vchuravy@users.noreply.github.com> 26 May 2023, 12:25:37 UTC
91cd521 Extend comparison lifting to `Core.ifelse` (#49882) This change extends our existing transformation for: φ(a,b) === Const(c) => φ(a === c, b === c) to perform the analogous transformation for `Core.ifelse`: Core.ifelse(cond, a, b) === Const(c) => Core.ifelse(cond, a === c, b === c) 26 May 2023, 01:55:35 UTC
229269b Don't permalloc the pkgimgs, but with an option (#49940) 25 May 2023, 17:37:20 UTC
01ddf80 lowering: preserve line numbers over julia-expand-macroscope pass (#44995) This is to preserve the line number of the macro caller in the output, in case we don't have context from eval on where it occured. But we make slightly more changes than strictly necessary to prepare for future improvements in this area. 25 May 2023, 13:52:51 UTC
94bc2f3 Merge pull request #49679 from JuliaLang/pc/timing-events 25 May 2023, 00:11:36 UTC
e370e4e Slightly re-factor timing counts back-end This should make it clearer what the responsibilities for each function are, and fix a bug where conditionally-triggered events could end up with an invalid total time. 24 May 2023, 18:42:19 UTC
aea56a9 Ensure Distributed workers inherit threads spec properly (#49942) 24 May 2023, 15:01:20 UTC
310f590 Include `HermOrSym` in character-based `mul!` dispatch (#49865) 24 May 2023, 12:30:14 UTC
bee2c30 doc: add rand! and randn! to docstrings of rand and randn (#49808) 24 May 2023, 07:01:37 UTC
c470dc3 Lock finalizers lists at exit (#49931) 23 May 2023, 13:26:41 UTC
1143b8f improve error message when calling argextype on invalid ir (#49923) 23 May 2023, 13:04:40 UTC
22551a2 allow specializing `Base.hash` for enum types without overwriting method (#49777) Previously `@enum` defined `Base.hash(::MyEnumType, ::UInt)` on the user-defined enum type `MyEnumType`. When the user wants to specialize the hash function for his own enum type he will define exactly that method signature again which overwrites it and leads to the warning WARNING: Method definition hash(TestPackage.MyEnumType, UInt64) in module TestPackage at Enums.jl:210 overwritten at [...] ** incremental compilation may be fatally broken for this module ** This commit changes `@enum` so that an internal method is used instead which is called through a fallback `Base.hash(::Enum, ::UInt)`. 23 May 2023, 11:15:31 UTC
f44be79 Merge pull request #41931 from JuliaLang/avi/noinfer * introduce `@nospecializeinfer` macro to tell the compiler to avoid excess inference This commit introduces a new compiler annotation called `@nospecializeinfer`, which allows us to request the compiler to avoid excessive inference. \## `@nospecialize` mechanism T discuss `@nospecializeinfer`, let's first understand the behavior of `@nospecialize`. Its docstring says that > This is only a hint for the compiler to avoid excess code generation. , and it works by suppressing dispatches with complex runtime occurrences of the annotated arguments. This could be understood with the example below: ```julia julia> function call_func_itr(func, itr) local r = 0 r += func(itr[1]) r += func(itr[2]) r += func(itr[3]) r end; julia> _isa = isa; # just for the sake of explanation, global variable to prevent inlining julia> func_specialize(a) = _isa(a, Function); julia> func_nospecialize(@nospecialize a) = _isa(a, Function); julia> dispatchonly = Any[sin, muladd, nothing]; # untyped container can cause excessive runtime dispatch julia> @code_typed call_func_itr(func_specialize, dispatchonly) CodeInfo( 1 ─ %1 = π (0, Int64) │ %2 = Base.arrayref(true, itr, 1)::Any │ %3 = (func)(%2)::Any │ %4 = (%1 + %3)::Any │ %5 = Base.arrayref(true, itr, 2)::Any │ %6 = (func)(%5)::Any │ %7 = (%4 + %6)::Any │ %8 = Base.arrayref(true, itr, 3)::Any │ %9 = (func)(%8)::Any │ %10 = (%7 + %9)::Any └── return %10 ) => Any julia> @code_typed call_func_itr(func_nospecialize, dispatchonly) CodeInfo( 1 ─ %1 = π (0, Int64) │ %2 = Base.arrayref(true, itr, 1)::Any │ %3 = invoke func(%2::Any)::Any │ %4 = (%1 + %3)::Any │ %5 = Base.arrayref(true, itr, 2)::Any │ %6 = invoke func(%5::Any)::Any │ %7 = (%4 + %6)::Any │ %8 = Base.arrayref(true, itr, 3)::Any │ %9 = invoke func(%8::Any)::Any │ %10 = (%7 + %9)::Any └── return %10 ) => Any ``` The calls of `func_specialize` remain to be `:call` expression (so that they are dispatched and compiled at runtime) while the calls of `func_nospecialize` are resolved as `:invoke` expressions. This is because `@nospecialize` requests the compiler to give up compiling `func_nospecialize` with runtime argument types but with the declared argument types, allowing `call_func_itr(func_nospecialize, dispatchonly)` to avoid runtime dispatches and accompanying JIT compilations (i.e. "excess code generation"). The difference is evident when checking `specializations`: ```julia julia> call_func_itr(func_specialize, dispatchonly) 2 julia> length(Base.specializations(only(methods(func_specialize)))) 3 # w/ runtime dispatch, multiple specializations julia> call_func_itr(func_nospecialize, dispatchonly) 2 julia> length(Base.specializations(only(methods(func_nospecialize)))) 1 # w/o runtime dispatch, the single specialization ``` The problem here is that it influences dispatch only, and does not intervene into inference in anyway. So there is still a possibility of "excess inference" when the compiler sees a considerable complexity of argument types during inference: ```julia julia> func_specialize(a) = _isa(a, Function); # redefine func to clear the specializations julia> @assert length(Base.specializations(only(methods(func_specialize)))) == 0; julia> func_nospecialize(@nospecialize a) = _isa(a, Function); # redefine func to clear the specializations julia> @assert length(Base.specializations(only(methods(func_nospecialize)))) == 0; julia> withinfernce = tuple(sin, muladd, "foo"); # typed container can cause excessive inference julia> @time @code_typed call_func_itr(func_specialize, withinfernce); 0.000812 seconds (3.77 k allocations: 217.938 KiB, 94.34% compilation time) julia> length(Base.specializations(only(methods(func_specialize)))) 4 # multiple method instances inferred julia> @time @code_typed call_func_itr(func_nospecialize, withinfernce); 0.000753 seconds (3.77 k allocations: 218.047 KiB, 92.42% compilation time) julia> length(Base.specializations(only(methods(func_nospecialize)))) 4 # multiple method instances inferred ``` The purpose of this PR is to implement a mechanism that allows us to avoid excessive inference to reduce the compilation latency when inference sees a considerable complexity of argument types. \## Design Here are some ideas to implement the functionality: 1. make `@nospecialize` block inference 2. add nospecializeinfer effect when `@nospecialize`d method is annotated as `@noinline` 3. implement as `@pure`-like boolean annotation to request nospecializeinfer effect on top of `@nospecialize` 4. implement as annotation that is orthogonal to `@nospecialize` After trying 1 ~ 3., I decided to submit 3. \### 1. make `@nospecialize` block inference This is almost same as what Jameson has done at <https://github.com/vtjnash/julia/commit/8ab7b6b94079b842b5db9f3fe29eb9d2708f5d1e>. It turned out that this approach performs very badly because some of `@nospecialize`'d arguments still need inference to perform reasonably. For example, it's obvious that the following definition of `getindex(@nospecialize(t::Tuple), i::Int)` would perform very badly if `@nospecialize` blocks inference, because of a lack of useful type information for succeeding optimizations: <https://github.com/JuliaLang/julia/blob/12d364e8249a07097a233ce7ea2886002459cc50/base/tuple.jl#L29-L30> \### 2. add nospecializeinfer effect when `@nospecialize`d method is annotated as `@noinline` The important observation is that we often use `@nospecialize` even when we expect inference to forward type and constant information. Adversely, we may be able to exploit the fact that we usually don't expect inference to forward information to a callee when we annotate it with `@noinline` (i.e. when adding `@noinline`, we're usually fine with disabling inter-procedural optimizations other than resolving dispatch). So the idea is to enable the inference suppression when `@nospecialize`'d method is annotated as `@noinline` too. It's a reasonable choice and can be efficiently implemented with #41922. But it sounds a bit weird to me to associate no infer effect with `@noinline`, and I also think there may be some cases we want to inline a method while partly avoiding inference, e.g.: ```julia \# the compiler will always infer with `f::Any` @noinline function twof(@nospecialize(f), n) # this method body is very simple and should be eligible for inlining if occursin('+', string(typeof(f).name.name::Symbol)) 2 + n elseif occursin('*', string(typeof(f).name.name::Symbol)) 2n else zero(n) end end ``` \### 3. implement as `@pure`-like boolean annotation to request nospecializeinfer effect on top of `@nospecialize` This is what this commit implements. It basically replaces the previous `@noinline` flag with a newly-introduced annotation named `@nospecializeinfer`. It is still associated with `@nospecialize` and it only has effect when used together with `@nospecialize`, but now it is not associated to `@noinline`, and it would help us reason about the behavior of `@nospecializeinfer` and experiment its effect more safely: ```julia \# the compiler will always infer with `f::Any` Base.@nospecializeinfer function twof(@nospecialize(f), n) # the compiler may or not inline this method if occursin('+', string(typeof(f).name.name::Symbol)) 2 + n elseif occursin('*', string(typeof(f).name.name::Symbol)) 2n else zero(n) end end ``` \### 4. implement as annotation that is orthogonal to `@nospecialize` Actually, we can have `@nospecialize` and `@nospecializeinfer` separately, and it would allow us to configure compilation strategies in a more fine-grained way. ```julia function noinfspec(Base.@nospecializeinfer(f), @nospecialize(g)) ... end ``` I'm fine with this approach but at the same time I'm afraid to have too many annotations that are related to some sort (I expect we will annotate both `@nospecializeinfer` and `@nospecialize` in this scheme). --- experiment `@nospecializeinfer` on `Core.Compiler` This commit adds `@nospecializeinfer` macro on various `Core.Compiler` functions and achieves the following sysimage size reduction: | | this commit | master | % | | --------------------------------- | ----------- | ----------- | ------- | | `Core.Compiler` compilation (sec) | `66.4551` | `71.0846` | `0.935` | | `corecompiler.jl` (KB) | `17638080` | `18407248` | `0.958` | | `sys.jl` (KB) | `88736432` | `89361280` | `0.993` | | `sys-o.a` (KB) | `189484400` | `189907096` | `0.998` | --------- Co-authored-by: Mosè Giordano <giordano@users.noreply.github.com> Co-authored-by: Tim Holy <tim.holy@gmail.com> 23 May 2023, 06:16:47 UTC
944b28c show mark-queue on GC critical error (#49902) Re-adds the capability of showing the mark-queue on a GC critical error. 22 May 2023, 19:29:39 UTC
e02d3ba jltypes: always run parameter normalization (#49845) This simplifies the types, which may help subtyping other other similar lookup code any time this is later used as a parameter, so it is probably worthwhile to do. This is a followup to #49820, where we reorganized the code to make this more straightforward. 22 May 2023, 15:21:03 UTC
1c21cbb Merge pull request #48793 from stahta01/libgit_find_libssh2_fix [WINDOWS][BUILD] Fix for Cygwin using USE_BINARYBUILDER_LIBGIT2=0 22 May 2023, 14:32:54 UTC
672f609 Two simple examples for Threads (#49704) 22 May 2023, 11:06:39 UTC
3b84b08 xref and doctest for regexmatch and occursin (#49911) 22 May 2023, 10:50:56 UTC
e4a563a deps/libgit2: Add LIBSSH2 paths 21 May 2023, 17:41:00 UTC
a6ad9ea Fix jl_timing_show_method_instance for top-level thunks (#49862) This was causing invalid pointer dereferences when the method instance had no backing method. 21 May 2023, 08:01:27 UTC
0495278 lowering: avoid copying the entire module back to flisp just to get its name (#49898) 21 May 2023, 08:00:10 UTC
back to top