Using IPC with the SDKPerf Tool
This section provides an example of using IPC through the Solace C messaging API-based SDKPerf test tool (sdkperf_c), which is a performance and functional test tool based on the Solace C API. This section assumes that the reader is already familiar with the use of sdkperf_c.
No modifications to sdkperf_c are necessary (aside from using a version of the C API library that supports IPC) for the tool to use IPC. The tool can accept “extra” context and session properties through a command line option, which enables the tool to utilize new features in the underlying C API.
IPC Between Two SDKPerf Instances
The following code snippet shows two sdkperf_c instances that want to communicate through an event broker. The first instance listens for messages on topic foo
, and the second instance publishes messages to topic foo
.
sdkperf_c -cip=192.168.160.29 -stl=foo
sdkperf_c -cip=192.168.160.29 -ptl=foo -msa=100 -mn=1000000 -mr=100000
To have the two sdkperf_c instances communicate over a shared memory IPC channel, only the host specifier has to change, as shown below. One instance has to listen for incoming IPC connections, and the other instance has to connect.
sdkperf_c -cip=listen:127.0.0.1 -stl=foo
sdkperf_c -cip=shm:127.0.0.1 -ptl=foo -msa=100 -mn=1000000 -mr=100000
To use a TCP channel for IPC instead of shared memory, the protocol is specified as TCP, as shown below, or it can be left out because TCP is the default:
sdkperf_c -cip=listen:127.0.0.1 -stl=foo
sdkperf_c -cip=127.0.0.1 -ptl=foo -msa=100 -mn=1000000 -mr=100000
To listen on a different port other than the default (55555), the port has to be specified, as shown below:
sdkperf_c -cip=listen:127.0.0.1:44444 -stl=foo
sdkperf_c -cip=shm:127.0.0.1:44444 -ptl=foo -msa=100 -mn=1000000 -mr=100000
When using shared memory communications, you can spin the shared memory thread to have the lowest possible latency. As both sdkperf_c instances are running on the same host, you must carefully configure the processor affinities to achieve the lowest latency possible.
In the code snippet shown below, the sdkperf_c -epl
option specifies extra properties that are not controlled by existing command line options. In this example, the -epl
option is used to spin the internal shared memory thread and to control the shared memory thread processor affinities.
sdkperf_c -cip=listen:127.0.0.1:44444 -l -lb=2048 -lp=3 -lg=10 -stl=foo -epl=CONTEXT_IPC_SHM_SPIN,-1,CONTEXT_IPC_SHM_THREAD_AFFINITY,4
sdkperf_c -cip=shm:127.0.0.1:44444 -l -ptl=foo -msa=100 -mn=1000000 -mr=100000 -epl=CONTEXT_IPC_SHM_SPIN,-1,CONTEXT_IPC_SHM_THREAD_AFFINITY,8
IPC Between Three SDKPerf Instances
In the following example, three sdkperf_c instances communicate with each other, so each instance can talk to the others over IPC. Each instance publishes on two different topics, and subscribes to two different topics. Each listens for incoming IPC connections, and then connects actively to one other peer.
sdkperf_c -cip=listen:127.0.0.1:55555;shm:127.0.0.1:33333;shm:127.0.0.1:44444 -ptl=e,f -stl=a,b,d -msa=100 -mn=100000 -mr=10000 sdkperf_c -cip=listen:127.0.0.1:44444;shm:127.0.0.1:33333;shm:127.0.0.1:55555 -ptl=c,d -stl=a,b,e -msa=100 -mn=100000 -mr=10000 sdkperf_c -cip=listen:127.0.0.1:33333;shm:127.0.0.1:44444;shm:127.0.0.1:55555 -ptl=a,b -stl=d,f -msa=100 -mn=100000 -mr=10000