A couple runtime "under the hood" questions

Discussion and feedback on Construct 2

Post » Thu Jan 31, 2013 8:19 pm

@Ashley

Two questions: First, does pathfinding use only 1 extra core, or does it use more if they are available?

Second, I'm trying to optimize for mobile as much as I can - when running an event like this:

Sprite.var=0
Sprite.var2=1
- rotate sprite

I'm wondering, does the second condition, under the hood, have to still process those sprites that were deselected from the first condition in any way to run the check? Such as, does the JavaScript still have to loop through all the instances to even determine if they are currently picked before checking if the condition is true?

Same for actions. Do actions have to loop through all instances, even deselected ones, to perform that action?

Even if very small, is there any remaining performance impact at all from deselected instances in events?
Moderator
B
88
S
32
G
33
Posts: 3,005
Reputation: 27,432

Post » Thu Jan 31, 2013 10:20 pm

Pathfinding only uses one separate thread (web worker). The main reason is Javascript doesn't have a good way to determine the number of cores/optimal number of threads to create. Creating too many workers could result in sub-optimal performance, and one thread on a single core machine shouldn't drag it down too much, so it's the only safe number to go with. The majority of devices are dual-core these days anyway so it's probably a good compromise.

The event system is relatively well optimised: once an instance has been de-selected by a condition, it is never iterated again (not even just to pass over) by any subsequent condition or action. Events with lots of conditions filter down the selected instances efficiently, only iterating those which met the previous condition. This means you can use a really small micro-optimisation of putting the least likely condition at the top, to reduce the instance count as low as possible initially so later conditions have fewer instances to iterate. However you'd better have tried *everything* else before thinking about such small optimisations, your time is far better off spent on things like rendering (as I'm sure you know).
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,580

Post » Thu Jan 31, 2013 10:28 pm

Awesome, thanks for the info.
Moderator
B
88
S
32
G
33
Posts: 3,005
Reputation: 27,432


Return to Construct 2 General

Who is online

Users browsing this forum: zenox98 and 14 guests