Why Am I Getting High CPU Usage with my Actor Framework Application?

Updated May 3, 2018

Reported In

Software

  • LabVIEW Full

Issue Details

My Actor Framework (AF) application is causing my CPU usage to go to 70-90%. However, the CPU usage is a lot lower when developing the same application using a Queued Message Handler (QMH).

Solution

There are several reasons why the CPU usage goes high with using AF. However, the theory behind why CPU is high is standard across all design patterns and architectures. The reason why CPU usage goes high is because we have a loop which is carrying out a process with very little (or no) sleep. In the case of AF we're going to call these loops Actors.

If your AF application is causing high CPU usage then it is likely there is a bottle neck actor. This is when multiple actors are sending messages to a single actor which then has to process that information. Let's take a Frame Grabber Controller actor as an example. In the following diagram you can see a single frame grabber actor take information from several sources and distribute it to other processes.


It makes logical sense to have a central controller handle all of the data. However, this is a typical example of a bottleneck.
Instead, it would be better to architect your AF application so a Frame Grabber Controller actor is launched for every source, as seen in the diagram below.

We can remove bottle necks by launching actors as required.

Additional Information

Another Thought: Review Messaging Mechanisms
When sending messages in Actor applications, most of the time you should be creating message classes. However, sometimes developers use the low-level queue functions (found in the Programming>>Synchronisation functions pallet) as those functions are less resource intensive. The downside of this is that these functions also bypass the Actor Framework and can cause race conditions.

WAS THIS ARTICLE HELPFUL?

Not Helpful