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  <20132014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  <20132014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: PyEpics speed
From: Matt Newville <[email protected]>
To: Jeremy Iken <[email protected]>
Cc: [email protected]
Date: Mon, 24 Jun 2013 11:50:00 -0500
Hi Jeremy,

On Mon, Jun 24, 2013 at 10:29 AM, Jeremy Iken <[email protected]> wrote:
> Hi,
>
> I am using the Python PyEpics3 tool (UChicago), and it seems to take about
> 0.2 seconds to caget() my PV.
>
> For safety, my system will need the fastest control system.
>
> Why does EPICS take so long? Do all tools take this long? Is this just a
> Python problem?

It shouldn't take that long, and PyEpics should not be significantly
slower that C at this.  Lewis's suggestion of testing the same PV with
the command-line caget will nicely separate network issues from Python
issues.  And, like Bob says, some PVs are actually that slow.

But, if command-line caget is much faster that PyEpics, here are a
couple of things to consider:

PyEpics' caget() does use a connection callback and does create a
subscription to the PV.  I believe those don't happen in the
command-line caget utility (someone please correct me if that's
wrong).  In addition, the first call to caget() may initialize the CA
library, creating a context.  This approach could be what is causing
an initial delay (but it shouldn't be 200 ms).    These differences
are designed to make subsequent calls to caget() much faster -- there
is a subscription and callbacks with updated values will happen in the
background so that the next caget() will have the latest value.

So one thing to try (after Lewis's suggestion, of course) is whether a
second caget() on the same PV also take a long time.

PyEpics' caget() is approximately
   pv = PV(pvname)
   pv.connect()
   return pv.get()

so another thing to try would be to break that apart and see which
part is taking all that time.  The creation should be very fast, and
the connect() (which waits for the connection callback to complete)
should also be fast.   The get() will wait for the monitor callback
defined in the connection callback to be run.    Again, that should be
fast, and normally a simple
   pv = PV(pvname)
   pv.get()

is very fast, and all the connection and monitor callbacks happen in
the background.

If you're looking to go as fast as possible with PyEpics, especially
for connecting to a large number of PVs, you may want to look at
   http://cars.uchicago.edu/software/python/pyepics3/advanced.html#strategies-for-connecting-to-a-large-number-of-pvs

Hope that helps,

--Matt Newville

References:
PyEpics speed Jeremy Iken

Navigate by Date:
Prev: Re: Problem in errlogRemoveListener Michael Abbott
Next: Re: PyEpics speed Daron Chabot
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  <20132014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: RE: PyEpics speed Dalesio, Leo
Next: Re: PyEpics speed Daron Chabot
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  <20132014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 20 Apr 2015 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·