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  <20122013  2014  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  <20122013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: Strategies for working with fast-changing large arrays
From: Matt Newville <[email protected]>
To: [email protected]
Cc: [email protected]
Date: Thu, 12 Jan 2012 11:06:43 -0600
Hi Michael, Anton, All,

Thanks for the report.   FWIW, pyepics uses preemptive callbacks by
default, but I still see dropped frames, independent of the context
model.   After some further testing, I believe this is due to the
conversion of data from C to Python, which is not too surprising.  The
culprit is, as earlier in this conversation, with the '_unpack'
function which does the C-Python data conversion.

For CHAR waveforms, such as images from a Prosilica camera, the
current code has a test for converting to a CHAR waveform is (ca.py,
line 815)
        # waveform data:
        if ntype == dbr.CHAR:
            if use_numpy:
                data = numpy.array(data)
            return copy(data[:])

where 'data' is the still-ctypes data (an unsigned byte Array:
c_ubyte_Array).  Ignoring the 'use_numpy' option, the 'return
copy(data[:])' does two things:
   a) makes a copy to avoid memory overwrites -- I've seen this on some systems.
   b) takes a slice of the whole array 'data[:]' which converts the
ctypes ubyte Array to a list.  This appears to be the slow part.

Replacing that with
        # waveform data:
        if ntype == dbr.CHAR:
            if use_numpy:
                data = numpy.array(data)
            return copy(data)

allows color images from a 1.4Mb camera (so 4177920 data) to be
received at full speed.  The downside is that the data is still a
ctypes array and has to be converted *somewhere* to something useful
to python, though this is simply 'data=data[:]'.   Doing this inside
the user-level callback still causes frames to be dropped, as that is
still run "inside" the event handler.   It might be possible that
running the user callback in a separate thread or expecting the user
to store the data in the callback and convert in a separate
thread/process would work, but I haven't tried that yet.

I'm not sure how cothread handles such an scenario, but I guess it
runs callbacks in a separate thread.

I'm also not sure whether the above change is the best idea for
default use, but having a 'DONT UNPACK' option for each PV/ChannelID
might be a useful option.  In this case, for example, it might allow a
faster image processing and display program, at least in the sense
that fewer frames would be dropped.

Any suggestions on whether that would be a useful addition?

--Matt

Replies:
RE: Strategies for working with fast-changing large arrays michael.abbott
References:
Re: pyepics: Strategies for working with fast-changing large arrays Anton Derbenev
Re: pyepics: Strategies for working with fast-changing large arrays Andrew Johnson
RE: Strategies for working with fast-changing large arrays michael.abbott

Navigate by Date:
Prev: RE: Does areaDetector Prosilica driver support Manta-series camera ? Davidsaver, Michael
Next: RE: Does areaDetector Prosilica driver support Manta-series camera ? Mark Rivers
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  <20122013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: RE: Strategies for working with fast-changing large arrays michael.abbott
Next: RE: Strategies for working with fast-changing large arrays michael.abbott
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  <20122013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 18 Nov 2013 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·