EPICS exampleCPP/arrayPerformance

2016.08.29

Abstract

arrayPerformance provides main programs that demonstrate performance of large arrays and can also be used to check for memory leaks. Checking for memory leaks can be accomplished by running the programs with valgrind or some other memory check program.

Table of Contents


Overview

The programs are:

arrayPerformanceMain
This is server and also a configurable number of longArrayMonitor clients. The clients can use either the local or remote providers. The monitor code is the same code that is used by longArrayMonitorMain.
longArrayMonitorMain
Remote client that monitors the array served by arrayPerformanceMain.
longArrayGetMain
Remote client that uses channelGet to access the array served by arrayPerformanceMain.
longArrayPutMain
Remote client that uses channelPut to access the array served by arrayPerformanceMain.

Each has support for -help.

mrk> pwd
/home/hg/exampleCPP/arrayPerformance
mrk> bin/$EPICS_HOST_ARCH/arrayPerformanceMain -help
recordName size delay providerName nMonitor queueSize
default
arrayPerformance 10000000 0.0001 local 1 2

mrk> bin/$EPICS_HOST_ARCH/longArrayMonitorMain -help
channelName queueSize
default
arrayPerformance 2

mrk> bin/$EPICS_HOST_ARCH/longArrayGetMain -help
channelName iterBetweenCreateChannel iterBetweenCreateChannelGet delayTime
default
arrayPerformance 0 0 1

mrk> bin/$EPICS_HOST_ARCH/longArrayPutMain -help
channelName arraySize iterBetweenCreateChannel iterBetweenCreateChannelPut delayTime
default
arrayPerformance 10 0 0 1

mrk> 

Example output

Note: These may fail if run on a platform that does not have sufficient memory,

To see an example just execute the following commands in four different terminal windows:

bin/$EPICS_HOST_ARCH/arrayPerformanceMain
bin/$EPICS_HOST_ARCH/longArrayMonitorMain
bin/$EPICS_HOST_ARCH/longArrayGetMain
bin/$EPICS_HOST_ARCH/longArrayPutMain

Each program generates a report every second when it has something to report. Examples are:

mrk> bin/$EPICS_HOST_ARCH/arrayPerformanceMain
arrayPerformance 10000000 0.0001 local 1 2
...
arrayPerformance value 691 time 1.00585 Iterations/sec 19.8837 megaElements/sec 198.837
 monitors/sec 20 first 691 last 691 changed {1, 2} overrun {} megaElements/sec 192.453
arrayPerformance value 709 time 1.00279 Iterations/sec 17.9499 megaElements/sec 179.499
 monitors/sec 19 first 710 last 710 changed {1, 2} overrun {} megaElements/sec 184.922
arrayPerformance value 729 time 1.01898 Iterations/sec 19.6274 megaElements/sec 196.274
 monitors/sec 20 first 730 last 730 changed {1, 2} overrun {} megaElements/sec 195.467
...
mrk> bin/$EPICS_HOST_ARCH/longArrayMonitorMain
longArrayMonitorMain arrayPerformance 2 0
...
 monitors/sec 9 first 1068 last 1068 changed {1, 2} overrun {1, 2} megaElements/sec 89.761
 monitors/sec 9 first 1084 last 1084 changed {1, 2} overrun {1, 2} megaElements/sec 87.1092
 monitors/sec 9 first 1101 last 1101 changed {1, 2} overrun {} megaElements/sec 86.267

...
mrk> bin/$EPICS_HOST_ARCH/longArrayPutMain
longArrayPutMain arrayPerformance 10 0 0 1
...
put numChannelPut 0 Elements/sec 79.8819
put numChannelPut 1  Elements/sec 79.8598
...
mrk> bin/$EPICS_HOST_ARCH/longArrayGetMain
longArrayGetMain arrayPerformance 0 0 1
...
get kiloElements/sec 7384.61
get kiloElements/sec 8726.34
...

arrayPerformance

The arguments for arrayPerforamanceMain are:

recordName
The name for the arrayPerform record.
size
The size for the long array of the value field.
delay
The time in seconds to sleep after each iteration.
providerName
The name of the channel provider for the longArrayMonitors created by the main program. This must be either local or pva.
nMonitor
The number of longArrayMonitors to create.
queueSize
The queueSize for the element queue.

arrayPerformance creates a PVRecord that has the structure:.

recordName
    long[] value
    timeStamp timeStamp
    alarm alarm
Thus it holds an array of 64 bit integers.

arrayPerformance creates a separate thread that runs until stop is called. arrayPerformance does the following:

report
Once a second it produces a report. In the above example output each line starting with ArrayPerformance is an arrayPerformance report.
create array
A new shared_vector is created and each element is set equal to the iteration count.
lock
The arrayPerformance record is locked.
Begin group put
beginGroupReport is called.
replace
The value field of the record is replaced with the newly created shared_vector.
process
The record is then processed. This causes the timeStamp to be set to the current time.
End group put
endGroupPut is called.
unlock
The arrayPerformance record is unlocked.
delay
If delay is greater than zero epicsThreadSleep is called.

longArrayMonitor

This is a pvAccess client that monitors an arrayPerformance record. It generates a report every second showing how many elements has received. For every monitor it also checks that the number of elements is >0 and the the first element equals the last element. It reports an error if either of these conditions is not true.

The arguments for longArrayMonitorMain are:

channelName
The name for the arrayPerform record.
queueSize
The queueSize. Note that any size <2 is made 2.

longArrayGet

This is a pvAccess client that uses channelGet to access an arrayPerformance record. Every second it produces a report.

The arguments for longArrayGetMain are:

channelName
The name for the arrayPerform record.
iterBetweenCreateChannel
The number of iterations between destroying and recreating the channel. A value of 0 means never destroy and recreate.
iterBetweenCreateChannelGet
The number of iterations between destroying and recreating the channelGet. A value of 0 means never destroy and recreate.
delayTime
The time to delay between gets.

longArrayPut

This is a pvAccess client that uses channelPut to access an arrayPerformance record. Every second it produces a report.

The arguments for longArrayPutMain are:

channelName
The name for the arrayPerform record.
arraySize
The capacity and length of the array to put to the server.
iterBetweenCreateChannel
The number of iterations between destroying and recreating the channel. A value of 0 means never destroy and recreate.
iterBetweenCreateChannelPut
The number of iterations between destroying and recreating the channelPut. A value of 0 means never destroy and recreate.
delayTime
The time to delay between gets.