Coder Social home page Coder Social logo

Performance suggestions about molly.jl HOT 8 OPEN

juliamolsim avatar juliamolsim commented on May 28, 2024
Performance suggestions

from molly.jl.

Comments (8)

jgreener64 avatar jgreener64 commented on May 28, 2024 1
  1. Sounds worth a go. I think this could be possible without changing the high-level API. Not that I am against changing the API, just that any performance gains that complicate the API might not be worth it.

  2. I guess I was going for the "It is typical for such functions to also return the modified array for convenience" guidance at https://docs.julialang.org/en/v1/manual/style-guide/#bang-convention-1, but this is loose guidance and I forgot to change the other shortcut returns. It is probably more intuitive to return nothing here as you suggest.

I just gave you write access to the repo so feel free to work on a branch, obviously PR things for review before merging to master though.

from molly.jl.

SebastianM-C avatar SebastianM-C commented on May 28, 2024 1

In this case I'll just go with Tuple{Int, Int}[] for everything and if we need more we can change it in the future.

from molly.jl.

SebastianM-C avatar SebastianM-C commented on May 28, 2024

Some more ideas would be to cache neighbors and accelerations. This could potentially have a bigger impact than the above.

  • Store neighbors in the Simulation object. This would could help reducing allocations by using a pre-allocated cache for neighbors in the simulation object.
  • Store a cache for accelerations in the Simulation object

from molly.jl.

jgreener64 avatar jgreener64 commented on May 28, 2024

Yes, sounds worth a go.

I used to have the neighbours as part of the Simulation object, I might not have been doing it in the right way to re-use memory though.

from molly.jl.

SebastianM-C avatar SebastianM-C commented on May 28, 2024

@jgreener64 Regarding neighbors is it safe to assume that all NeighbourFinder return a Tuple{Int, Int}[]?
I was not sure if the cache should be the same for all NeighbourFinders (and in the respective structs) or in the Simulation object directly and the same for everyone.

from molly.jl.

jgreener64 avatar jgreener64 commented on May 28, 2024

Tuple{Int, Int}[] was what I went for as a simple scheme for recording pairs, though I've only implemented the distance neighbour finder so far so I don't know what works best in general.

For now I think we can assume that all NeighbourFinders return a Tuple{Int, Int}[] if that's helpful to you, though I don't have very strong feelings on it and am open to better schemes. Currently the requirements seem to be that you can index into it to get something containing i and j. A variety of structures would work with this so one option is to have it as another type parameter, depending on whether this allows you to cache effectively.

from molly.jl.

SebastianM-C avatar SebastianM-C commented on May 28, 2024

I noticed that even when I optimize a single acceleration function call to be faster than the one in NBodySimulator, the full simulation is still 2x slower. I think that adapting for the DiffEq time-stepping could give significant performance gains.
The main idea would be to replace simulate! with an appropriate solve call. This would mean that things such as finding neighbors and thermostats will be implemented as DiscreteCallbacks.
I think that the construction of the DiffEq problem can also be handled in ParticleAccelerations.

from molly.jl.

jgreener64 avatar jgreener64 commented on May 28, 2024

Yeah that would be good.

from molly.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.