Nasal Loops: Difference between revisions

m
http://forum.flightgear.org/viewtopic.php?f=4&t=20576&p=199262&hilit=#p199264
No edit summary
m (http://forum.flightgear.org/viewtopic.php?f=4&t=20576&p=199262&hilit=#p199264)
Line 48: Line 48:
Normally, there's a vector of subsystems that's iterated in the FG main loop, each subsystem's update() method is then called, including the update() method of the Nasal subsystem.
Normally, there's a vector of subsystems that's iterated in the FG main loop, each subsystem's update() method is then called, including the update() method of the Nasal subsystem.
However, most Nasal code is not directly called via Nasal::update(), but instead via callbacks by other C++ subsystems, such as events (for timers) or the property tree code (for listeners), but also the AI traffic system, scenery system - or even the GUI system, whenever Nasal hooks are supported by the system, the corresponding system needs to reach back into Nasal space, which may end up triggering the GC.
However, most Nasal code is not directly called via Nasal::update(), but instead via callbacks by other C++ subsystems, such as events (for timers) or the property tree code (for listeners), but also the AI traffic system, scenery system - or even the GUI system, whenever Nasal hooks are supported by the system, the corresponding system needs to reach back into Nasal space, which may end up triggering the GC.
In the meantime what you could do is keep taking things out until you find some things that slow FG down. Start with the 3D model (eg replace with UFO) then take out various parts of Nasal, particularly those that have timers, listeners, or other callbacks. From there you can narrow it down by checking individual call times via systime(), like my framework does (on a large scale), or maybe debug.benchmark when I provide a small patch...
== for, while, foreach, and forindex loops ==
== for, while, foreach, and forindex loops ==
Nasal's looping constructs are mostly C-like:
Nasal's looping constructs are mostly C-like: