From FlightGear wiki
Jump to navigation Jump to search

Control over thread-cpu affinities.

This is on next.

By default OSG ties the main thread and others to a single CPU core early on in startup. This can cause problems on Linux if one tries to run CPU-intensive tasks on other threads, because new threads inherit their parent thread's affinity settings.

For example this can make video encoding run very slowly because the internal threads created by ffmpeg can end up all trying to run on the same core.

One can change the default behaviour by setting the /sim/thread-cpu-affinity property on startup to "none", e.g. with --prop:/sim/thread-cpu-affinity=none.

Allowed values are:

  • Empty string or unset: allow OSG to set thread affinities as normal.
  • "none": do not allow OSG to set thread affinities; the OS gets to choose what cores to use.
  • "osg": allow OSG to set up thread affinities but attempt to cancel affinity of main thread afterwards. (This doesn't really work.)

One can also change the behaviour at runtime by setting property /sim/affinity-control, e.g. to test the effect of thread affinities on frame rate:

  • Set to "clear": remember current threads' affinities then clear all thread affinities.
  • Set to "revert": restore thread affinities remembered from most recent clear setting.