Hello EPICS community!
I'm writing a multi thread CA client test program to find the performance of CA put with softIOC using C language. My program is like this:
preemptive_thread_handle_function()
{
ca_attach_context(pcaput_context);
for (i = 0; i < pv_cnt; i++)
{
switch (pv's dbr_type)
{
case CHAR:
ca_array_put(DBR_CHAR, 1, pCh, value);
break;
case SHORT:
ca_array_put(DBR_SHORT, 1, pCh, value);
break;
case LONG:
ca_array_put(DBR_LONG, 1, pCh, value);
break;
case FLOAT:
ca_array_put(DBR_FLOAT, 1, pCh, value);
break;
case WAVEFORM:
ca_array_put(DBR_CHAR, array_cnt, pCh, value);
break;
}
}
ca_flush_io();
}
There are 3 threads to run this, and each thread's pv_cnt is ~3000. The main program is a infinite loop to schedule all the threads.
After running for servel mininutes,strange time consumption occured during the for loop with no rules.
The time measure code is like this:
clock_t start, end;
start = clock();
for (i = 0; i < pv_cnt; i++)
{...}
ca_flush_io();
end = clock();
double dt = (double)(end - start) / CLOCKS_PER_SEC;
printf("create_pv dt=%lf\n", dt);
In most time, the dt is ~0.002s, sometimes is ~0.015s. But suddenly, it becomes a number ~5.0s and I can see the camonitor within base/bin/win32-x86 suspend at the same time clearly.
After that, it resumes ~0.002s. The 5.0s appeared 6 times in half an hour.
EPICS base version is 3.15.8(win32_x86). My hardware is i7-3770, 8G RAM. The OS is Microsoft Windows 7_64bit and the dev IDE is Microsoft Visual Studio 2017.
My test program used CPU ~25%(60s Ave) shown by the Windows Process Monitor.Before I run my test program, the softIoc.exe starts like this:
softIoc.exe -D softIoc.dbd -d test1.db -d test2.db -d test3.db
My question is: All the PVs' type and count are fixed, why CA put consumed different time? How to avoid 5.0s situation?
Any hint and help will be appreciated.
Thank you very much!