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: Re: Strange time consumption in multi thread CA Client program
From: "Sinclair, John via Tech-talk" <tech-talk at aps.anl.gov>
To: tech-talk <tech-talk at aps.anl.gov>, wzhy <wzhy66 at foxmail.com>, Mark Rivers <rivers at cars.uchicago.edu>
Date: Mon, 26 Jun 2023 17:02:44 +0000
Hi,

Have you done anything to ensure that each individual thread is always running on a single cpu? Otherwise calling start=clock() might be sampling the clock of a different cpu than end=clock().

John Sinclair
ORNL


From: Tech-talk <tech-talk-bounces at aps.anl.gov> on behalf of Mark Rivers via Tech-talk <tech-talk at aps.anl.gov>
Sent: Monday, June 26, 2023 9:31 AM
To: tech-talk <tech-talk at aps.anl.gov>; wzhy <wzhy66 at foxmail.com>
Subject: [EXTERNAL] Re: Strange time consumption in multi thread CA Client program
 
Hi,

You said:
  • I can see the camonitor within base/bin/win32-x86 suspend at the same time 
That implies you have built for the win32-x86 architecture, which is 32-bits.

You also said:
  • My hardware is i7-3770, 8G RAM. The OS is Microsoft Windows 7_64bit
That means your machine is 64-bit capable.  What is EPICS_HOST_ARCH set to, win32-x86 or windows-x64?  I suggest using windows-x64 and see if the problem still happens.

Mark




From: Tech-talk <tech-talk-bounces at aps.anl.gov> on behalf of wzhy via Tech-talk <tech-talk at aps.anl.gov>
Sent: Sunday, June 25, 2023 9:39 PM
To: tech-talk <tech-talk at aps.anl.gov>
Subject: Strange time consumption in multi thread CA Client program
 
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!

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

Navigate by Date:
Prev: Re: Strange time consumption in multi thread CA Client program Mark Rivers via Tech-talk
Next: Strangeness in ai/mbbiDirect with StreamDevice on PINI Leblanc, Gregory 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: Re: Strange time consumption in multi thread CA Client program Mark Rivers via Tech-talk
Next: Strangeness in ai/mbbiDirect with StreamDevice on PINI Leblanc, Gregory 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 ·