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

Reduce allocation in flatten #29786

Merged
merged 1 commit into from
Oct 31, 2018
Merged

Conversation

mschauer
Copy link
Contributor

@mschauer mschauer commented Oct 23, 2018

Fix #29762.

Before

z = rand(50)
fl = flatten([z for i in 1:10000])
@btime sum(fl)
  11.299 ms (1000001 allocations: 30.52 MiB)

After

julia> @btime sum(fl)
  791.038 μs (7 allocations: 128 bytes)
259558.6656132105

@KristofferC KristofferC added potential benchmark Could make a good benchmark in BaseBenchmarks performance Must go faster labels Oct 24, 2018
@mschauer
Copy link
Contributor Author

mschauer commented Oct 24, 2018

A second useful benchmark would be

julia> f = flatten((i,i+1) for i in 1:10000)
julia> @btime sum($f)
  27.160 μs (0 allocations: 0 bytes)
100020000

which was already fast and shouldnt get slower.

@KristofferC KristofferC merged commit 07ea302 into JuliaLang:master Oct 31, 2018
KristofferC pushed a commit that referenced this pull request Oct 31, 2018
@KristofferC KristofferC removed the potential benchmark Could make a good benchmark in BaseBenchmarks label Oct 31, 2018
KristofferC pushed a commit that referenced this pull request Oct 31, 2018
@mschauer
Copy link
Contributor Author

mschauer commented Nov 2, 2018

Can we retrospectively run the iterators benchmark?

@KristofferC
Copy link
Sponsor Member

The new benchmarks need to be updated on Nanosoldier as well, not enough to merge to BenchmarkTools. I think @ararslan does that from time to time.

@mschauer
Copy link
Contributor Author

mschauer commented Nov 2, 2018

Ok, thanks, no hurries.

KristofferC pushed a commit that referenced this pull request Nov 2, 2018
KristofferC pushed a commit that referenced this pull request Feb 11, 2019
KristofferC pushed a commit that referenced this pull request Feb 20, 2020
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.

2 participants