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

Decrease allocations done #35

Closed
Datseris opened this issue Sep 30, 2017 · 8 comments
Closed

Decrease allocations done #35

Datseris opened this issue Sep 30, 2017 · 8 comments

Comments

@Datseris
Copy link
Member

Datseris commented Sep 30, 2017

A standard evolve call has at least 100,000 allocations even though everything is done through SVectors.

I do not know how or why this happens and also how to solve it.

Just do

using DynamicalBilliards, BenchmarkTools
bt = billiard_sinai()
p = randominside(bt)
evolve!(p, bt, 1.0) # compile
@btime evolve!(p, bt, 1000.0)

to see what I mean.

@dapias
Copy link
Contributor

dapias commented Sep 30, 2017

What kind of billiard bt is?

@Datseris
Copy link
Member Author

It doesn't really matter. The allocations come from evolve! so I am quite sure they happen in any combination of billiard tables.

And so it should be, since all the methods are identical no matter the obstacles. What changes is only sings and numerical values...

@Datseris
Copy link
Member Author

I guess the answer is simply "SVectors result in allocations" ? I cannot know for sure though.

What I know for sure is that a lot of SVectors are created all the time during evolve!

@dapias
Copy link
Contributor

dapias commented Oct 2, 2017

Check out this case:

using DynamicalBilliards, BenchmarkTools

space = 3.0
r = 1.0
polygon_sides = 6
bth = billiard_polygon(polygon_sides, space/sqrt(3); setting = "periodic")
d = Disk([0.,0.], r)
push!(bth, d)
t = 1000.0
p = randominside(bth)
@btime evolve!(p, bth, t)

I get

478.572 μs (7459 allocations: 137.20 KiB)

after having compiled once.

PS: Sometimes in Sydney, the connection to github is down. I wanted to share this piece of code two days ago...

@dpsanders
Copy link

Note that when using the benchmarking tools, any global variables should be preceded by a $, as e.g.
@btime evolve!($p, $bth, $t).
However, I don't think this will make much difference here.

@dapias
Copy link
Contributor

dapias commented Oct 3, 2017

Oh ok. Thank you @dpsanders

@Datseris
Copy link
Member Author

This is apparently due to the type instabilities that result from using Vector{Obstacle{T}} as the billiard table.

I am hoping the combo of #30 and #51 will resolve it at least partly.

@Datseris Datseris added this to To do in Release 2.0 Mar 13, 2018
@Datseris
Copy link
Member Author

Closed in #72

Release 2.0 automation moved this from To do to Done Mar 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Release 2.0
  
Done
Development

No branches or pull requests

3 participants