High CPU Load Caused by Client/Server Interfaces
Client/Server Interfaces, an Often-Unexpected Reason for High CPU Load
In multi-partition configurations, Client/Server interfaces can have a significant contribution to the CPU load. The reason is the implementation of the server invocation in different scenarios.
First Scenario – Client/Server Interfaces within a Partition
- If a client SWC A is mapped to Task 1 and calls a service of a server SWC B that is not mapped to a task, the service runs in the context of the calling client SWC and is handled as a function call. There is no time-consuming invocation of another task necessary.
- If a client SWC A is mapped to Task 1 and calls a service of a server SWC C that is mapped to another Task 2, this task of the server operation has to be invoked. This can have a major impact on the CPU load of the system. The resulting rescheduling consumes execution times, which are by magnitudes greater than a direct invocation (function call).
Second Scenario – Client/Server Interfaces crossing the partition boundary
- If a client SWC A is mapped to a Task 1 and needs to access a server SWC D that resides on another partition, this server must be mapped to a task (Task 4).
Accessing Client/Server type interfaces over partition (core) boundaries consumes by magnitudes more execution time than on the same partition since it requires scheduling of the client and the server task.
There are different solutions to reduce the CPU load caused by Client/Server interfaces.
- Check if the task mapping of the server operation is really necessary. There can be configurations in which the RTE cannot determine the partition assignment of a software component and must be provided with additional information. The best method to provide this information is to assign the component to a partition within the EcuC module. Mapping a server operation provides the same information but also brings the drawback of much longer execution times when the mapped operation is being invoked.
- Map server and client(s) to the same partition. In other words: Omit inter-partition Client/Server interfaces if possible. If the interface is between the application and the BSW, check if the BSW module can provide a satellite that provides the interface on the same partition as the application.
- Refactor interfaces to data oriented S/R types (read/write, send/receive) either directly or via a proxy component.