Howto:Optimizing FlightGear for mobile devices: Difference between revisions

Jump to navigation Jump to search
Switch to {{flightgear url}}, {{flightgear source}}, {{flightgear commit}}, {{simgear commit}}, and {{fgdata source}} to fix the broken Gitorious links. The line numbers still require a lot of fixing!
No edit summary
(Switch to {{flightgear url}}, {{flightgear source}}, {{flightgear commit}}, {{simgear commit}}, and {{fgdata source}} to fix the broken Gitorious links. The line numbers still require a lot of fixing!)
Line 214: Line 214:
Being able to disable subsystems individually will be useful for the whole simulator, not just for this effort: [[FlightGear Run Levels]].
Being able to disable subsystems individually will be useful for the whole simulator, not just for this effort: [[FlightGear Run Levels]].


There are many other subsystems which are started by default and which cannot be currently disabled, so more CPU/RAM resources can be saved by editing [https://gitorious.org/fg/flightgear/blobs/next/src/Main/fg_init.cxx#line1043 $FG_SRC/Main/fg_init.cxx] and by making more subsystems optional there, using a property to decide if the subsystem shall be started or not, e.g.:
There are many other subsystems which are started by default and which cannot be currently disabled, so more CPU/RAM resources can be saved by editing {{flightgear source|path=src/Main/fg_init.cxx|line=1043|pre=$FG_SRC}} and by making more subsystems optional there, using a property to decide if the subsystem shall be started or not, e.g.:


<syntaxhighlight lang="cpp">
<syntaxhighlight lang="cpp">
Line 234: Line 234:


Some possible candidates include:
Some possible candidates include:
* [https://gitorious.org/fg/flightgear/blobs/next/src/Main/fg_init.cxx#line1052 the sounds system]
* {{flightgear source|path=src/Main/fg_init.cxx|line=1052|text=the sounds system}}
* [https://gitorious.org/fg/flightgear/blobs/next/src/Main/fg_init.cxx#line1081 the performance monitor] (during development this should definitely be useful, especially once customized)
* {{flightgear source|path=src/Main/fg_init.cxx|line=1081|text=the performance monitor}} (during development this should definitely be useful, especially once customized)
* [https://gitorious.org/fg/flightgear/blobs/next/src/Main/fg_init.cxx#line1133 the autopilot/route manager systems]
* {{flightgear source|path=src/Main/fg_init.cxx|line=1133|text=the autopilot/route manager systems}}
* [https://gitorious.org/fg/flightgear/blobs/next/src/Main/fg_init.cxx#line1178 the ATC system]
* {{flightgear source|path=src/Main/fg_init.cxx|line=1178|text=the ATC system}}
* [https://gitorious.org/fg/flightgear/blobs/next/src/Main/fg_init.cxx#line1196 the traffic manager]
* {{flightgear source|path=src/Main/fg_init.cxx|line=1196|text=the traffic manager}}
* [https://gitorious.org/fg/flightgear/blobs/next/src/Main/fg_init.cxx#line1225 the replay system]
* {{flightgear source|path=src/Main/fg_init.cxx|line=1225|text=the replay system}}
* [https://gitorious.org/fg/flightgear/blobs/next/src/Main/fg_init.cxx#line1230 the voice system]
* {{flightgear source|path=src/Main/fg_init.cxx|line=1230|text=the voice system}}


To check what else is initialized, see the "globals" files in $FG_SRC/Main:
To check what else is initialized, see the "globals" files in $FG_SRC/Main:
* https://gitorious.org/fg/flightgear/blobs/next/src/Main/globals.cxx
* {{flightgear url|src/Main/globals.cxx}}
* https://gitorious.org/fg/flightgear/blobs/next/src/Main/globals.hxx
* {{flightgear url|src/Main/globals.hxx}}


While disabling these systems can be fairly easily accomplished using ifdefs, care must be taken that FlightGear still builds properly and that no other systems are trying to access disabled subsystems at runtime, so this will involve repeated edit/build/debugging sessions using gdb. But that doesn't need to be done on the target device, it could just as well be completed on a conventional PC.
While disabling these systems can be fairly easily accomplished using ifdefs, care must be taken that FlightGear still builds properly and that no other systems are trying to access disabled subsystems at runtime, so this will involve repeated edit/build/debugging sessions using gdb. But that doesn't need to be done on the target device, it could just as well be completed on a conventional PC.
Line 255: Line 255:
In order to help reduce the memory footprint of FlightGear, it might be beneficial to extend the built-in [[Howto:Use the system monitor|performance monitor system]] such that it also supports tracking memory consumption per subsystem.  
In order to help reduce the memory footprint of FlightGear, it might be beneficial to extend the built-in [[Howto:Use the system monitor|performance monitor system]] such that it also supports tracking memory consumption per subsystem.  


The performance monitor is initialized in fg_init.cxx: https://gitorious.org/fg/flightgear/blobs/next/src/Main/fg_init.cxx#line1083
The performance monitor is initialized in fg_init.cxx: {{flightgear url|src/Main/fg_init.cxx|line=1083}}
The performance monitor is implemented as part of SimGear, <simgear/structure/SGPerfMon.hxx>
The performance monitor is implemented as part of SimGear, <simgear/structure/SGPerfMon.hxx>
As can be seen, it hooks into the [http://simgear.sourceforge.net/doxygen/classSGSubsystem.html SGSubsystem] code, so that it gets invoked by all subsystems in order to create runtime samples.
As can be seen, it hooks into the [http://simgear.sourceforge.net/doxygen/classSGSubsystem.html SGSubsystem] code, so that it gets invoked by all subsystems in order to create runtime samples.


The commits implementing the performance monitor are these:  
The commits implementing the performance monitor are these:  
* [http://gitorious.org/fg/simgear/commit/27a1c02/diffs SimGear commit]
* {{simgear commit|27a1c02|text=SimGear commit}}
* [https://gitorious.org/fg/flightgear/commit/4b2506d/diffs FlightGear commit]
* {{flightgear commit|4b2506d|text=FlightGear commit}}


The performance monitor dialog reads all data from the property tree and it is created dynamically using a Nasal module in [http://gitorious.org/fg/fgdata/blobs/master/Nasal/performance_monitor/monitor.nas $FG_ROOT/Nasal/performance_monitor/monitor.nas]
The performance monitor dialog reads all data from the property tree and it is created dynamically using a Nasal module in {{fgdata source|Nasal/performance_monitor/monitor.nas|pre=$FG_ROOT}}


It would probably suffice to use "placement new" (i.e. pool memory) here, and overload the new operator at the SGSubsystem level (i.e. in SimGear), so that all subsystems use the overloaded new operator automatically and write allocation reports to the performance monitor.  
It would probably suffice to use "placement new" (i.e. pool memory) here, and overload the new operator at the SGSubsystem level (i.e. in SimGear), so that all subsystems use the overloaded new operator automatically and write allocation reports to the performance monitor.  

Navigation menu