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

Add inbounds annotation in map! computation #30624

Merged
merged 2 commits into from
Jan 25, 2019

Conversation

YingboMa
Copy link
Contributor

@YingboMa YingboMa commented Jan 7, 2019

using BenchmarkTools

function foo!(a, b, c, d, e)
    map!((b, c, d, e) -> b + 0.1 * (0.2c + 0.3d + 0.4e), a, b, c, d, e)
end

a,b,c,d,e=(ones(1000) for i in 1:5)
@btime foo!($a, $b, $c, $d, $e);
# Master: 1.753 μs (1 allocation: 48 bytes)
# PR: 347.575 ns (1 allocation: 48 bytes)

If I put @_propagate_inbounds_meta in map_n!, the map! function will be a lot slower

julia> @btime foo!($a, $b, $c, $d, $e);
  583.367 ns (1 allocation: 48 bytes)

.

@nalimilan
Copy link
Member

Thanks. I'd say we should merge the PR without the FIXME part for now, we can always figure out later why adding the @_propagate_inbounds_meta makes things (slightly) slower. As a first contribution, map_n! was introduced by @JeffBezanson in f4ed999, making it a separate function from map!, probably because it was faster for a reason that escapes me. So it's not completely surprising that inlining it makes things slower.

base/abstractarray.jl Outdated Show resolved Hide resolved
base/abstractarray.jl Outdated Show resolved Hide resolved
base/abstractarray.jl Outdated Show resolved Hide resolved
@mbauman mbauman added the performance Must go faster label Jan 7, 2019
@YingboMa
Copy link
Contributor Author

Bump

@KristofferC
Copy link
Sponsor Member

@nanosoldier runbenchmarks(ALL, vs = ":master")

@nanosoldier
Copy link
Collaborator

Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @ararslan

@KristofferC KristofferC reopened this Jan 20, 2019
@YingboMa
Copy link
Contributor Author

The regression seems to be noise.

@KristofferC KristofferC merged commit f9645ff into JuliaLang:master Jan 25, 2019
@YingboMa YingboMa deleted the myb/map_n_perf branch February 5, 2019 11:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Must go faster
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants