NetLogo / Galapagos

NetLogo model simulation visualizer (Beak) and the netlogoweb.org website 🐢
https://netlogoweb.org/
Other
62 stars 43 forks source link

checkbox to turn view updates off #72

Open SethTisue opened 11 years ago

SethTisue commented 11 years ago

at minimum, it could turn off rendering of the canvas.

ideally, it would stop generating view updates internally, since that's expensive. turning the checkbox back on would generate a full, from-scratch world update

the checkbox is desirable for end users to have, but it would also be desirable for us, since we could see how much things speed up, and see what kind of engine speed we are getting in-browser. (Rhino is a dog, so the speed numbers we get on the JVM aren't much use.)

qiemem commented 11 years ago

For performance stuff before this is done: Standard browser profilers will tell you where the bottlenecks are. Also, in Chrome, Firefox (I believe), and maybe others, you can modify the source in browser have it take effect. Just comment out the line this.controller.repaint(); in tortoise.js. Also, note that there are multiple expensive things happening: the drawing itself and the integration view updates into the view's model. In Chrome, they're about the same. In Firefox, redrawing is way more expensive.

TheBizzle commented 11 years ago

This isn't just about repainting, though. From my experience with the ScalaJS engine, the aggregation of view updates is pretty heavy bottleneck. What Seth's proposing would also include turning off view updates aggregation.

TheBizzle commented 11 years ago

I guess that's what you were getting at with "the integration view updates into the view's model".

qiemem commented 11 years ago

I guess that's what you were getting at with "the integration view updates into the view's model".

Yup.

Unfortunately, we can't turn off view updates and turn them on again without breaking everything. If the view's model gets out of sync, if it, say, misses the destruction of a turtle, you get graphical artifacts.

It's not just the aggregation itself either. Every single modification in the engine right now comes with its own update object. That's a ton of garbage. The gc pauses can get pretty bad if you run a model a while.

This performance bottleneck is actually an issue I've meant to raise for a while. The engine should modify a single update until collectUpdates is called (or, when/if we move to a web worker, display is called), at which point that should be sent out. I'll open an issue for this soon.

SethTisue commented 11 years ago

Unfortunately, we can't turn off view updates and turn them on again without breaking everything

That's what I meant by "turning the checkbox back on would generate a full, from-scratch world update" — the Tortoise engine can simply be asked to generate a complete, fresh description of every agent. It's already capable of doing that, so we just need to put in a hook.

qiemem commented 11 years ago

Doh, sorry. Missed that part.

To be clear (as a note to my future self), the view's model should just be destroyed entirely and a whole world update be made. A whole world update alone is not enough as it won't clear dead turtles.

TheBizzle commented 11 years ago

Good point.

qiemem commented 9 years ago

Jason and I did some testing yesterday to determine how important this was. We did this by using the most view intensive yet engine-easiest models we could come up with. The only time rendering made a significant impact on speed was when we were generating so many shape/color combinations that the shape cacher became useless. We decided that such was an extremely unlikely to happen in the wild and thus lowered the priority of this issue.

During this process, I believe we came up with the greatest model ever created. If you too would like to experience this awesome, here's the code:

globals [ all-the-shapes ]

to setup
  ca
  crt 100
  set all-the-shapes ["default" "airplane" "arrow" "box" "bug" "butterfly" "car" "circle" "circle 2" "cow" "cylinder" "dot" "face happy" "face neutral" "face sad" "fish" "flag" "flower" "house" "leaf" "line" "line half" "pentagon" "person" "plant" "sheep" "square" "square 2" "star" "target" "tree" "triangle" "triangle 2" "truck" "turtle" "wheel" "wolf" "x"]
  reset-ticks
end

to go
  ask turtles [ fd 1 set shape one-of all-the-shapes set color (list random 255 random 255 random 255) set size random 15 ]
  tick
end

(note that shapes isn't in netlogo web yet; thus all-the-shapes)

TheBizzle commented 9 years ago

:+1: for best model

qiemem commented 9 years ago

It occurred to me that the engine itself can also run faster when view updates are disabled. It no longer needs to create and modify update objects, since it would just send the full world state once the view updates are turned on again. This could be significant but might also be harder to test.