fix memory allocation regression of muladd introduced in v1.10 - #321
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #321 +/- ##
==========================================
+ Coverage 69.45% 69.53% +0.08%
==========================================
Files 57 57
Lines 3051 3056 +5
==========================================
+ Hits 2119 2125 +6
+ Misses 932 931 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Member
Author
|
@JeffreySarnoff Here are some additional benchmark results: On current julia> using BenchmarkTools, DoubleFloats
julia> function foo(x, y, z)
a = Double64(x)
b = Double64(y)
c = Double64(z)
return muladd(a, b, c)
end
foo (generic function with 1 method)
julia> foo(1.0, 1.0, -1.0)
0.0
julia> @allocated foo(1.0, 1.0, -1.0)
320
julia> @benchmark foo($(Ref(1.0))[], $(Ref(1.0))[], $(Ref(-1.0))[])
BenchmarkTools.Trial: 10000 samples with 961 evaluations per sample.
Range (min … max): 85.588 ns … 986.472 ns ┊ GC (min … max): 0.00% … 89.84%
Time (median): 96.732 ns ┊ GC (median): 0.00%
Time (mean ± σ): 100.251 ns ± 28.831 ns ┊ GC (mean ± σ): 2.16% ± 6.07%
▁▁ ▁ ▁▁▁▁▂▄▇█▇▅▄▄▅▅▃▃▂▂▃▃▂▂▁▁▂▂▁ ▂
██████▇███████████████████████████████████▆▇▆▆▆▅▅▅▅▆▆▅▅▄▄▅▄▄▅ █
85.6 ns Histogram: log(frequency) by time 121 ns <
Memory estimate: 320 bytes, allocs estimate: 4.With this PR: julia> using BenchmarkTools, DoubleFloats
julia> function foo(x, y, z)
a = Double64(x)
b = Double64(y)
c = Double64(z)
return muladd(a, b, c)
end
foo (generic function with 2 methods)
julia> foo(1.0, 1.0, -1.0)
0.0
julia> @allocated foo(1.0, 1.0, -1.0)
0
julia> @benchmark foo($(Ref(1.0))[], $(Ref(1.0))[], $(Ref(-1.0))[])
BenchmarkTools.Trial: 10000 samples with 996 evaluations per sample.
Range (min … max): 17.487 ns … 42.630 ns ┊ GC (min … max): 0.00% … 0.00%
Time (median): 20.164 ns ┊ GC (median): 0.00%
Time (mean ± σ): 20.400 ns ± 2.042 ns ┊ GC (mean ± σ): 0.00% ± 0.00%
▆▅▃▅▂ ▁▁ ▁▅█▆▄▅▄▃▃▁▁▁▂▂ ▂▃▁ ▂▂ ▁▃▂ ▂
▄▄████████████▇██████████████▇▅▆████▇▇████▇▇▆▆████▇▇▇▆▆▇▆██ █
17.5 ns Histogram: log(frequency) by time 26.5 ns <
Memory estimate: 0 bytes, allocs estimate: 0. |
Member
|
done thank you
…On Tue, Jul 28, 2026 at 4:36 AM Hendrik Ranocha ***@***.***> wrote:
*ranocha* left a comment (JuliaMath/DoubleFloats.jl#321)
<#321 (comment)>
@JeffreySarnoff <https://github.com/JeffreySarnoff> Here are some
additional benchmark results:
On current main:
julia> using BenchmarkTools, DoubleFloats
julia> function foo(x, y, z)
a = Double64(x)
b = Double64(y)
c = Double64(z)
return muladd(a, b, c)
end
foo (generic function with 1 method)
julia> foo(1.0, 1.0, -1.0)0.0
julia> @allocated foo(1.0, 1.0, -1.0)320
julia> @benchmark foo($(Ref(1.0))[], $(Ref(1.0))[], $(Ref(-1.0))[])
BenchmarkTools.Trial: 10000 samples with 961 evaluations per sample.
Range (min … max): 85.588 ns … 986.472 ns ┊ GC (min … max): 0.00% … 89.84%
Time (median): 96.732 ns ┊ GC (median): 0.00%
Time (mean ± σ): 100.251 ns ± 28.831 ns ┊ GC (mean ± σ): 2.16% ± 6.07%
▁▁ ▁ ▁▁▁▁▂▄▇█▇▅▄▄▅▅▃▃▂▂▃▃▂▂▁▁▂▂▁ ▂
██████▇███████████████████████████████████▆▇▆▆▆▅▅▅▅▆▆▅▅▄▄▅▄▄▅ █
85.6 ns Histogram: log(frequency) by time 121 ns <
Memory estimate: 320 bytes, allocs estimate: 4.
With this PR:
julia> using BenchmarkTools, DoubleFloats
julia> function foo(x, y, z)
a = Double64(x)
b = Double64(y)
c = Double64(z)
return muladd(a, b, c)
end
foo (generic function with 2 methods)
julia> foo(1.0, 1.0, -1.0)0.0
julia> @allocated foo(1.0, 1.0, -1.0)0
julia> @benchmark foo($(Ref(1.0))[], $(Ref(1.0))[], $(Ref(-1.0))[])
BenchmarkTools.Trial: 10000 samples with 996 evaluations per sample.
Range (min … max): 17.487 ns … 42.630 ns ┊ GC (min … max): 0.00% … 0.00%
Time (median): 20.164 ns ┊ GC (median): 0.00%
Time (mean ± σ): 20.400 ns ± 2.042 ns ┊ GC (mean ± σ): 0.00% ± 0.00%
▆▅▃▅▂ ▁▁ ▁▅█▆▄▅▄▃▃▁▁▁▂▂ ▂▃▁ ▂▂ ▁▃▂ ▂
▄▄████████████▇██████████████▇▅▆████▇▇████▇▇▆▆████▇▇▇▆▆▇▆██ █
17.5 ns Histogram: log(frequency) by time 26.5 ns <
Memory estimate: 0 bytes, allocs estimate: 0.
—
Reply to this email directly, view it on GitHub
<#321?email_source=notifications&email_token=AAM2VRQLKUFN5NFVE6CNTXL5HBQ2LA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTKMJQGE4DIOJSGA2KM4TFMFZW63VHNVSW45DJN5XKKZLWMVXHJLDGN5XXIZLSL5RWY2LDNM#issuecomment-5101849204>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAM2VRQ5EIZSCP6EIQORBV35HBQ2LAVCNFSNUABFKJSXA33TNF2G64TZHMYTCOBZHEZDMNBRHNEXG43VMU5TIOJZGAZDMNJYGE32C5QC>
.
Triage notifications, keep track of coding agent tasks and review pull
requests on the go with GitHub Mobile for iOS
<https://github.com/notifications/mobile/ios/AAM2VRRY5IT2ELMNDXVMEIL5HBQ2LA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTKMJQGE4DIOJSGA2KM4TFMFZW63VHNVSW45DJN5XKKZLWMVXHJKTGN5XXIZLSL5UW64Y>
and Android
<https://github.com/notifications/mobile/android/AAM2VRTLMUEIYPMNS7M3H6T5HBQ2LA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTKMJQGE4DIOJSGA2KM4TFMFZW63VHNVSW45DJN5XKKZLWMVXHJLTGN5XXIZLSL5QW4ZDSN5UWI>.
Download it today!
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Member
Author
|
Thanks a lot for ahndling this so quickly! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In version v1.10, allocations were introduced in
muladd(andfma) for some inputs. The old (good) behavior isThe new (bad) behavior in the current release is
This PR fixes this performance regression. I used Codex to create this PR.