-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
use Iterators.reverse for foldr etc. #31781
Conversation
@nanosoldier |
In particular, it looks like any reversed-order array iteration, e.g. Correction: the problem seems exclusive to
gives zero allocations for |
It is probably allocating the
|
The explicit |
I can confirm that removing the Update: No, I take that back, removing |
In
julia> foo(Float64[])
ERROR: ArgumentError: reducing over an empty collection is not allowed
Stacktrace: Things probably don't get inlined because inference doesn't see a point in inlining things that are guaranteed to throw (except in this case it ruins the escape analysis). It reminds me of #29867. |
Thanks for the tip; that's now fixed for |
Added an allocation test. |
cc @timholy, not sure if you have any further thoughts about removing the |
Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @ararslan |
nanosoldier regressions look like unrelated noise. (As far as I can tell, BaseBenchmarks.jl also doesn't call |
Okay to merge? @StefanKarpinski? |
This is an alternate version of #25520 (and #24833) that avoids wrapping
op
in aSwitch
type. Rationale: avoids potential complications of overloadingmapreduce_empty_iter
andmapreduce_first
discussed in https://github.com/JuliaLang/julia/pull/25520/files#r277144296, at a slight cost in code size.Fixes #31780. Closes #25520. Fixes #24823.
Performance-wise it seems roughly identical to
master
in a simple benchmarks as I mentioned in #25520,though for some reason(update: now fixed, see below).@btime
is now reporting(1 allocation: 16 bytes)
whereas there were zero allocations before