Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backports release 1.11 #53790

Merged
merged 23 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
9b14cc4
Add an IndexStyle example to the diagind docstring (#53757)
jishnub Mar 17, 2024
005ac6d
remove dllexport `jl_arraylen` which no longer exists (#53765)
fatteneder Mar 17, 2024
a579dab
Remove some duplicates from emitted compilation traces for Julia 1.10…
kpamnany Mar 20, 2024
0a7a95c
Add missing GC_POP() in emit_cfunction (#53809)
gbaraldi Mar 22, 2024
6f6cae8
also check that UUID of project is non-null when treating it as a pac…
KristofferC Mar 22, 2024
a414011
precompilepkgs: simplify custom config printing if only one (#53805)
IanButterworth Mar 22, 2024
ce13c35
Bump libuv (#53822)
Keno Mar 23, 2024
3cc6c5c
update MPFR to 4.2.1 (#53837)
fxcoudert Mar 25, 2024
08c4987
precompilepkgs: fix error reporting (#53862)
IanButterworth Mar 27, 2024
121226b
Add `_unsetindex!` methods for `SubArray`s and `CartesianIndex`es (#5…
jishnub Feb 20, 2024
cd297c7
Fix boundscheck in unsetindex for SubArrays (#53475)
jishnub Feb 27, 2024
c356e60
add invokelatest to on_done callback in bracketed paste (#53696)
JeffBezanson Mar 27, 2024
6c6097c
fix typos in codegen.cpp (#53888)
aviatesk Mar 29, 2024
6f8e78d
Revert change to checksum for llvm-julia (#53870)
Zentrik Mar 29, 2024
9afd069
Add `Base.isrelocatable(pkg)` (#53906)
fatteneder Apr 1, 2024
bfac67b
Profile: make heap snapshots viewable in vscode viewer (#53833)
IanButterworth Apr 5, 2024
ec16401
`LazyString` in `LinearAlgebra.checksquare` error message (#53961)
jishnub Apr 5, 2024
df60193
Use StringMemory instead of StringVector where possible (#53962)
Zentrik Apr 5, 2024
25c1c87
profile: doc: update the `Allocs.@profile` doc string (#53825)
nsajko Apr 5, 2024
b0d7ee4
`LazyString` in `DimensionMismatch` error messages in broadcasting (#…
jishnub Apr 6, 2024
967e2f0
Avoid repeated precompilation when loading from non-relocatable cache…
fatteneder Apr 2, 2024
146a7db
Make reshape and view on Memory produce Arrays and delete wrap (#53896)
LilithHafner Apr 6, 2024
eb96c07
Test and fix non-int-length bug in `view(::Memory, ::Union{UnitRange,…
LilithHafner Apr 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use StringMemory instead of StringVector where possible (#53962)
On `1.11.0-alpha2`
Old:
```julia
@benchmark Base.dec($0x1, $0, $false)
BenchmarkTools.Trial: 10000 samples with 994 evaluations.
 Range (min … max):  33.702 ns …   4.242 μs  ┊ GC (min … max):  0.00% … 97.61%
 Time  (median):     37.626 ns               ┊ GC (median):     0.00%
 Time  (mean ± σ):   45.787 ns ± 147.794 ns  ┊ GC (mean ± σ):  14.53% ±  4.47%

    ▄▅▆▇█▇▇▅▃▃▂▂▂▁    ▁▂▁▁▁             ▁▁   ▁                 ▂
  ▄▇███████████████▇▇██████▇█▆▆▄▄▃▄▅▄▆▇████████▆▅▅▇▆▅▆▄▄▅▄▄▄▁▅ █
  33.7 ns       Histogram: log(frequency) by time      67.5 ns <

 Memory estimate: 88 bytes, allocs estimate: 3.
```
New:
```julia
BenchmarkTools.Trial: 10000 samples with 995 evaluations.
 Range (min … max):  27.538 ns …   3.397 μs  ┊ GC (min … max):  0.00% … 97.86%
 Time  (median):     30.151 ns               ┊ GC (median):     0.00%
 Time  (mean ± σ):   34.547 ns ± 105.101 ns  ┊ GC (mean ± σ):  10.37% ±  3.39%

       ▁ █▆▃  ▁
  ▂▂▃▃▅█████▆████▆▄▄▃▃▃▃▃▃▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▁▂▂▂▂▂▁▂▂▂▂▂▂▂▂▂▂▂▂▂ ▃
  27.5 ns         Histogram: frequency by time         43.8 ns <

 Memory estimate: 56 bytes, allocs estimate: 2.
```

Fixes #53950, actually now even faster than `1.10.2`.

It doesn't look like the length is ever changed and we don't return
these `StringMemory`s so this change should be fine.

(cherry picked from commit 0e59c9e)
  • Loading branch information
Zentrik authored and KristofferC committed Apr 9, 2024
commit df60193377c16352de83c80a136cefae7b13e75c
2 changes: 1 addition & 1 deletion base/gmp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,7 @@ function string(n::BigInt; base::Integer = 10, pad::Integer = 1)
iszero(n) && pad < 1 && return ""
nd1 = ndigits(n, base=base)
nd = max(nd1, pad)
sv = Base.StringVector(nd + isneg(n))
sv = Base.StringMemory(nd + isneg(n))
GC.@preserve sv MPZ.get_str!(pointer(sv) + nd - nd1, base, n)
@inbounds for i = (1:nd-nd1) .+ isneg(n)
sv[i] = '0' % UInt8
Expand Down
12 changes: 6 additions & 6 deletions base/intfuncs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,7 @@ ndigits(x::Integer; base::Integer=10, pad::Integer=1) = max(pad, ndigits0z(x, ba
function bin(x::Unsigned, pad::Int, neg::Bool)
m = top_set_bit(x)
n = neg + max(pad, m)
a = StringVector(n)
a = StringMemory(n)
# for i in 0x0:UInt(n-1) # automatic vectorization produces redundant codes
# @inbounds a[n - i] = 0x30 + (((x >> i) % UInt8)::UInt8 & 0x1)
# end
Expand All @@ -769,7 +769,7 @@ end
function oct(x::Unsigned, pad::Int, neg::Bool)
m = div(top_set_bit(x) + 2, 3)
n = neg + max(pad, m)
a = StringVector(n)
a = StringMemory(n)
i = n
while i > neg
@inbounds a[i] = 0x30 + ((x % UInt8)::UInt8 & 0x7)
Expand Down Expand Up @@ -844,7 +844,7 @@ end

function dec(x::Unsigned, pad::Int, neg::Bool)
n = neg + ndigits(x, pad=pad)
a = StringVector(n)
a = StringMemory(n)
append_c_digits_fast(n, x, a, 1)
neg && (@inbounds a[1] = 0x2d) # UInt8('-')
String(a)
Expand All @@ -853,7 +853,7 @@ end
function hex(x::Unsigned, pad::Int, neg::Bool)
m = 2 * sizeof(x) - (leading_zeros(x) >> 2)
n = neg + max(pad, m)
a = StringVector(n)
a = StringMemory(n)
i = n
while i >= 2
b = (x % UInt8)::UInt8
Expand All @@ -880,7 +880,7 @@ function _base(base::Integer, x::Integer, pad::Int, neg::Bool)
b = (base % Int)::Int
digits = abs(b) <= 36 ? base36digits : base62digits
n = neg + ndigits(x, base=b, pad=pad)
a = StringVector(n)
a = StringMemory(n)
i = n
@inbounds while i > neg
if b > 0
Expand Down Expand Up @@ -956,7 +956,7 @@ julia> bitstring(2.2)
function bitstring(x::T) where {T}
isprimitivetype(T) || throw(ArgumentError("$T not a primitive type"))
sz = sizeof(T) * 8
str = StringVector(sz)
str = StringMemory(sz)
i = sz
@inbounds while i >= 4
b = UInt32(sizeof(T) == 1 ? bitcast(UInt8, x) : trunc_int(UInt8, x))
Expand Down
2 changes: 1 addition & 1 deletion base/strings/util.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1061,7 +1061,7 @@ function bytes2hex end

function bytes2hex(itr)
eltype(itr) === UInt8 || throw(ArgumentError("eltype of iterator not UInt8"))
b = Base.StringVector(2*length(itr))
b = Base.StringMemory(2*length(itr))
@inbounds for (i, x) in enumerate(itr)
b[2i - 1] = hex_chars[1 + x >> 4]
b[2i ] = hex_chars[1 + x & 0xf]
Expand Down
2 changes: 1 addition & 1 deletion base/uuid.jl
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ let groupings = [36:-1:25; 23:-1:20; 18:-1:15; 13:-1:10; 8:-1:1]
global string
function string(u::UUID)
u = u.value
a = Base.StringVector(36)
a = Base.StringMemory(36)
for i in groupings
@inbounds a[i] = hex_chars[1 + u & 0xf]
u >>= 4
Expand Down
2 changes: 1 addition & 1 deletion stdlib/FileWatching/src/pidfile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ function open_exclusive(path::String;
end

function _rand_filename(len::Int=4) # modified from Base.Libc
slug = Base.StringVector(len)
slug = Base.StringMemory(len)
chars = b"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
for i = 1:len
slug[i] = chars[(Libc.rand() % length(chars)) + 1]
Expand Down