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

repeat is unnecessarily slow #15553

Closed
simonbyrne opened this issue Mar 18, 2016 · 3 comments · Fixed by #20635
Closed

repeat is unnecessarily slow #15553

simonbyrne opened this issue Mar 18, 2016 · 3 comments · Fixed by #20635
Labels
kind:potential benchmark Could make a good benchmark in BaseBenchmarks performance Must go faster

Comments

@simonbyrne
Copy link
Contributor

julia> @time n = repeat(collect(1:20000), inner=[84], outer=[1]);
  1.439516 seconds (20.03 M allocations: 523.687 MB, 4.77% gc time)

Writing the loops manually is 100x faster.

Unfortunately I can't think of any easy way to fix the general case that doesn't involve generated functions.

@tkelman tkelman added performance Must go faster kind:potential benchmark Could make a good benchmark in BaseBenchmarks labels Mar 18, 2016
@nalimilan
Copy link
Member

Cf. #14082

@JeffBezanson
Copy link
Sponsor Member

I believe we could at least do block copy operations instead of computing the position of every element individually. Instead of constructing an array of scalar indexes, construct an array of ranges for each element to handle inner, initially constructing only one of the outer copies. Then that data just needs to be copied to handle outer. The case of inner being all 1s can be optimized as well.

@stevengj
Copy link
Member

(Benchmark added to BaseBenchmarks.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:potential benchmark Could make a good benchmark in BaseBenchmarks performance Must go faster
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants