EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  <20232024  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  <20232024 
<== Date ==> <== Thread ==>

Subject: Strange time consumption in multi thread CA Client program
From: wzhy via Tech-talk <tech-talk at aps.anl.gov>
To: "tech-talk" <tech-talk at aps.anl.gov>
Date: Mon, 26 Jun 2023 10:39:04 +0800
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!

Replies:
Re: Strange time consumption in multi thread CA Client program Mark Rivers via Tech-talk

Navigate by Date:
Prev: Re: Real-Time Spectral Analysis of streaming data in EPICS operator screens. Ralph Lange via Tech-talk
Next: Re: Strange time consumption in multi thread CA Client program Mark Rivers via Tech-talk
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  <20232024 
Navigate by Thread:
Prev: Open position in Controls @ PSI - control system specialist Celcer Tine via Tech-talk
Next: Re: Strange time consumption in multi thread CA Client program Mark Rivers via Tech-talk
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  <20232024 
ANJ, 26 Jun 2023 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·