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

Optimize energy chunk performance #75

Closed
jbphet opened this issue Aug 27, 2018 · 5 comments
Closed

Optimize energy chunk performance #75

jbphet opened this issue Aug 27, 2018 · 5 comments
Assignees

Comments

@jbphet
Copy link
Contributor

jbphet commented Aug 27, 2018

Profiling has shown that positioning and rendering of the energy chunks is pretty expensive, we need to investigate how to improve the performance of this portion of the sim. One possibility is to use a canvas, but that may prove problematic due to the use of layering.

@jbphet
Copy link
Contributor Author

jbphet commented Aug 27, 2018

So that we have a baseline against which to compare, I'm gathering some data on performance on my Dell XPS running Windows 10. When I do this at full screen on the main display, I'm currently seeing around 38 FPS when showing the sun (which creates a lot of energy chunks) and the beaker (which contains a lot of energy chunks). Note that the conversion from light to electrical energy on the solar panel is not currently working.

Here is a screenshot:

efac-perf-1

Profiling shows that a fair amount of time is being spent getting the reflective shape of the clouds, which seems odd. Here is a screenshot that shows a "flame" where over 25ms is being spent on this:

image

@chrisklus and I discussed this, and he is going to investigate optimizing this code.

@jbphet
Copy link
Contributor Author

jbphet commented Aug 27, 2018

Also, the energy chunks are being created frequently and consist of a composite node with a background and a text element. We may get some performance increase by making this an image and reusing one image per energy chunk type. @chrisklus is also going to investigate this.

@chrisklus
Copy link
Contributor

The clouds' ellipses are now only drawn when their position changes, and the energy chunk image nodes are only created on initialization, instead of every time a new chunk is needed.

Before these changes, on the iPad Air 2, the sim was running at 18 fps when the sun was showing with energy chunks coming out of it. After making the cloud change, it ran at 29-33 fps, and after the image node change, it runs at 40-41 fps and looks pretty nice. @jbphet and I are going to discuss if any further optimization needs to be done for the energy chunks.

@chrisklus
Copy link
Contributor

@jbphet and I are going to do a bunch of profiling on different devices before making this decision.

@chrisklus
Copy link
Contributor

Closing, see #191 for latest performance updates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants