Polarith AI

front-end: AIMPerformance
inherits from: AIMContextEvaluation

This component replaces the former Threading component. It provides a couple of tools to improve the overall performance of the scene by optimizing agent updates (by agents, we mean Context instances). Every scene may contain only one AIMPerformance instance at maximum.

The Performance component is superior to the obsolete Threading component since it handles all Context instances instead of just the multithreaded ones. By having such global knowledge, advanced and better optimization methods can be provided.

Performance type Single-threaded Multi-threaded
Synchronous Agents update in the main thread based on the given UpdateFrequency. Agents update in sub-threads, the main thread only continues if all sub-threads have finished with their work.
Asynchronous Agents update in the main thread based on the given UpdateFrequency. Agents update in sub-threads, the main thread does not block but restarts sub-threads if they finished their work.
LoadBalanced Agents update in the main thread based on the UpdateFrequency and the set TargetFps, agent updates are equally distributed over the available frames (see Figure 1). Agents update in the main thread based on the given UpdateFrequency.

Figure 1: Two profiler examples of the same scene, all agents have an update frequency of 5 Hz. The top example does not use load balancing and shows spikes of 60 ms (17 FPS). The bottom example uses load balancing resulting in a smooth update rate of 16 ms (60 FPS).


This component has got the following specific properties.

Property Description
Performance Selects the given performance optimization method as described in the table above.
Threads The number of threads which should be used, whereby the number of actual threads is always limited by the number of (virtual) processors.
UpdateFrequency Overrides the AIMContext.UpdateFrequency property for each agent which is handled by this component.
TargetFps A reference frame per second value that is used by the load balancing mechanism to determine the optimal update distribution.


TargetFps can, of course, deviate from the real FPS. The system is implemented in a way that it adapts to the real FPS automatically so that the system interprets this value only as a guideline. Imagine the following scenario:

  • 120 non-multithreaded agents,
  • UpdateFrequency = 10,
  • TargetFps = 60.

To equally distribute the updates while remaining the UpdateFrequency of 10, 20 agents must be processed in every update. Thus, after 6 frames, 120 agents are updated with 6 * 10 (UpdateFrequency) = 60 (TargetFps). What happens if the actual update rate drops to, e.g., 30 FPS? Short answer: The actual frequency in which agents are updated drops to 5. All 120 agents are still processed with 20 agents per update. The load does not increase with dropping frame rates so the already exhausted system does not get any extra load. This also works the other way around. However, if you are utilizing VSync, an upper limit is guaranteed anyways.

AIMPerformance inherits from AIMContextEvaluation, this means that all AIMContext instances stop using their own update logic which is then handled by AIMPerformance instead. If you need your own custom update logic, you may also inherit from AIMContextEvaluation.