From 0da9578148ddd237470eb588943a29e9100778a3 Mon Sep 17 00:00:00 2001 From: Elliot Saba Date: Mon, 19 Aug 2024 12:10:29 -0700 Subject: [PATCH 01/22] Set `.jl` sources as read-only during installation (#55524) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This sets all `.jl` files in `$(prefix)/base` and `$(prefix)/test` to have `0444` permissions, to better match how `Pkg` installs packages (and sets them to be read-only). Fixes https://github.com/JuliaLang/juliaup/issues/865 --------- Co-authored-by: Mosè Giordano <765740+giordano@users.noreply.github.com> (cherry picked from commit 62e7705845f9dbf0c22b291c3d63e3cc6af57df4) --- Makefile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Makefile b/Makefile index 57d5cde328e02..ec13f23bbb2cf 100644 --- a/Makefile +++ b/Makefile @@ -377,6 +377,11 @@ endif cp -R -L $(JULIAHOME)/base/* $(DESTDIR)$(datarootdir)/julia/base cp -R -L $(JULIAHOME)/test/* $(DESTDIR)$(datarootdir)/julia/test cp -R -L $(build_datarootdir)/julia/* $(DESTDIR)$(datarootdir)/julia + + # Set .jl sources as read-only to match package directories + find $(DESTDIR)$(datarootdir)/julia/base -type f -name \*.jl -exec chmod 0444 '{}' \; + find $(DESTDIR)$(datarootdir)/julia/test -type f -name \*.jl -exec chmod 0444 '{}' \; + # Copy documentation cp -R -L $(BUILDROOT)/doc/_build/html $(DESTDIR)$(docdir)/ # Remove various files which should not be installed From e3657193498736a0e5d1543c42ea2efab75b6647 Mon Sep 17 00:00:00 2001 From: Jameson Nash Date: Mon, 19 Aug 2024 21:57:48 -0400 Subject: [PATCH 02/22] make jl_thread_suspend_and_get_state safe (#55500) Fixes async safety, thread safety, FreeBSD safety. (cherry picked from commit d4bd540d0f30605ef184af79f2aaaff9aa351a54) --- src/signals-unix.c | 109 +++++++++++++++++++++++---------------------- 1 file changed, 55 insertions(+), 54 deletions(-) diff --git a/src/signals-unix.c b/src/signals-unix.c index 8b79e11863e1f..5732fd1e9c91d 100644 --- a/src/signals-unix.c +++ b/src/signals-unix.c @@ -292,6 +292,8 @@ int exc_reg_is_write_fault(uintptr_t esr) { #if defined(HAVE_MACH) #include "signals-mach.c" #else +#include +#include int jl_lock_stackwalk(void) { @@ -404,17 +406,13 @@ JL_NO_ASAN static void segv_handler(int sig, siginfo_t *info, void *context) } } -#if !defined(JL_DISABLE_LIBUNWIND) -static bt_context_t *signal_context; -pthread_mutex_t in_signal_lock; -static pthread_cond_t exit_signal_cond; -static pthread_cond_t signal_caught_cond; +pthread_mutex_t in_signal_lock; // shared with jl_delete_thread +static bt_context_t *signal_context; // protected by in_signal_lock +static int exit_signal_cond = -1; +static int signal_caught_cond = -1; int jl_thread_suspend_and_get_state(int tid, int timeout, bt_context_t *ctx) { - struct timespec ts; - clock_gettime(CLOCK_REALTIME, &ts); - ts.tv_sec += timeout; pthread_mutex_lock(&in_signal_lock); jl_ptls_t ptls2 = jl_atomic_load_relaxed(&jl_all_tls_states)[tid]; jl_task_t *ct2 = ptls2 ? jl_atomic_load_relaxed(&ptls2->current_task) : NULL; @@ -423,48 +421,51 @@ int jl_thread_suspend_and_get_state(int tid, int timeout, bt_context_t *ctx) pthread_mutex_unlock(&in_signal_lock); return 0; } - jl_atomic_store_release(&ptls2->signal_request, 1); - pthread_kill(ptls2->system_id, SIGUSR2); - // wait for thread to acknowledge - int err = pthread_cond_timedwait(&signal_caught_cond, &in_signal_lock, &ts); - if (err == ETIMEDOUT) { - sig_atomic_t request = 1; + sig_atomic_t request = 0; + if (!jl_atomic_cmpswap(&ptls2->signal_request, &request, 1)) { + // something is wrong, or there is already a usr2 in flight elsewhere + pthread_mutex_unlock(&in_signal_lock); + return 0; + } + request = 1; + int err = pthread_kill(ptls2->system_id, SIGUSR2); + // wait for thread to acknowledge or timeout + struct pollfd event = {signal_caught_cond, POLLIN, 0}; + if (err == 0) { + do { + err = poll(&event, 1, timeout * 1000); + } while (err == -1 && errno == EINTR); + } + if ((event.revents & POLLIN) == 0) { + // not ready after timeout: try to cancel this request if (jl_atomic_cmpswap(&ptls2->signal_request, &request, 0)) { pthread_mutex_unlock(&in_signal_lock); return 0; } - // Request is either now 0 (meaning the other thread is waiting for - // exit_signal_cond already), - // Or it is now -1 (meaning the other thread - // is waiting for in_signal_lock, and we need to release that lock - // here for a bit, until the other thread has a chance to get to the - // exit_signal_cond) - if (request == -1) { - err = pthread_cond_wait(&signal_caught_cond, &in_signal_lock); - assert(!err); - } } + eventfd_t got; + do { + err = read(signal_caught_cond, &got, sizeof(eventfd_t)); + } while (err == -1 && errno == EINTR); + if (err != sizeof(eventfd_t)) abort(); + assert(got == 1); (void) got; // Now the other thread is waiting on exit_signal_cond (verify that here by // checking it is 0, and add an acquire barrier for good measure) - int request = jl_atomic_load_acquire(&ptls2->signal_request); + request = jl_atomic_load_acquire(&ptls2->signal_request); assert(request == 0); (void) request; - jl_atomic_store_release(&ptls2->signal_request, 1); // prepare to resume normally + jl_atomic_store_release(&ptls2->signal_request, 4); // prepare to resume normally, but later code may change this *ctx = *signal_context; return 1; } void jl_thread_resume(int tid) { - jl_ptls_t ptls2 = jl_atomic_load_relaxed(&jl_all_tls_states)[tid]; - pthread_cond_broadcast(&exit_signal_cond); - pthread_cond_wait(&signal_caught_cond, &in_signal_lock); // wait for thread to acknowledge (so that signal_request doesn't get mixed up) - // The other thread is waiting to leave exit_signal_cond (verify that here by - // checking it is 0, and add an acquire barrier for good measure) - int request = jl_atomic_load_acquire(&ptls2->signal_request); - assert(request == 0); (void) request; + int err; + eventfd_t got = 1; + err = write(exit_signal_cond, &got, sizeof(eventfd_t)); + if (err != sizeof(eventfd_t)) abort(); pthread_mutex_unlock(&in_signal_lock); } -#endif // Throw jl_interrupt_exception if the master thread is in a signal async region // or if SIGINT happens too often. @@ -473,9 +474,11 @@ static void jl_try_deliver_sigint(void) jl_ptls_t ptls2 = jl_atomic_load_relaxed(&jl_all_tls_states)[0]; jl_safepoint_enable_sigint(); jl_wake_libuv(); + pthread_mutex_lock(&in_signal_lock); jl_atomic_store_release(&ptls2->signal_request, 2); // This also makes sure `sleep` is aborted. pthread_kill(ptls2->system_id, SIGUSR2); + pthread_mutex_unlock(&in_signal_lock); } // Write only by signal handling thread, read only by main thread @@ -508,12 +511,12 @@ static void jl_exit_thread0(int signo, jl_bt_element_t *bt_data, size_t bt_size) } // request: -// -1: beginning processing [invalid outside here] // 0: nothing [not from here] -// 1: get state +// 1: get state & wait for request // 2: throw sigint if `!defer_signal && io_wait` or if force throw threshold // is reached // 3: raise `thread0_exit_signo` and try to exit +// 4: no-op void usr2_handler(int sig, siginfo_t *info, void *ctx) { jl_task_t *ct = jl_get_current_task(); @@ -524,25 +527,21 @@ void usr2_handler(int sig, siginfo_t *info, void *ctx) return; int errno_save = errno; // acknowledge that we saw the signal_request - sig_atomic_t request = jl_atomic_exchange(&ptls->signal_request, -1); -#if !defined(JL_DISABLE_LIBUNWIND) + sig_atomic_t request = jl_atomic_exchange(&ptls->signal_request, 0); if (request == 1) { - pthread_mutex_lock(&in_signal_lock); signal_context = jl_to_bt_context(ctx); - // acknowledge that we set the signal_caught_cond broadcast + int err; + eventfd_t got = 1; + err = write(signal_caught_cond, &got, sizeof(eventfd_t)); + if (err != sizeof(eventfd_t)) abort(); + do { + err = read(exit_signal_cond, &got, sizeof(eventfd_t)); + } while (err == -1 && errno == EINTR); + if (err != sizeof(eventfd_t)) abort(); + assert(got == 1); request = jl_atomic_exchange(&ptls->signal_request, 0); - assert(request == -1); (void) request; - pthread_cond_broadcast(&signal_caught_cond); - pthread_cond_wait(&exit_signal_cond, &in_signal_lock); - request = jl_atomic_exchange(&ptls->signal_request, 0); - assert(request == 1 || request == 3); - // acknowledge that we got the resume signal - pthread_cond_broadcast(&signal_caught_cond); - pthread_mutex_unlock(&in_signal_lock); + assert(request == 2 || request == 3 || request == 4); } - else -#endif - jl_atomic_exchange(&ptls->signal_request, 0); // returns -1 if (request == 2) { int force = jl_check_force_sigint(); if (force || (!ptls->defer_signal && ptls->io_wait)) { @@ -987,10 +986,12 @@ void restore_signals(void) jl_sigsetset(&sset); pthread_sigmask(SIG_SETMASK, &sset, 0); -#if !defined(HAVE_MACH) && !defined(JL_DISABLE_LIBUNWIND) +#if !defined(HAVE_MACH) + exit_signal_cond = eventfd(0, EFD_CLOEXEC); + signal_caught_cond = eventfd(0, EFD_CLOEXEC); if (pthread_mutex_init(&in_signal_lock, NULL) != 0 || - pthread_cond_init(&exit_signal_cond, NULL) != 0 || - pthread_cond_init(&signal_caught_cond, NULL) != 0) { + exit_signal_cond == -1 || + signal_caught_cond == -1) { jl_error("SIGUSR pthread init failed"); } #endif From 803520ee849c8402a17a1525d6e996ec65224aba Mon Sep 17 00:00:00 2001 From: Jishnu Bhattacharya Date: Fri, 23 Aug 2024 12:55:46 +0530 Subject: [PATCH 03/22] Fix indexing in _mapreducedim for OffsetArrays (#55506) The destination array was being indexed incorrectly if it had offset indices. This led to the following on nightly: ```julia julia> using OffsetArrays julia> r = 5:100; julia> a = OffsetVector(r, 2); julia> sum(a, dims=1) 1-element OffsetArray(::Vector{Int64}, 3:3) with eltype Int64 with indices 3:3: 0 julia> sum(a) 5040 ``` The indexing was marked `@inbounds`, so this was not throwing an error. This PR also follows #55329 and only marks the indexing operations as `@inbounds`, omitting the function calls. --------- Co-authored-by: Matt Bauman (cherry picked from commit 3d20a9210a59097b46ed2cbdcd1e87435873bcfa) --- base/reducedim.jl | 5 +++-- test/offsetarray.jl | 7 +++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/base/reducedim.jl b/base/reducedim.jl index 19d8f0a5af77c..2f51837a66050 100644 --- a/base/reducedim.jl +++ b/base/reducedim.jl @@ -261,8 +261,9 @@ function _mapreducedim!(f, op, R::AbstractArray, A::AbstractArrayOrBroadcasted) # use mapreduce_impl, which is probably better tuned to achieve higher performance nslices = div(length(A), lsiz) ibase = first(LinearIndices(A))-1 - for i = 1:nslices - @inbounds R[i] = op(R[i], mapreduce_impl(f, op, A, ibase+1, ibase+lsiz)) + for i in eachindex(R) + r = op(@inbounds(R[i]), mapreduce_impl(f, op, A, ibase+1, ibase+lsiz)) + @inbounds R[i] = r ibase += lsiz end return R diff --git a/test/offsetarray.jl b/test/offsetarray.jl index c50f38c382385..5f0c19d7593f5 100644 --- a/test/offsetarray.jl +++ b/test/offsetarray.jl @@ -878,3 +878,10 @@ end v = view([1,2,3,4], :) @test v[Base.IdentityUnitRange(2:3)] == OffsetArray(2:3, 2:3) end + +@testset "mapreduce with OffsetRanges" begin + r = 5:100 + a = OffsetArray(r, 2) + b = sum(a, dims=1) + @test b[begin] == sum(r) +end From 808203f43fa2b3d97ca62dedc32c13cadf01b861 Mon Sep 17 00:00:00 2001 From: Gabriel Baraldi Date: Sun, 25 Aug 2024 10:21:58 -0300 Subject: [PATCH 04/22] Empty out loaded_precompiles dict instead of asserting it's empty. (#55564) This dict will contain things if we load a package image during precompilation (cherry picked from commit 0c8641aacb53e6f4c7f21dd08e35873a2801a8f8) --- base/Base.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base/Base.jl b/base/Base.jl index 21c9a101758a0..0aa191206e3df 100644 --- a/base/Base.jl +++ b/base/Base.jl @@ -603,7 +603,7 @@ function __init__() init_active_project() append!(empty!(_sysimage_modules), keys(loaded_modules)) empty!(explicit_loaded_modules) - @assert isempty(loaded_precompiles) + empty!(loaded_precompiles) # If we load a packageimage when building the image this might not be empty for (mod, key) in module_keys loaded_precompiles[key => module_build_id(mod)] = mod end From 598a4de169af8385a5ce85fec23bcc058eba5d20 Mon Sep 17 00:00:00 2001 From: DilumAluthgeBot <43731525+DilumAluthgeBot@users.noreply.github.com> Date: Wed, 28 Aug 2024 13:16:39 -0400 Subject: [PATCH 05/22] =?UTF-8?q?=F0=9F=A4=96=20[backports-release-1.11]?= =?UTF-8?q?=20Bump=20the=20Downloads=20stdlib=20from=20a9d274f=20to=201061?= =?UTF-8?q?ecc=20(#55615)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Stdlib: Downloads URL: https://github.com/JuliaLang/Downloads.jl.git Stdlib branch: master Julia branch: backports-release-1.11 Old commit: a9d274f New commit: 1061ecc Julia version: 1.11.0-rc2 Downloads version: 1.6.0(It's okay that it doesn't match) Bump invoked by: @IanButterworth Powered by: [BumpStdlibs.jl](https://github.com/JuliaLang/BumpStdlibs.jl) Diff: https://github.com/JuliaLang/Downloads.jl/compare/a9d274ff6588cc5dbfa90e908ee34c2408bab84a...1061ecc377a053fce0df94e1a19e5260f7c030f5 ``` $ git log --oneline a9d274f..1061ecc 1061ecc Fix setting atexit. Fixes trailing download tasks during precompilation (#257) b871386 Add debug information to `setopt` commands (#248) 51e5321 fix: use invokelatest for easy_hook, avoid race (#241) 05f9ec2 make precompile workload relocatable (#236) 2dd891a Hardcode doc edit backlink (#232) ``` Co-authored-by: Dilum Aluthge --- .../md5 | 1 + .../sha512 | 1 + .../md5 | 1 - .../sha512 | 1 - stdlib/Downloads.version | 2 +- 5 files changed, 3 insertions(+), 3 deletions(-) create mode 100644 deps/checksums/Downloads-1061ecc377a053fce0df94e1a19e5260f7c030f5.tar.gz/md5 create mode 100644 deps/checksums/Downloads-1061ecc377a053fce0df94e1a19e5260f7c030f5.tar.gz/sha512 delete mode 100644 deps/checksums/Downloads-a9d274ff6588cc5dbfa90e908ee34c2408bab84a.tar.gz/md5 delete mode 100644 deps/checksums/Downloads-a9d274ff6588cc5dbfa90e908ee34c2408bab84a.tar.gz/sha512 diff --git a/deps/checksums/Downloads-1061ecc377a053fce0df94e1a19e5260f7c030f5.tar.gz/md5 b/deps/checksums/Downloads-1061ecc377a053fce0df94e1a19e5260f7c030f5.tar.gz/md5 new file mode 100644 index 0000000000000..f42bbedb6d415 --- /dev/null +++ b/deps/checksums/Downloads-1061ecc377a053fce0df94e1a19e5260f7c030f5.tar.gz/md5 @@ -0,0 +1 @@ +70878dd96911d6960537dfee2a820d98 diff --git a/deps/checksums/Downloads-1061ecc377a053fce0df94e1a19e5260f7c030f5.tar.gz/sha512 b/deps/checksums/Downloads-1061ecc377a053fce0df94e1a19e5260f7c030f5.tar.gz/sha512 new file mode 100644 index 0000000000000..83164cad9a89d --- /dev/null +++ b/deps/checksums/Downloads-1061ecc377a053fce0df94e1a19e5260f7c030f5.tar.gz/sha512 @@ -0,0 +1 @@ +87d2bdc6c85cbbce5302aab8ffe92fc542c9c71a396844fcc04c0416be059b00298b4816ab5e5491dbf865660a3a6152f1c245875a1ec75fb49b4c7ba0d303d8 diff --git a/deps/checksums/Downloads-a9d274ff6588cc5dbfa90e908ee34c2408bab84a.tar.gz/md5 b/deps/checksums/Downloads-a9d274ff6588cc5dbfa90e908ee34c2408bab84a.tar.gz/md5 deleted file mode 100644 index fc3bce951cafb..0000000000000 --- a/deps/checksums/Downloads-a9d274ff6588cc5dbfa90e908ee34c2408bab84a.tar.gz/md5 +++ /dev/null @@ -1 +0,0 @@ -97bb33510fadec7f4cc4c718c739e9a0 diff --git a/deps/checksums/Downloads-a9d274ff6588cc5dbfa90e908ee34c2408bab84a.tar.gz/sha512 b/deps/checksums/Downloads-a9d274ff6588cc5dbfa90e908ee34c2408bab84a.tar.gz/sha512 deleted file mode 100644 index bf2821e8252b0..0000000000000 --- a/deps/checksums/Downloads-a9d274ff6588cc5dbfa90e908ee34c2408bab84a.tar.gz/sha512 +++ /dev/null @@ -1 +0,0 @@ -a362aaf762f42deebb8632a7a7980cd22b2777e8c4dc629e418580269e24a64217ad846d61acad70438cfdc190e47ba2ff7716edd4e04d8d10c1d765efce604d diff --git a/stdlib/Downloads.version b/stdlib/Downloads.version index 7805348a4b2f5..cb041d86d7f66 100644 --- a/stdlib/Downloads.version +++ b/stdlib/Downloads.version @@ -1,4 +1,4 @@ DOWNLOADS_BRANCH = master -DOWNLOADS_SHA1 = a9d274ff6588cc5dbfa90e908ee34c2408bab84a +DOWNLOADS_SHA1 = 1061ecc377a053fce0df94e1a19e5260f7c030f5 DOWNLOADS_GIT_URL := https://github.com/JuliaLang/Downloads.jl.git DOWNLOADS_TAR_URL = https://api.github.com/repos/JuliaLang/Downloads.jl/tarball/$1 From 890ac86f29dd08ec1bc5daf5c74248f8186c95bb Mon Sep 17 00:00:00 2001 From: Mark Kittisopikul Date: Fri, 16 Aug 2024 03:33:22 -0400 Subject: [PATCH 06/22] Fix push! for OffsetVectors, add tests for push! and append! on AbstractVector (#55480) Per https://github.com/JuliaLang/julia/pull/55470#discussion_r1714000529, the `push!(::AbstractArray, ...)` array implementation assumed one-based indexing and did not account for an `OffsetVector` scenario. Here we add tests for `push!(::AbstractArray, ...)` and `append(::AbstractArray, ...)` including using `@invoke` to test the effect on `OffsetVector`. cc: @fredrikekre (cherry picked from commit 5230d27de950165475892acfabded59713c8cd3e) --- base/abstractarray.jl | 7 ++++--- test/abstractarray.jl | 18 +++++++++++++++++- test/offsetarray.jl | 29 +++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 4 deletions(-) diff --git a/base/abstractarray.jl b/base/abstractarray.jl index 2d281b487c437..ad70b973ab10b 100644 --- a/base/abstractarray.jl +++ b/base/abstractarray.jl @@ -3504,7 +3504,7 @@ function push!(a::AbstractVector{T}, item) where T itemT = item isa T ? item : convert(T, item)::T new_length = length(a) + 1 resize!(a, new_length) - a[new_length] = itemT + a[end] = itemT return a end @@ -3512,7 +3512,7 @@ end function push!(a::AbstractVector{Any}, @nospecialize x) new_length = length(a) + 1 resize!(a, new_length) - a[new_length] = x + a[end] = x return a end function push!(a::AbstractVector{Any}, @nospecialize x...) @@ -3520,8 +3520,9 @@ function push!(a::AbstractVector{Any}, @nospecialize x...) na = length(a) nx = length(x) resize!(a, na + nx) + e = lastindex(a) - nx for i = 1:nx - a[na+i] = x[i] + a[e+i] = x[i] end return a end diff --git a/test/abstractarray.jl b/test/abstractarray.jl index 88cffbcf2947d..8244d3fc791f5 100644 --- a/test/abstractarray.jl +++ b/test/abstractarray.jl @@ -1424,14 +1424,30 @@ using .Main.OffsetArrays end @testset "Check push!($a, $args...)" for - a in (["foo", "Bar"], SimpleArray(["foo", "Bar"]), OffsetVector(["foo", "Bar"], 0:1)), + a in (["foo", "Bar"], SimpleArray(["foo", "Bar"]), SimpleArray{Any}(["foo", "Bar"]), OffsetVector(["foo", "Bar"], 0:1)), args in (("eenie",), ("eenie", "minie"), ("eenie", "minie", "mo")) orig = copy(a) push!(a, args...) @test length(a) == length(orig) + length(args) + @test a[axes(orig,1)] == orig @test all(a[end-length(args)+1:end] .== args) end +@testset "Check append!($a, $args)" for + a in (["foo", "Bar"], SimpleArray(["foo", "Bar"]), SimpleArray{Any}(["foo", "Bar"]), OffsetVector(["foo", "Bar"], 0:1)), + args in (("eenie",), ("eenie", "minie"), ("eenie", "minie", "mo")) + orig = copy(a) + append!(a, args) + @test length(a) == length(orig) + length(args) + @test a[axes(orig,1)] == orig + @test all(a[end-length(args)+1:end] .== args) +end + +@testset "Check sizehint!($a)" for + a in (["foo", "Bar"], SimpleArray(["foo", "Bar"]), SimpleArray{Any}(["foo", "Bar"]), OffsetVector(["foo", "Bar"], 0:1)) + @test sizehint!(a, 10) === a +end + @testset "splatting into hvcat" begin t = (1, 2) @test [t...; 3 4] == [1 2; 3 4] diff --git a/test/offsetarray.jl b/test/offsetarray.jl index 5f0c19d7593f5..fb5855dfbaa0d 100644 --- a/test/offsetarray.jl +++ b/test/offsetarray.jl @@ -383,6 +383,18 @@ v2 = copy(v) @test v2[end-1] == 2 @test v2[end] == 1 +# push!(v::AbstractVector, x...) +v2 = copy(v) +@test @invoke(push!(v2::AbstractVector, 3)) === v2 +@test v2[axes(v,1)] == v +@test v2[end] == 3 +@test v2[begin] == v[begin] == v[-2] +v2 = copy(v) +@test @invoke(push!(v2::AbstractVector, 5, 6)) == v2 +@test v2[axes(v,1)] == v +@test v2[end-1] == 5 +@test v2[end] == 6 + # append! from array v2 = copy(v) @test append!(v2, [2, 1]) === v2 @@ -399,6 +411,23 @@ v2 = copy(v) @test v2[axes(v, 1)] == v @test v2[lastindex(v)+1:end] == [2, 1] +# append!(::AbstractVector, ...) +# append! from array +v2 = copy(v) +@test @invoke(append!(v2::AbstractVector, [2, 1]::Any)) === v2 +@test v2[axes(v, 1)] == v +@test v2[lastindex(v)+1:end] == [2, 1] +# append! from HasLength iterator +v2 = copy(v) +@test @invoke(append!(v2::AbstractVector, (v for v in [2, 1])::Any)) === v2 +@test v2[axes(v, 1)] == v +@test v2[lastindex(v)+1:end] == [2, 1] +# append! from SizeUnknown iterator +v2 = copy(v) +@test @invoke(append!(v2::AbstractVector, (v for v in [2, 1] if true)::Any)) === v2 +@test v2[axes(v, 1)] == v +@test v2[lastindex(v)+1:end] == [2, 1] + # other functions v = OffsetArray(v0, (-3,)) @test lastindex(v) == 1 From d6fca1558127bad162df8e4f0e63d65b573c3255 Mon Sep 17 00:00:00 2001 From: Gabriel Baraldi Date: Tue, 27 Aug 2024 15:00:55 -0300 Subject: [PATCH 07/22] Initialize threadpools correctly during sysimg build (#55567) I made a mistake with which threadpool was which. (cherry picked from commit d5bbcc5aaec8033de1dd5b4b0de730ab40575469) --- src/init.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/init.c b/src/init.c index 2c1ad618948f8..a5c9a6b19f94d 100644 --- a/src/init.c +++ b/src/init.c @@ -883,8 +883,8 @@ static NOINLINE void _finish_julia_init(JL_IMAGE_SEARCH rel, jl_ptls_t ptls, jl_ jl_n_markthreads = 0; jl_n_sweepthreads = 0; jl_n_gcthreads = 0; - jl_n_threads_per_pool[0] = 1; - jl_n_threads_per_pool[1] = 0; + jl_n_threads_per_pool[0] = 0; // Interactive threadpool + jl_n_threads_per_pool[1] = 1; // Default threadpool } else { post_image_load_hooks(); } From 561e5c8c8b2a8a200551d889ec7e9b3aa1bf6487 Mon Sep 17 00:00:00 2001 From: Jishnu Bhattacharya Date: Wed, 28 Aug 2024 14:05:58 +0530 Subject: [PATCH 08/22] Fast bounds-check for CartesianIndex ranges (#55596) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `StepRangeLen{<:CartesianIndex}` indices have been supported since v1.11, but bounds-checking for such indices currently falls back to iterating over the entire range. This PR adds a quick `checkindex` for such ranges. The performance improvement as a consequence: ```julia julia> D = Diagonal(1:10_000); julia> @btime checkbounds($D, diagind($D, IndexCartesian())); 6.697 μs (0 allocations: 0 bytes) # nightly, O(n) 4.044 ns (0 allocations: 0 bytes) # This PR, O(1) ``` (cherry picked from commit 644029282cfeafcb3b80d999b0054cdaa9278e3d) --- base/multidimensional.jl | 2 ++ stdlib/LinearAlgebra/test/diagonal.jl | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/base/multidimensional.jl b/base/multidimensional.jl index 519ac06e6e7ec..b6c93fa318d78 100644 --- a/base/multidimensional.jl +++ b/base/multidimensional.jl @@ -693,6 +693,8 @@ using .IteratorsMD end @inline checkindex(::Type{Bool}, inds::Tuple, I::CartesianIndex) = checkbounds_indices(Bool, inds, I.I) +@inline checkindex(::Type{Bool}, inds::Tuple, i::AbstractRange{<:CartesianIndex}) = + isempty(i) | (checkindex(Bool, inds, first(i)) & checkindex(Bool, inds, last(i))) # Indexing into Array with mixtures of Integers and CartesianIndices is # extremely performance-sensitive. While the abstract fallbacks support this, diff --git a/stdlib/LinearAlgebra/test/diagonal.jl b/stdlib/LinearAlgebra/test/diagonal.jl index c20c63b5b3477..fd4ebfb714a37 100644 --- a/stdlib/LinearAlgebra/test/diagonal.jl +++ b/stdlib/LinearAlgebra/test/diagonal.jl @@ -1312,4 +1312,9 @@ end end end +@testset "bounds-check with CartesianIndex ranges" begin + D = Diagonal(1:typemax(Int)) + @test checkbounds(Bool, D, diagind(D, IndexCartesian())) +end + end # module TestDiagonal From dde7c107871e775a0d2a4f5ef7f200269fa226ea Mon Sep 17 00:00:00 2001 From: Jameson Nash Date: Tue, 3 Sep 2024 12:24:01 -0400 Subject: [PATCH 09/22] win: move stack_overflow_warning to the backtrace fiber (#55640) There is not enough stack space remaining after a stack overflow on Windows to allocate the 4k page used by `write` to call the WriteFile syscall. This causes it to hard-crash. But we can simply run this on the altstack implementation, where there is plenty of space. (cherry picked from commit eebc1e4e083b9b597bef328a5bd8eeda9ec52c1f) --- src/signals-win.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/signals-win.c b/src/signals-win.c index a2980a0c063d9..2b01310964ddb 100644 --- a/src/signals-win.c +++ b/src/signals-win.c @@ -109,6 +109,8 @@ static jl_ptls_t stkerror_ptls; static int have_backtrace_fiber; static void JL_NORETURN start_backtrace_fiber(void) { + // print the warning (this mysteriously needs a lot of stack for the WriteFile syscall) + stack_overflow_warning(); // collect the backtrace stkerror_ptls->bt_size = rec_backtrace_ctx(stkerror_ptls->bt_data, JL_MAX_BT_SIZE, stkerror_ctx, From 972d618bc222b97af5dee5e61b6c2b36417c9716 Mon Sep 17 00:00:00 2001 From: Katharine Hyatt Date: Mon, 19 Aug 2024 11:38:52 -0400 Subject: [PATCH 10/22] Add test for upper/lower/titlecase and fix missing import (#55443) (cherry picked from commit 39eaa3cfc1a861cf898d89fbe320ffa858f41939) --- base/strings/annotated.jl | 2 +- base/strings/unicode.jl | 3 ++- test/strings/annotated.jl | 3 +++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/base/strings/annotated.jl b/base/strings/annotated.jl index 69b04202edbf6..ef1ea28f42738 100644 --- a/base/strings/annotated.jl +++ b/base/strings/annotated.jl @@ -384,7 +384,7 @@ a vector of region–annotation tuples. In accordance with the semantics documented in [`AnnotatedString`](@ref), the order of annotations returned matches the order in which they were applied. -See also: `annotate!`. +See also: [`annotate!`](@ref). """ annotations(s::AnnotatedString) = s.annotations diff --git a/base/strings/unicode.jl b/base/strings/unicode.jl index a3b06063b98ac..2e142be901b0b 100644 --- a/base/strings/unicode.jl +++ b/base/strings/unicode.jl @@ -5,7 +5,8 @@ module Unicode import Base: show, ==, hash, string, Symbol, isless, length, eltype, convert, isvalid, ismalformed, isoverlong, iterate, - AnnotatedString, AnnotatedChar, annotated_chartransform + AnnotatedString, AnnotatedChar, annotated_chartransform, + annotations # whether codepoints are valid Unicode scalar values, i.e. 0-0xd7ff, 0xe000-0x10ffff diff --git a/test/strings/annotated.jl b/test/strings/annotated.jl index 62bf9a0c91c00..9e24ae46fd206 100644 --- a/test/strings/annotated.jl +++ b/test/strings/annotated.jl @@ -66,6 +66,9 @@ end @testset "AnnotatedChar" begin chr = Base.AnnotatedChar('c') @test chr == Base.AnnotatedChar(chr.char, Pair{Symbol, Any}[]) + @test uppercase(chr) == Base.AnnotatedChar('C') + @test titlecase(chr) == Base.AnnotatedChar('C') + @test lowercase(Base.AnnotatedChar('C')) == chr str = Base.AnnotatedString("hmm", [(1:1, :attr => "h0h0"), (1:2, :attr => "h0m1"), (2:3, :attr => "m1m2")]) From e7ca87b325d8146f8870316832220163a1cc7ad5 Mon Sep 17 00:00:00 2001 From: KristofferC Date: Mon, 9 Sep 2024 13:07:08 +0200 Subject: [PATCH 11/22] Revert "Don't expose guard pages to malloc_stack API consumers (#54591)" This reverts commit 5dfd57d25c189f6d5558dac9499b45f8bb9b271d. --- src/gc-stacks.c | 30 +----------------------------- 1 file changed, 1 insertion(+), 29 deletions(-) diff --git a/src/gc-stacks.c b/src/gc-stacks.c index 3f40e2fc15d81..82094035349b3 100644 --- a/src/gc-stacks.c +++ b/src/gc-stacks.c @@ -22,22 +22,13 @@ // number of stacks to always keep available per pool #define MIN_STACK_MAPPINGS_PER_POOL 5 -#if defined(_OS_WINDOWS_) || (!defined(_OS_OPENBSD_) && !defined(JL_HAVE_UCONTEXT) && !defined(JL_HAVE_SIGALTSTACK)) -#define JL_USE_GUARD_PAGE 1 const size_t jl_guard_size = (4096 * 8); -#else -const size_t jl_guard_size = 0; -#endif - static _Atomic(uint32_t) num_stack_mappings = 0; #ifdef _OS_WINDOWS_ #define MAP_FAILED NULL static void *malloc_stack(size_t bufsz) JL_NOTSAFEPOINT { - size_t guard_size = LLT_ALIGN(jl_guard_size, jl_page_size); - bufsz += guard_size; - void *stk = VirtualAlloc(NULL, bufsz, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE); if (stk == NULL) return MAP_FAILED; @@ -46,7 +37,6 @@ static void *malloc_stack(size_t bufsz) JL_NOTSAFEPOINT VirtualFree(stk, 0, MEM_RELEASE); return MAP_FAILED; } - stk = (char *)stk + guard_size; jl_atomic_fetch_add(&num_stack_mappings, 1); return stk; @@ -55,12 +45,6 @@ static void *malloc_stack(size_t bufsz) JL_NOTSAFEPOINT static void free_stack(void *stkbuf, size_t bufsz) { -#ifdef JL_USE_GUARD_PAGE - size_t guard_size = LLT_ALIGN(jl_guard_size, jl_page_size); - bufsz += guard_size; - stkbuf = (char *)stkbuf - guard_size; -#endif - VirtualFree(stkbuf, 0, MEM_RELEASE); jl_atomic_fetch_add(&num_stack_mappings, -1); } @@ -69,22 +53,16 @@ static void free_stack(void *stkbuf, size_t bufsz) static void *malloc_stack(size_t bufsz) JL_NOTSAFEPOINT { -#ifdef JL_USE_GUARD_PAGE - size_t guard_size = LLT_ALIGN(jl_guard_size, jl_page_size); - bufsz += guard_size; -#endif - void* stk = mmap(0, bufsz, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); if (stk == MAP_FAILED) return MAP_FAILED; -#ifdef JL_USE_GUARD_PAGE +#if !defined(JL_HAVE_UCONTEXT) && !defined(JL_HAVE_SIGALTSTACK) // set up a guard page to detect stack overflow if (mprotect(stk, jl_guard_size, PROT_NONE) == -1) { munmap(stk, bufsz); return MAP_FAILED; } - stk = (char *)stk + guard_size; #endif jl_atomic_fetch_add(&num_stack_mappings, 1); return stk; @@ -92,12 +70,6 @@ static void *malloc_stack(size_t bufsz) JL_NOTSAFEPOINT static void free_stack(void *stkbuf, size_t bufsz) { -#ifdef JL_USE_GUARD_PAGE - size_t guard_size = LLT_ALIGN(jl_guard_size, jl_page_size); - bufsz += guard_size; - stkbuf = (char *)stkbuf - guard_size; -#endif - munmap(stkbuf, bufsz); jl_atomic_fetch_add(&num_stack_mappings, -1); } From 287847936f9c952c6cdbf87fa5ecbbbbd4d1f605 Mon Sep 17 00:00:00 2001 From: Jishnu Bhattacharya Date: Mon, 2 Sep 2024 20:12:39 +0530 Subject: [PATCH 12/22] Reroute Symmetric/Hermitian + Diagonal through triangular (#55605) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This should fix the `Diagonal`-related issue from https://github.com/JuliaLang/julia/issues/55590, although the `SymTridiagonal` one still remains. ```julia julia> using LinearAlgebra julia> a = Matrix{BigFloat}(undef, 2,2) 2×2 Matrix{BigFloat}: #undef #undef #undef #undef julia> a[1] = 1; a[3] = 1; a[4] = 1 1 julia> a = Hermitian(a) 2×2 Hermitian{BigFloat, Matrix{BigFloat}}: 1.0 1.0 1.0 1.0 julia> b = Symmetric(a) 2×2 Symmetric{BigFloat, Matrix{BigFloat}}: 1.0 1.0 1.0 1.0 julia> c = Diagonal([1,1]) 2×2 Diagonal{Int64, Vector{Int64}}: 1 ⋅ ⋅ 1 julia> a+c 2×2 Hermitian{BigFloat, Matrix{BigFloat}}: 2.0 1.0 1.0 2.0 julia> b+c 2×2 Symmetric{BigFloat, Matrix{BigFloat}}: 2.0 1.0 1.0 2.0 ``` (cherry picked from commit 39f2ad1e941fd092b906d60e8d23c004e8ee5b7e) --- stdlib/LinearAlgebra/src/diagonal.jl | 15 --------------- stdlib/LinearAlgebra/src/special.jl | 19 +++++++++++++++++++ stdlib/LinearAlgebra/test/special.jl | 13 +++++++++++++ 3 files changed, 32 insertions(+), 15 deletions(-) diff --git a/stdlib/LinearAlgebra/src/diagonal.jl b/stdlib/LinearAlgebra/src/diagonal.jl index d27da450205f7..bea8183546d90 100644 --- a/stdlib/LinearAlgebra/src/diagonal.jl +++ b/stdlib/LinearAlgebra/src/diagonal.jl @@ -250,21 +250,6 @@ end (+)(Da::Diagonal, Db::Diagonal) = Diagonal(Da.diag + Db.diag) (-)(Da::Diagonal, Db::Diagonal) = Diagonal(Da.diag - Db.diag) -for f in (:+, :-) - @eval function $f(D::Diagonal{<:Number}, S::Symmetric) - return Symmetric($f(D, S.data), sym_uplo(S.uplo)) - end - @eval function $f(S::Symmetric, D::Diagonal{<:Number}) - return Symmetric($f(S.data, D), sym_uplo(S.uplo)) - end - @eval function $f(D::Diagonal{<:Real}, H::Hermitian) - return Hermitian($f(D, H.data), sym_uplo(H.uplo)) - end - @eval function $f(H::Hermitian, D::Diagonal{<:Real}) - return Hermitian($f(H.data, D), sym_uplo(H.uplo)) - end -end - (*)(x::Number, D::Diagonal) = Diagonal(x * D.diag) (*)(D::Diagonal, x::Number) = Diagonal(D.diag * x) (/)(D::Diagonal, x::Number) = Diagonal(D.diag / x) diff --git a/stdlib/LinearAlgebra/src/special.jl b/stdlib/LinearAlgebra/src/special.jl index 1363708fb515f..2a3b6bf2a8e00 100644 --- a/stdlib/LinearAlgebra/src/special.jl +++ b/stdlib/LinearAlgebra/src/special.jl @@ -264,6 +264,25 @@ function (-)(A::UniformScaling, B::Diagonal) Diagonal(Ref(A) .- B.diag) end +for f in (:+, :-) + @eval function $f(D::Diagonal{<:Number}, S::Symmetric) + uplo = sym_uplo(S.uplo) + return Symmetric(parentof_applytri($f, Symmetric(D, uplo), S), uplo) + end + @eval function $f(S::Symmetric, D::Diagonal{<:Number}) + uplo = sym_uplo(S.uplo) + return Symmetric(parentof_applytri($f, S, Symmetric(D, uplo)), uplo) + end + @eval function $f(D::Diagonal{<:Real}, H::Hermitian) + uplo = sym_uplo(H.uplo) + return Hermitian(parentof_applytri($f, Hermitian(D, uplo), H), uplo) + end + @eval function $f(H::Hermitian, D::Diagonal{<:Real}) + uplo = sym_uplo(H.uplo) + return Hermitian(parentof_applytri($f, H, Hermitian(D, uplo)), uplo) + end +end + ## Diagonal construction from UniformScaling Diagonal{T}(s::UniformScaling, m::Integer) where {T} = Diagonal{T}(fill(T(s.λ), m)) Diagonal(s::UniformScaling, m::Integer) = Diagonal{eltype(s)}(s, m) diff --git a/stdlib/LinearAlgebra/test/special.jl b/stdlib/LinearAlgebra/test/special.jl index 7e96af369e310..148ccd85efeb1 100644 --- a/stdlib/LinearAlgebra/test/special.jl +++ b/stdlib/LinearAlgebra/test/special.jl @@ -536,4 +536,17 @@ end @test v * S isa Matrix end +@testset "Partly filled Hermitian and Diagonal algebra" begin + D = Diagonal([1,2]) + for S in (Symmetric, Hermitian), uplo in (:U, :L) + M = Matrix{BigInt}(undef, 2, 2) + M[1,1] = M[2,2] = M[1+(uplo == :L), 1 + (uplo == :U)] = 3 + H = S(M, uplo) + HM = Matrix(H) + @test H + D == D + H == HM + D + @test H - D == HM - D + @test D - H == D - HM + end +end + end # module TestSpecial From 26440bd4467c900c08a4fef97211037fdb839407 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1ll=20Haraldsson?= Date: Mon, 9 Sep 2024 17:57:18 +0000 Subject: [PATCH 13/22] Add precompile signatures to Markdown to reduce latency. (#55715) Fixes #55706 that is seemingly a 4472x regression, not just 16x (was my first guess, based on CondaPkg, also fixes or greatly mitigates https://github.com/JuliaPy/CondaPkg.jl/issues/145), and large part of 3x regression for PythonCall. --------- Co-authored-by: Kristoffer Carlsson (cherry picked from commit 1463c9991c4a75730e4d6822313180ca323241c0) --- stdlib/Markdown/src/Markdown.jl | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/stdlib/Markdown/src/Markdown.jl b/stdlib/Markdown/src/Markdown.jl index 93d8dbc39fc59..e8c64deb3d593 100644 --- a/stdlib/Markdown/src/Markdown.jl +++ b/stdlib/Markdown/src/Markdown.jl @@ -98,4 +98,25 @@ import Base.Docs: catdoc catdoc(md::MD...) = MD(md...) +if Base.generating_output() + # workload to reduce latency + md""" + # H1 + ## H2 + ### H3 + **bold text** + *italicized text* + > blockquote + 1. First item + 2. Second item + 3. Third item + - First item + - Second item + - Third item + `code` + Horizontal Rule + --- + """ +end + end From b702d7611bc98bcc3d08475a01322fb4564d4b1a Mon Sep 17 00:00:00 2001 From: Nathan Zimmerberg <39104088+nhz2@users.noreply.github.com> Date: Mon, 9 Sep 2024 14:23:38 -0400 Subject: [PATCH 14/22] Fix invalidations for FileIO (#55593) Fixes https://github.com/JuliaIO/FileIO.jl/issues/396 (cherry picked from commit 68feddc7c89b7f328eb72e336c7dbe51ac47b626) --- base/strings/io.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/base/strings/io.jl b/base/strings/io.jl index 97cdedac3db78..4e413c0ebd78c 100644 --- a/base/strings/io.jl +++ b/base/strings/io.jl @@ -365,7 +365,8 @@ function _join_preserve_annotations(iterator, args...) # in nature, we extract an `AnnotatedString`, otherwise we just extract # a plain `String` from `io`. if isconcretetype(et) || !isempty(io.annotations) - read(seekstart(io), AnnotatedString{String}) + seekstart(io) + read(io, AnnotatedString{String}) else String(take!(io.io)) end From 6270b903719ce4a236825debee9b63422b2cae0e Mon Sep 17 00:00:00 2001 From: Ian Butterworth Date: Tue, 10 Sep 2024 07:33:56 -0400 Subject: [PATCH 15/22] Fix `@time_imports` extension recognition (#55718) (cherry picked from commit d2807927656efe2bfbfe4402f83e2ea417306db2) --- base/loading.jl | 41 ++++++++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/base/loading.jl b/base/loading.jl index 5614c3603e540..6436f15a3ac16 100644 --- a/base/loading.jl +++ b/base/loading.jl @@ -1152,7 +1152,7 @@ const TIMING_IMPORTS = Threads.Atomic{Int}(0) # these return either the array of modules loaded from the path / content given # or an Exception that describes why it couldn't be loaded # and it reconnects the Base.Docs.META -function _include_from_serialized(pkg::PkgId, path::String, ocachepath::Union{Nothing, String}, depmods::Vector{Any}, ignore_native::Union{Nothing,Bool}=nothing) +function _include_from_serialized(pkg::PkgId, path::String, ocachepath::Union{Nothing, String}, depmods::Vector{Any}, ignore_native::Union{Nothing,Bool}=nothing; register::Bool=true) if isnothing(ignore_native) if JLOptions().code_coverage == 0 && JLOptions().malloc_log == 0 ignore_native = false @@ -1201,13 +1201,14 @@ function _include_from_serialized(pkg::PkgId, path::String, ocachepath::Union{No for M in restored M = M::Module if parentmodule(M) === M && PkgId(M) == pkg + register && register_root_module(M) if timing_imports elapsed = round((time_ns() - t_before) / 1e6, digits = 1) comp_time, recomp_time = cumulative_compile_time_ns() .- t_comp_before print(lpad(elapsed, 9), " ms ") - parentid = get(EXT_PRIMED, pkg, nothing) - if parentid !== nothing - print(parentid.name, " → ") + ext_parent = extension_parent_name(M) + if ext_parent !== nothing + print(ext_parent::String, " → ") end print(pkg.name) if comp_time > 0 @@ -1229,6 +1230,27 @@ function _include_from_serialized(pkg::PkgId, path::String, ocachepath::Union{No end end +# if M is an extension, return the string name of the parent. Otherwise return nothing +function extension_parent_name(M::Module) + rootmodule = moduleroot(M) + src_path = pathof(rootmodule) + src_path === nothing && return nothing + pkgdir_parts = splitpath(src_path) + ext_pos = findlast(==("ext"), pkgdir_parts) + if ext_pos !== nothing && ext_pos >= length(pkgdir_parts) - 2 + parent_package_root = joinpath(pkgdir_parts[1:ext_pos-1]...) + parent_package_project_file = locate_project_file(parent_package_root) + if parent_package_project_file isa String + d = parsed_toml(parent_package_project_file) + name = get(d, "name", nothing) + if name !== nothing + return name + end + end + end + return nothing +end + function register_restored_modules(sv::SimpleVector, pkg::PkgId, path::String) # This function is also used by PkgCacheInspector.jl restored = sv[1]::Vector{Any} @@ -1403,7 +1425,7 @@ function _insert_extension_triggers(parent::PkgId, extensions::Dict{String, Any} triggers = triggers::Union{String, Vector{String}} triggers isa String && (triggers = [triggers]) id = PkgId(uuid5(parent.uuid::UUID, ext), ext) - if id in keys(EXT_PRIMED) || haskey(Base.loaded_modules, id) + if haskey(EXT_PRIMED, id) || haskey(Base.loaded_modules, id) continue # extension is already primed or loaded, don't add it again end EXT_PRIMED[id] = parent @@ -1833,8 +1855,7 @@ function _tryrequire_from_serialized(pkg::PkgId, path::String, ocachepath::Union depmods[i] = dep end # then load the file - loaded = _include_from_serialized(pkg, path, ocachepath, depmods, ignore_native) - loaded isa Module && register_root_module(loaded) + loaded = _include_from_serialized(pkg, path, ocachepath, depmods, ignore_native; register = true) return loaded end @@ -1901,8 +1922,7 @@ end if dep === nothing try set_pkgorigin_version_path(modkey, modpath) - dep = _include_from_serialized(modkey, modcachepath, modocachepath, modstaledeps) - dep isa Module && stalecheck && register_root_module(dep) + dep = _include_from_serialized(modkey, modcachepath, modocachepath, modstaledeps; register = stalecheck) finally end_loading(modkey, dep) end @@ -1918,9 +1938,8 @@ end end restored = get(loaded_precompiles, pkg => newbuild_id, nothing) if !isa(restored, Module) - restored = _include_from_serialized(pkg, path_to_try, ocachefile, staledeps) + restored = _include_from_serialized(pkg, path_to_try, ocachefile, staledeps; register = stalecheck) end - isa(restored, Module) && stalecheck && register_root_module(restored) isa(restored, Module) && return restored @debug "Deserialization checks failed while attempting to load cache from $path_to_try" exception=restored @label check_next_path From b86812d127e9477b7580bf3d85befc04de95fe75 Mon Sep 17 00:00:00 2001 From: Ian Butterworth Date: Mon, 9 Sep 2024 21:01:08 -0400 Subject: [PATCH 16/22] Fix `pkgdir` for extensions (#55720) Fixes https://github.com/JuliaLang/julia/issues/55719 --------- Co-authored-by: Max Horn <241512+fingolfin@users.noreply.github.com> (cherry picked from commit 99b8868ff563eded17376b3f90ffc1637222f2c6) --- base/loading.jl | 16 +++++++++++++++- test/loading.jl | 17 +++++++++++++++-- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/base/loading.jl b/base/loading.jl index 6436f15a3ac16..43ffb2cf52ca2 100644 --- a/base/loading.jl +++ b/base/loading.jl @@ -507,6 +507,8 @@ package root. To get the root directory of the package that implements the current module the form `pkgdir(@__MODULE__)` can be used. +If an extension module is given, the root of the parent package is returned. + ```julia-repl julia> pkgdir(Foo) "/path/to/Foo.jl" @@ -524,7 +526,19 @@ function pkgdir(m::Module, paths::String...) rootmodule = moduleroot(m) path = pathof(rootmodule) path === nothing && return nothing - return joinpath(dirname(dirname(path)), paths...) + original = path + path, base = splitdir(dirname(path)) + if base == "src" + # package source in `../src/Foo.jl` + elseif base == "ext" + # extension source in `../ext/FooExt.jl` + elseif basename(path) == "ext" + # extension source in `../ext/FooExt/FooExt.jl` + path = dirname(path) + else + error("Unexpected path structure for module source: $original") + end + return joinpath(path, paths...) end function get_pkgversion_from_path(path) diff --git a/test/loading.jl b/test/loading.jl index 9207294a205b5..71d0b07b64376 100644 --- a/test/loading.jl +++ b/test/loading.jl @@ -1034,6 +1034,16 @@ end end @testset "Extensions" begin + test_ext = """ + function test_ext(parent::Module, ext::Symbol) + _ext = Base.get_extension(parent, ext) + _ext isa Module || error("expected extension \$ext to be loaded") + _pkgdir = pkgdir(_ext) + _pkgdir == pkgdir(parent) != nothing || error("unexpected extension \$ext pkgdir path: \$_pkgdir") + _pkgversion = pkgversion(_ext) + _pkgversion == pkgversion(parent) || error("unexpected extension \$ext version: \$_pkgversion") + end + """ depot_path = mktempdir() try proj = joinpath(@__DIR__, "project", "Extensions", "HasDepWithExtensions.jl") @@ -1044,6 +1054,7 @@ end cmd = """ $load_distr begin + $ew $test_ext $ew push!(empty!(DEPOT_PATH), $(repr(depot_path))) using HasExtensions $ew using HasExtensions @@ -1051,6 +1062,7 @@ end $ew HasExtensions.ext_loaded && error("ext_loaded set") using HasDepWithExtensions $ew using HasDepWithExtensions + $ew test_ext(HasExtensions, :Extension) $ew Base.get_extension(HasExtensions, :Extension).extvar == 1 || error("extvar in Extension not set") $ew HasExtensions.ext_loaded || error("ext_loaded not set") $ew HasExtensions.ext_folder_loaded && error("ext_folder_loaded set") @@ -1100,11 +1112,12 @@ end test_ext_proj = """ begin + $test_ext using HasExtensions using ExtDep - Base.get_extension(HasExtensions, :Extension) isa Module || error("expected extension to load") + test_ext(HasExtensions, :Extension) using ExtDep2 - Base.get_extension(HasExtensions, :ExtensionFolder) isa Module || error("expected extension to load") + test_ext(HasExtensions, :ExtensionFolder) end """ for compile in (`--compiled-modules=no`, ``) From f09de94afb0c574f84274c746624df2ed840847d Mon Sep 17 00:00:00 2001 From: KristofferC Date: Wed, 11 Sep 2024 14:16:55 +0200 Subject: [PATCH 17/22] Revert "Reroute Symmetric/Hermitian + Diagonal through triangular (#55605)" This reverts commit 287847936f9c952c6cdbf87fa5ecbbbbd4d1f605. --- stdlib/LinearAlgebra/src/diagonal.jl | 15 +++++++++++++++ stdlib/LinearAlgebra/src/special.jl | 19 ------------------- stdlib/LinearAlgebra/test/special.jl | 13 ------------- 3 files changed, 15 insertions(+), 32 deletions(-) diff --git a/stdlib/LinearAlgebra/src/diagonal.jl b/stdlib/LinearAlgebra/src/diagonal.jl index bea8183546d90..d27da450205f7 100644 --- a/stdlib/LinearAlgebra/src/diagonal.jl +++ b/stdlib/LinearAlgebra/src/diagonal.jl @@ -250,6 +250,21 @@ end (+)(Da::Diagonal, Db::Diagonal) = Diagonal(Da.diag + Db.diag) (-)(Da::Diagonal, Db::Diagonal) = Diagonal(Da.diag - Db.diag) +for f in (:+, :-) + @eval function $f(D::Diagonal{<:Number}, S::Symmetric) + return Symmetric($f(D, S.data), sym_uplo(S.uplo)) + end + @eval function $f(S::Symmetric, D::Diagonal{<:Number}) + return Symmetric($f(S.data, D), sym_uplo(S.uplo)) + end + @eval function $f(D::Diagonal{<:Real}, H::Hermitian) + return Hermitian($f(D, H.data), sym_uplo(H.uplo)) + end + @eval function $f(H::Hermitian, D::Diagonal{<:Real}) + return Hermitian($f(H.data, D), sym_uplo(H.uplo)) + end +end + (*)(x::Number, D::Diagonal) = Diagonal(x * D.diag) (*)(D::Diagonal, x::Number) = Diagonal(D.diag * x) (/)(D::Diagonal, x::Number) = Diagonal(D.diag / x) diff --git a/stdlib/LinearAlgebra/src/special.jl b/stdlib/LinearAlgebra/src/special.jl index 2a3b6bf2a8e00..1363708fb515f 100644 --- a/stdlib/LinearAlgebra/src/special.jl +++ b/stdlib/LinearAlgebra/src/special.jl @@ -264,25 +264,6 @@ function (-)(A::UniformScaling, B::Diagonal) Diagonal(Ref(A) .- B.diag) end -for f in (:+, :-) - @eval function $f(D::Diagonal{<:Number}, S::Symmetric) - uplo = sym_uplo(S.uplo) - return Symmetric(parentof_applytri($f, Symmetric(D, uplo), S), uplo) - end - @eval function $f(S::Symmetric, D::Diagonal{<:Number}) - uplo = sym_uplo(S.uplo) - return Symmetric(parentof_applytri($f, S, Symmetric(D, uplo)), uplo) - end - @eval function $f(D::Diagonal{<:Real}, H::Hermitian) - uplo = sym_uplo(H.uplo) - return Hermitian(parentof_applytri($f, Hermitian(D, uplo), H), uplo) - end - @eval function $f(H::Hermitian, D::Diagonal{<:Real}) - uplo = sym_uplo(H.uplo) - return Hermitian(parentof_applytri($f, H, Hermitian(D, uplo)), uplo) - end -end - ## Diagonal construction from UniformScaling Diagonal{T}(s::UniformScaling, m::Integer) where {T} = Diagonal{T}(fill(T(s.λ), m)) Diagonal(s::UniformScaling, m::Integer) = Diagonal{eltype(s)}(s, m) diff --git a/stdlib/LinearAlgebra/test/special.jl b/stdlib/LinearAlgebra/test/special.jl index 148ccd85efeb1..7e96af369e310 100644 --- a/stdlib/LinearAlgebra/test/special.jl +++ b/stdlib/LinearAlgebra/test/special.jl @@ -536,17 +536,4 @@ end @test v * S isa Matrix end -@testset "Partly filled Hermitian and Diagonal algebra" begin - D = Diagonal([1,2]) - for S in (Symmetric, Hermitian), uplo in (:U, :L) - M = Matrix{BigInt}(undef, 2, 2) - M[1,1] = M[2,2] = M[1+(uplo == :L), 1 + (uplo == :U)] = 3 - H = S(M, uplo) - HM = Matrix(H) - @test H + D == D + H == HM + D - @test H - D == HM - D - @test D - H == D - HM - end -end - end # module TestSpecial From 4ab4722b6ee18009ea7f2fce4a63711a1efcd148 Mon Sep 17 00:00:00 2001 From: Jishnu Bhattacharya Date: Thu, 12 Sep 2024 15:12:07 +0530 Subject: [PATCH 18/22] Reland "Reroute Symmetric/Hermitian + Diagonal through triangular" This backports the following commits: commit 9690961c426ce2640d7db6c89952e69f87873a93 Author: Jishnu Bhattacharya Date: Mon Apr 29 21:43:31 2024 +0530 Add upper/lowertriangular functions and use in applytri (#53573) We may use the fact that a `Diagonal` is already triangular to avoid adding a wrapper. Fixes the specific example in https://github.com/JuliaLang/julia/issues/53564, although not the broader issue. This is because it changes the operation from a `UpperTriangular + UpperTriangular` to a `UpperTriangular + Diagonal`, which uses broadcasting. The latter operation may also allow one to define more efficient methods. commit 77821cdddb968eeabf31ccb6b214ccf59a604c68 Author: Jishnu Bhattacharya Date: Wed Aug 28 00:53:31 2024 +0530 Remove Diagonal-triangular specialization commit 621fb2e739a04207df63857700aca3562b41b5eb Author: Jishnu Bhattacharya Date: Wed Aug 28 00:50:49 2024 +0530 Restrict broadcasting to strided-diag Diagonal commit 58eb2045ddb5dbbfdb759c06239ca54751e73d71 Author: Jishnu Bhattacharya Date: Wed Aug 28 00:44:47 2024 +0530 Add tests for partly filled parent commit 5aa6080a580bfbc9453e94a06f3e379e4517b316 Author: Jishnu Bhattacharya Date: Tue Aug 27 20:42:07 2024 +0530 Reroute Symmetric/Hermitian + Diagonal through triangular --- stdlib/LinearAlgebra/src/diagonal.jl | 18 +++--------------- stdlib/LinearAlgebra/src/special.jl | 19 +++++++++++++++++++ stdlib/LinearAlgebra/src/symmetric.jl | 12 ++++++------ stdlib/LinearAlgebra/src/triangular.jl | 6 ++++++ stdlib/LinearAlgebra/test/diagonal.jl | 6 ++++++ stdlib/LinearAlgebra/test/special.jl | 13 +++++++++++++ stdlib/LinearAlgebra/test/symmetric.jl | 25 +++++++++++++++++++++++++ stdlib/LinearAlgebra/test/triangular.jl | 8 ++++++++ 8 files changed, 86 insertions(+), 21 deletions(-) diff --git a/stdlib/LinearAlgebra/src/diagonal.jl b/stdlib/LinearAlgebra/src/diagonal.jl index d27da450205f7..830332db0dbb1 100644 --- a/stdlib/LinearAlgebra/src/diagonal.jl +++ b/stdlib/LinearAlgebra/src/diagonal.jl @@ -250,21 +250,6 @@ end (+)(Da::Diagonal, Db::Diagonal) = Diagonal(Da.diag + Db.diag) (-)(Da::Diagonal, Db::Diagonal) = Diagonal(Da.diag - Db.diag) -for f in (:+, :-) - @eval function $f(D::Diagonal{<:Number}, S::Symmetric) - return Symmetric($f(D, S.data), sym_uplo(S.uplo)) - end - @eval function $f(S::Symmetric, D::Diagonal{<:Number}) - return Symmetric($f(S.data, D), sym_uplo(S.uplo)) - end - @eval function $f(D::Diagonal{<:Real}, H::Hermitian) - return Hermitian($f(D, H.data), sym_uplo(H.uplo)) - end - @eval function $f(H::Hermitian, D::Diagonal{<:Real}) - return Hermitian($f(H.data, D), sym_uplo(H.uplo)) - end -end - (*)(x::Number, D::Diagonal) = Diagonal(x * D.diag) (*)(D::Diagonal, x::Number) = Diagonal(D.diag * x) (/)(D::Diagonal, x::Number) = Diagonal(D.diag / x) @@ -991,3 +976,6 @@ end function Base.muladd(A::Diagonal, B::Diagonal, z::Diagonal) Diagonal(A.diag .* B.diag .+ z.diag) end + +uppertriangular(D::Diagonal) = D +lowertriangular(D::Diagonal) = D diff --git a/stdlib/LinearAlgebra/src/special.jl b/stdlib/LinearAlgebra/src/special.jl index 1363708fb515f..2a3b6bf2a8e00 100644 --- a/stdlib/LinearAlgebra/src/special.jl +++ b/stdlib/LinearAlgebra/src/special.jl @@ -264,6 +264,25 @@ function (-)(A::UniformScaling, B::Diagonal) Diagonal(Ref(A) .- B.diag) end +for f in (:+, :-) + @eval function $f(D::Diagonal{<:Number}, S::Symmetric) + uplo = sym_uplo(S.uplo) + return Symmetric(parentof_applytri($f, Symmetric(D, uplo), S), uplo) + end + @eval function $f(S::Symmetric, D::Diagonal{<:Number}) + uplo = sym_uplo(S.uplo) + return Symmetric(parentof_applytri($f, S, Symmetric(D, uplo)), uplo) + end + @eval function $f(D::Diagonal{<:Real}, H::Hermitian) + uplo = sym_uplo(H.uplo) + return Hermitian(parentof_applytri($f, Hermitian(D, uplo), H), uplo) + end + @eval function $f(H::Hermitian, D::Diagonal{<:Real}) + uplo = sym_uplo(H.uplo) + return Hermitian(parentof_applytri($f, H, Hermitian(D, uplo)), uplo) + end +end + ## Diagonal construction from UniformScaling Diagonal{T}(s::UniformScaling, m::Integer) where {T} = Diagonal{T}(fill(T(s.λ), m)) Diagonal(s::UniformScaling, m::Integer) = Diagonal{eltype(s)}(s, m) diff --git a/stdlib/LinearAlgebra/src/symmetric.jl b/stdlib/LinearAlgebra/src/symmetric.jl index 6f778629b51b7..8cc07566c109e 100644 --- a/stdlib/LinearAlgebra/src/symmetric.jl +++ b/stdlib/LinearAlgebra/src/symmetric.jl @@ -277,21 +277,21 @@ diag(A::Hermitian) = hermitian.(diag(parent(A)), sym_uplo(A.uplo)) function applytri(f, A::HermOrSym) if A.uplo == 'U' - f(UpperTriangular(A.data)) + f(uppertriangular(A.data)) else - f(LowerTriangular(A.data)) + f(lowertriangular(A.data)) end end function applytri(f, A::HermOrSym, B::HermOrSym) if A.uplo == B.uplo == 'U' - f(UpperTriangular(A.data), UpperTriangular(B.data)) + f(uppertriangular(A.data), uppertriangular(B.data)) elseif A.uplo == B.uplo == 'L' - f(LowerTriangular(A.data), LowerTriangular(B.data)) + f(lowertriangular(A.data), lowertriangular(B.data)) elseif A.uplo == 'U' - f(UpperTriangular(A.data), UpperTriangular(_conjugation(B)(B.data))) + f(uppertriangular(A.data), uppertriangular(_conjugation(B)(B.data))) else # A.uplo == 'L' - f(UpperTriangular(_conjugation(A)(A.data)), UpperTriangular(B.data)) + f(uppertriangular(_conjugation(A)(A.data)), uppertriangular(B.data)) end end parentof_applytri(f, args...) = applytri(parent ∘ f, args...) diff --git a/stdlib/LinearAlgebra/src/triangular.jl b/stdlib/LinearAlgebra/src/triangular.jl index 0cd5a49a0956d..fb9f6b2df9121 100644 --- a/stdlib/LinearAlgebra/src/triangular.jl +++ b/stdlib/LinearAlgebra/src/triangular.jl @@ -153,6 +153,12 @@ const UpperOrUnitUpperTriangular{T,S} = Union{UpperTriangular{T,S}, UnitUpperTri const LowerOrUnitLowerTriangular{T,S} = Union{LowerTriangular{T,S}, UnitLowerTriangular{T,S}} const UpperOrLowerTriangular{T,S} = Union{UpperOrUnitUpperTriangular{T,S}, LowerOrUnitLowerTriangular{T,S}} +uppertriangular(M) = UpperTriangular(M) +lowertriangular(M) = LowerTriangular(M) + +uppertriangular(U::UpperOrUnitUpperTriangular) = U +lowertriangular(U::LowerOrUnitLowerTriangular) = U + imag(A::UpperTriangular) = UpperTriangular(imag(A.data)) imag(A::LowerTriangular) = LowerTriangular(imag(A.data)) imag(A::UpperTriangular{<:Any,<:StridedMaybeAdjOrTransMat}) = imag.(A) diff --git a/stdlib/LinearAlgebra/test/diagonal.jl b/stdlib/LinearAlgebra/test/diagonal.jl index fd4ebfb714a37..7049dd784faa8 100644 --- a/stdlib/LinearAlgebra/test/diagonal.jl +++ b/stdlib/LinearAlgebra/test/diagonal.jl @@ -1277,6 +1277,12 @@ end @test c == Diagonal([2,2,2,2]) end +@testset "uppertriangular/lowertriangular" begin + D = Diagonal([1,2]) + @test LinearAlgebra.uppertriangular(D) === D + @test LinearAlgebra.lowertriangular(D) === D +end + @testset "mul/div with an adjoint vector" begin A = [1.0;;] x = [1.0] diff --git a/stdlib/LinearAlgebra/test/special.jl b/stdlib/LinearAlgebra/test/special.jl index 7e96af369e310..148ccd85efeb1 100644 --- a/stdlib/LinearAlgebra/test/special.jl +++ b/stdlib/LinearAlgebra/test/special.jl @@ -536,4 +536,17 @@ end @test v * S isa Matrix end +@testset "Partly filled Hermitian and Diagonal algebra" begin + D = Diagonal([1,2]) + for S in (Symmetric, Hermitian), uplo in (:U, :L) + M = Matrix{BigInt}(undef, 2, 2) + M[1,1] = M[2,2] = M[1+(uplo == :L), 1 + (uplo == :U)] = 3 + H = S(M, uplo) + HM = Matrix(H) + @test H + D == D + H == HM + D + @test H - D == HM - D + @test D - H == D - HM + end +end + end # module TestSpecial diff --git a/stdlib/LinearAlgebra/test/symmetric.jl b/stdlib/LinearAlgebra/test/symmetric.jl index 23556c6548742..25522042dcf2b 100644 --- a/stdlib/LinearAlgebra/test/symmetric.jl +++ b/stdlib/LinearAlgebra/test/symmetric.jl @@ -507,6 +507,31 @@ end @test Su - Sl == -(Sl - Su) == MSu - MSl end end + @testset "non-strided" begin + @testset "diagonal" begin + for ST1 in (Symmetric, Hermitian), uplo1 in (:L, :U) + m = ST1(Matrix{BigFloat}(undef,2,2), uplo1) + m.data[1,1] = 1 + m.data[2,2] = 3 + m.data[1+(uplo1==:L), 1+(uplo1==:U)] = 2 + A = Array(m) + for ST2 in (Symmetric, Hermitian), uplo2 in (:L, :U) + id = ST2(I(2), uplo2) + @test m + id == id + m == A + id + end + end + end + @testset "unit triangular" begin + for ST1 in (Symmetric, Hermitian), uplo1 in (:L, :U) + H1 = ST1(UnitUpperTriangular(big.(rand(Int8,4,4))), uplo1) + M1 = Matrix(H1) + for ST2 in (Symmetric, Hermitian), uplo2 in (:L, :U) + H2 = ST2(UnitUpperTriangular(big.(rand(Int8,4,4))), uplo2) + @test H1 + H2 == M1 + Matrix(H2) + end + end + end + end end # bug identified in PR #52318: dot products of quaternionic Hermitian matrices, diff --git a/stdlib/LinearAlgebra/test/triangular.jl b/stdlib/LinearAlgebra/test/triangular.jl index 98334639c11e9..f37bf05650452 100644 --- a/stdlib/LinearAlgebra/test/triangular.jl +++ b/stdlib/LinearAlgebra/test/triangular.jl @@ -996,6 +996,14 @@ end end end +@testset "uppertriangular/lowertriangular" begin + M = rand(2,2) + @test LinearAlgebra.uppertriangular(M) === UpperTriangular(M) + @test LinearAlgebra.lowertriangular(M) === LowerTriangular(M) + @test LinearAlgebra.uppertriangular(UnitUpperTriangular(M)) === UnitUpperTriangular(M) + @test LinearAlgebra.lowertriangular(UnitLowerTriangular(M)) === UnitLowerTriangular(M) +end + @testset "arithmetic with partly uninitialized matrices" begin @testset "$(typeof(A))" for A in (Matrix{BigFloat}(undef,2,2), Matrix{Complex{BigFloat}}(undef,2,2)') A[2,1] = eltype(A) <: Complex ? 4 + 3im : 4 From 65c1ecbc2ab875afa780c4cccab488284b09d4af Mon Sep 17 00:00:00 2001 From: Kristoffer Carlsson Date: Thu, 12 Sep 2024 11:23:53 +0200 Subject: [PATCH 19/22] bump to latest Pkg 1.11 --- .../Pkg-2ff691035e9b2780cbd2fcb8dd30b640d85edde2.tar.gz/md5 | 1 - .../Pkg-2ff691035e9b2780cbd2fcb8dd30b640d85edde2.tar.gz/sha512 | 1 - .../Pkg-69938284d6804dd30a24577397f52dfdedbd37e1.tar.gz/md5 | 1 + .../Pkg-69938284d6804dd30a24577397f52dfdedbd37e1.tar.gz/sha512 | 1 + stdlib/Pkg.version | 2 +- 5 files changed, 3 insertions(+), 3 deletions(-) delete mode 100644 deps/checksums/Pkg-2ff691035e9b2780cbd2fcb8dd30b640d85edde2.tar.gz/md5 delete mode 100644 deps/checksums/Pkg-2ff691035e9b2780cbd2fcb8dd30b640d85edde2.tar.gz/sha512 create mode 100644 deps/checksums/Pkg-69938284d6804dd30a24577397f52dfdedbd37e1.tar.gz/md5 create mode 100644 deps/checksums/Pkg-69938284d6804dd30a24577397f52dfdedbd37e1.tar.gz/sha512 diff --git a/deps/checksums/Pkg-2ff691035e9b2780cbd2fcb8dd30b640d85edde2.tar.gz/md5 b/deps/checksums/Pkg-2ff691035e9b2780cbd2fcb8dd30b640d85edde2.tar.gz/md5 deleted file mode 100644 index fe1a6a5d418b4..0000000000000 --- a/deps/checksums/Pkg-2ff691035e9b2780cbd2fcb8dd30b640d85edde2.tar.gz/md5 +++ /dev/null @@ -1 +0,0 @@ -6f6793bcb797bfd2c48f52c631ce9479 diff --git a/deps/checksums/Pkg-2ff691035e9b2780cbd2fcb8dd30b640d85edde2.tar.gz/sha512 b/deps/checksums/Pkg-2ff691035e9b2780cbd2fcb8dd30b640d85edde2.tar.gz/sha512 deleted file mode 100644 index ea7ace0f5e812..0000000000000 --- a/deps/checksums/Pkg-2ff691035e9b2780cbd2fcb8dd30b640d85edde2.tar.gz/sha512 +++ /dev/null @@ -1 +0,0 @@ -70a9e47694082ab3f999891e03a932d1d43f9a700de1c7943d943f11c98d0893dafa9ed19f585dfe1af9aa053c5db1efde4af55c26b824632afa057ecb97f07a diff --git a/deps/checksums/Pkg-69938284d6804dd30a24577397f52dfdedbd37e1.tar.gz/md5 b/deps/checksums/Pkg-69938284d6804dd30a24577397f52dfdedbd37e1.tar.gz/md5 new file mode 100644 index 0000000000000..12ef870b31933 --- /dev/null +++ b/deps/checksums/Pkg-69938284d6804dd30a24577397f52dfdedbd37e1.tar.gz/md5 @@ -0,0 +1 @@ +248ce4c4b85394431e71b6f555f82216 diff --git a/deps/checksums/Pkg-69938284d6804dd30a24577397f52dfdedbd37e1.tar.gz/sha512 b/deps/checksums/Pkg-69938284d6804dd30a24577397f52dfdedbd37e1.tar.gz/sha512 new file mode 100644 index 0000000000000..b51345f090447 --- /dev/null +++ b/deps/checksums/Pkg-69938284d6804dd30a24577397f52dfdedbd37e1.tar.gz/sha512 @@ -0,0 +1 @@ +84f193d72062199f2791ba7f7c2b6eb547e1a97569ae20cbb3557bc291715dd0cf55b2e121c4829b4572929e97255fd53b9210a168a7fde36f09ae6cf76c7f40 diff --git a/stdlib/Pkg.version b/stdlib/Pkg.version index 9c627070566a9..5729fc9f7c69d 100644 --- a/stdlib/Pkg.version +++ b/stdlib/Pkg.version @@ -1,4 +1,4 @@ PKG_BRANCH = release-1.11 -PKG_SHA1 = 2ff691035e9b2780cbd2fcb8dd30b640d85edde2 +PKG_SHA1 = 69938284d6804dd30a24577397f52dfdedbd37e1 PKG_GIT_URL := https://github.com/JuliaLang/Pkg.jl.git PKG_TAR_URL = https://api.github.com/repos/JuliaLang/Pkg.jl/tarball/$1 From 50c1ea848579ddc99e3c3633b85669988c2c89f2 Mon Sep 17 00:00:00 2001 From: Ian Butterworth Date: Wed, 11 Sep 2024 11:50:05 -0400 Subject: [PATCH 20/22] Precompile the `@time_imports` printing so it doesn't confuse reports (#55729) Makes functions for the report printing that can be precompiled into the sysimage. (cherry picked from commit 255162c7197e973d0427cc11d1e0117cdd76a1bf) --- base/loading.jl | 94 +++++++++++++++++++++------------- contrib/generate_precompile.jl | 9 ++++ 2 files changed, 66 insertions(+), 37 deletions(-) diff --git a/base/loading.jl b/base/loading.jl index 43ffb2cf52ca2..0262ace997a09 100644 --- a/base/loading.jl +++ b/base/loading.jl @@ -1217,22 +1217,9 @@ function _include_from_serialized(pkg::PkgId, path::String, ocachepath::Union{No if parentmodule(M) === M && PkgId(M) == pkg register && register_root_module(M) if timing_imports - elapsed = round((time_ns() - t_before) / 1e6, digits = 1) + elapsed_time = time_ns() - t_before comp_time, recomp_time = cumulative_compile_time_ns() .- t_comp_before - print(lpad(elapsed, 9), " ms ") - ext_parent = extension_parent_name(M) - if ext_parent !== nothing - print(ext_parent::String, " → ") - end - print(pkg.name) - if comp_time > 0 - printstyled(" ", Ryu.writefixed(Float64(100 * comp_time / (elapsed * 1e6)), 2), "% compilation time", color = Base.info_color()) - end - if recomp_time > 0 - perc = Float64(100 * recomp_time / comp_time) - printstyled(" (", perc < 1 ? "<1" : Ryu.writefixed(perc, 0), "% recompilation)", color = Base.warn_color()) - end - println() + print_time_imports_report(M, elapsed_time, comp_time, recomp_time) end return M end @@ -1244,6 +1231,52 @@ function _include_from_serialized(pkg::PkgId, path::String, ocachepath::Union{No end end +# printing functions for @time_imports +# note that the time inputs are UInt64 on all platforms. Give default values here so that we don't have +# confusing UInt64 types in generate_precompile.jl +function print_time_imports_report( + mod::Module, + elapsed_time::UInt64=UInt64(1), + comp_time::UInt64=UInt64(1), + recomp_time::UInt64=UInt64(1) + ) + print(lpad(round(elapsed_time / 1e6, digits=1), 9), " ms ") + ext_parent = extension_parent_name(mod) + if ext_parent !== nothing + print(ext_parent::String, " → ") + end + print(string(mod)) + if comp_time > 0 + perc = Ryu.writefixed(Float64(100 * comp_time / (elapsed_time)), 2) + printstyled(" $perc% compilation time", color = Base.info_color()) + end + if recomp_time > 0 + perc = Float64(100 * recomp_time / comp_time) + perc_show = perc < 1 ? "<1" : Ryu.writefixed(perc, 0) + printstyled(" ($perc_show% recompilation)", color = Base.warn_color()) + end + println() +end +function print_time_imports_report_init( + mod::Module, i::Int=1, + elapsed_time::UInt64=UInt64(1), + comp_time::UInt64=UInt64(1), + recomp_time::UInt64=UInt64(1) + ) + connector = i > 1 ? "├" : "┌" + printstyled(" $connector ", color = :light_black) + print("$(round(elapsed_time / 1e6, digits=1)) ms $mod.__init__() ") + if comp_time > 0 + perc = Ryu.writefixed(Float64(100 * (comp_time) / elapsed_time), 2) + printstyled("$perc% compilation time", color = Base.info_color()) + end + if recomp_time > 0 + perc = Float64(100 * recomp_time / comp_time) + printstyled(" ($(perc < 1 ? "<1" : Ryu.writefixed(perc, 0))% recompilation)", color = Base.warn_color()) + end + println() +end + # if M is an extension, return the string name of the parent. Otherwise return nothing function extension_parent_name(M::Module) rootmodule = moduleroot(M) @@ -1301,31 +1334,18 @@ function run_module_init(mod::Module, i::Int=1) # `i` informs ordering for the `@time_imports` report formatting if TIMING_IMPORTS[] == 0 ccall(:jl_init_restored_module, Cvoid, (Any,), mod) - else - if isdefined(mod, :__init__) - connector = i > 1 ? "├" : "┌" - printstyled(" $connector ", color = :light_black) - - elapsedtime = time_ns() - cumulative_compile_timing(true) - compile_elapsedtimes = cumulative_compile_time_ns() + elseif isdefined(mod, :__init__) + elapsed_time = time_ns() + cumulative_compile_timing(true) + compile_elapsedtimes = cumulative_compile_time_ns() - ccall(:jl_init_restored_module, Cvoid, (Any,), mod) + ccall(:jl_init_restored_module, Cvoid, (Any,), mod) - elapsedtime = (time_ns() - elapsedtime) / 1e6 - cumulative_compile_timing(false); - comp_time, recomp_time = (cumulative_compile_time_ns() .- compile_elapsedtimes) ./ 1e6 + elapsed_time = time_ns() - elapsed_time + cumulative_compile_timing(false); + comp_time, recomp_time = cumulative_compile_time_ns() .- compile_elapsedtimes - print("$(round(elapsedtime, digits=1)) ms $mod.__init__() ") - if comp_time > 0 - printstyled(Ryu.writefixed(Float64(100 * comp_time / elapsedtime), 2), "% compilation time", color = Base.info_color()) - end - if recomp_time > 0 - perc = Float64(100 * recomp_time / comp_time) - printstyled(" ($(perc < 1 ? "<1" : Ryu.writefixed(perc, 0))% recompilation)", color = Base.warn_color()) - end - println() - end + print_time_imports_report_init(mod, i, elapsed_time, comp_time, recomp_time) end end diff --git a/contrib/generate_precompile.jl b/contrib/generate_precompile.jl index 92dde676244e4..e4eeeed577686 100644 --- a/contrib/generate_precompile.jl +++ b/contrib/generate_precompile.jl @@ -41,6 +41,8 @@ precompile(Base.__require_prelocked, (Base.PkgId, Nothing)) precompile(Base._require, (Base.PkgId, Nothing)) precompile(Base.indexed_iterate, (Pair{Symbol, Union{Nothing, String}}, Int)) precompile(Base.indexed_iterate, (Pair{Symbol, Union{Nothing, String}}, Int, Int)) +precompile(Tuple{typeof(Base.Threads.atomic_add!), Base.Threads.Atomic{Int}, Int}) +precompile(Tuple{typeof(Base.Threads.atomic_sub!), Base.Threads.Atomic{Int}, Int}) # Pkg loading precompile(Tuple{typeof(Base.Filesystem.normpath), String, String, Vararg{String}}) @@ -163,6 +165,8 @@ for match = Base._methods(+, (Int, Int), -1, Base.get_world_counter()) push!(Expr[], Expr(:return, false)) vcat(String[], String[]) k, v = (:hello => nothing) + Base.print_time_imports_report(Base) + Base.print_time_imports_report_init(Base) # Preferences uses these get(Dict{String,Any}(), "missing", nothing) @@ -174,6 +178,11 @@ for match = Base._methods(+, (Int, Int), -1, Base.get_world_counter()) # interactive statup uses this write(IOBuffer(), "") + # not critical, but helps hide unrelated compilation from @time when using --trace-compile + foo() = rand(2,2) * rand(2,2) + @time foo() + @time foo() + break # only actually need to do this once end """ From a29fae6b6e83d155a38255671898857b22b20955 Mon Sep 17 00:00:00 2001 From: Kristoffer Carlsson Date: Mon, 16 Sep 2024 15:05:54 +0200 Subject: [PATCH 21/22] Revert "win: move stack_overflow_warning to the backtrace fiber (#55640)" This reverts commit dde7c107871e775a0d2a4f5ef7f200269fa226ea. --- src/signals-win.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/signals-win.c b/src/signals-win.c index 2b01310964ddb..a2980a0c063d9 100644 --- a/src/signals-win.c +++ b/src/signals-win.c @@ -109,8 +109,6 @@ static jl_ptls_t stkerror_ptls; static int have_backtrace_fiber; static void JL_NORETURN start_backtrace_fiber(void) { - // print the warning (this mysteriously needs a lot of stack for the WriteFile syscall) - stack_overflow_warning(); // collect the backtrace stkerror_ptls->bt_size = rec_backtrace_ctx(stkerror_ptls->bt_data, JL_MAX_BT_SIZE, stkerror_ctx, From 1c516dc002cca734c6afd621e765bb97c5b49e86 Mon Sep 17 00:00:00 2001 From: Gabriel Baraldi Date: Mon, 16 Sep 2024 15:58:40 -0300 Subject: [PATCH 22/22] Fix hang in tmerge_types_slow (#55757) Fixes https://github.com/JuliaLang/julia/issues/55751 Co-authored-by: Jameson Nash (cherry picked from commit 753296e89ddc484e54937ce7195a3f152fd5a14a) --- base/compiler/typelimits.jl | 1 + test/compiler/inference.jl | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/base/compiler/typelimits.jl b/base/compiler/typelimits.jl index 318ac0b5c27e5..e5133f9aca0bf 100644 --- a/base/compiler/typelimits.jl +++ b/base/compiler/typelimits.jl @@ -815,6 +815,7 @@ end typenames[i] = Any.name simplify[i] = false types[j] = widen + typenames[j] = ijname break end end diff --git a/test/compiler/inference.jl b/test/compiler/inference.jl index f203d411a4424..a849ddbf982a8 100644 --- a/test/compiler/inference.jl +++ b/test/compiler/inference.jl @@ -5671,3 +5671,14 @@ end # fieldcount on `Tuple` should constant fold, even though `.fields` not const @test fully_eliminated(Base.fieldcount, Tuple{Type{Tuple{Nothing, Int, Int}}}) + +# Issue https://github.com/JuliaLang/julia/issues/55751 + +abstract type AbstractGrid55751{T, N} <: AbstractArray{T, N} end +struct Grid55751{T, N, AT} <: AbstractGrid55751{T, N} + axes::AT +end + +t155751 = Union{AbstractArray{UInt8, 4}, Array{Float32, 4}, Grid55751{Float32, 3, _A} where _A} +t255751 = Array{Float32, 3} +@test Core.Compiler.tmerge_types_slow(t155751,t255751) == AbstractArray # shouldn't hang