phetsims / natural-selection

"Natural Selection" is an educational simulation in HTML5, by PhET Interactive Simulations
GNU General Public License v3.0
3 stars 7 forks source link

Migration can take a long time if many bunnies exist #350

Closed KatieWoe closed 1 year ago

KatieWoe commented 1 year ago

Test device Samsung Operating System Win 11 Browser Chrome Problem description For https://github.com/phetsims/qa/issues/967 In the migration wrapper, if there are a large number of bunnies to migrate, it can take a long time. It took almost 30 seconds for one of my tries. Spoke with @pixelzoom on zoom and this is expected behavior, but should still be documented. Steps to reproduce

  1. In the top sim of the migration wrapper, set food to limited and let generations run for awhile
  2. Set food to unlimited and let run until bunnies take over world
  3. Migrate

Troubleshooting information:

!!!!! DO NOT EDIT !!!!! Name: ‪Natural Selection‬ URL: https://phet-dev.colorado.edu/html/natural-selection/1.5.0-dev.5/phet/natural-selection_all_phet.html Version: 1.5.0-dev.5 2023-07-31 18:14:35 UTC Features missing: applicationcache, applicationcache, touch Flags: pixelRatioScaling User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36 Language: en-US Window: 1536x707 Pixel Ratio: 1.25/1 WebGL: WebGL 1.0 (OpenGL ES 2.0 Chromium) GLSL: WebGL GLSL ES 1.0 (OpenGL ES GLSL ES 1.0 Chromium) Vendor: WebKit (WebKit WebGL) Vertex: attribs: 16 varying: 31 uniform: 4096 Texture: size: 8192 imageUnits: 32 (vertex: 32, combined: 64) Max viewport: 8192x8192 OES_texture_float: true Dependencies JSON: {}
pixelzoom commented 1 year ago

@KatieWoe and I looked at this on Zoom. If you let the sim run for awhile (especially if population reaches a steady state) you will have a lot of bunnies and a lot of graph data. That will take a long time to migrate, so I'm not surprised by "almost 30 seconds".

This rule will be particularly expensive. It rewrites the state object for each bunny, one at a time:

    new PrivateStateUnderscored( 'BunnyIO', { canDoNothing: true } ),

@zepumph @samreid @kathy-phet FYI.

@arouinfar Do we need to say anything about this in general migration doc (does that exist?) Or in examples.md?

KatieWoe commented 1 year ago

I did also notice that the bottom studio could be a bit slow to respond. For instance, if you x out of the "bunnies have taken over the world" dialog then hit reset all it takes a few seconds.

pixelzoom commented 1 year ago

@KatieWoe said:

I did also notice that the bottom studio could be a bit slow to respond. ...

Yep. Huge amount of state being set in this sim, no way around it.

arouinfar commented 1 year ago

@arouinfar Do we need to say anything about this in general migration doc (does that exist?) Or in examples.md?

There isn't a migration-specific doc, but the general PhET-iO Guide has a section related to migration: https://github.com/phetsims/phet-io-sim-specific/blob/master/client-guide-common/client-guide/phet-io-guide.md#updating-the-standard-phet-io-wrapper-via-studio

Yep. Huge amount of state being set in this sim, no way around it.

I agree. There is definitely a noticeable performance drop in Studio when the simulation runs long enough to amass a large number of bunnies (dead or alive). However, this doesn't seem like a compelling initial condition for students, so I don't anticipate that a client would create a Standard Wrapper after 10+ generations have elapsed. Even if they do, the performance of the Standard Wrapper itself seems just fine.

I tagged this for consideration in #346, so we can close.