Significant differences in the performance of read requests from a Sardana MotorController DS and from PyTango DS
|
|
---|---|
I have measured the read time of the position of a motor which is implemented as a child class of the Sardana MotorController. I have used %%timeit in a jupyter notebook. Although there is no communication with the HW, the query takes 6.8 msec, that is very slow in my opinion. In contrast, reading a double attribute of a pure PyTango DS takes only 0.25 msec. is it normal behavior of Sardana or is something wrong in my setup? I use Sardana 3.5.0 and PyTango 9.4.1 in a conda env on ubuntu 20.04. How to reproduce:
|
|
|
---|---|
Hi Alex I tried the same thing, with Sardana and the other Tango device all running on the same computer. Timing from Spock. I also tried with a cppTango device server. I don't see much difference. The standard deviation is much lower with cppTango directly.
Maybe there is a something else that is keeping your Sardana pool busy, and slowing down the responses from the motor? |
|
|
---|---|
Dear Anton, Thank you for the quick reply. I observe the same behavior for Sardana Demo Motor. But for my MotorController it is much slower.
I can't understand this, because in the ReadOne method I simply return a number just to be sure that there is no interaction with the hardware:
What could be the cause of this behavior? |
|
|
---|---|
Hi Alex I tried with one of our custom motor controllers, also modified so ReadOne returns a fixed value. I noticed that reading position, also reads the state of the controller (so StateAll and StateOne get executed). That caused quite a delay, since Tango device it was connecting to was offline. After modifying the StateAll method to ignore the Tango device, the time per read dropped from about 1 millisecond to microseconds, similar to the dummy motor. /Anton |
|
|
---|---|
Hello Anton, thanks for the clarification. Indeed, mot.position triggers StateOne(). Why is this happening? According to this image in the Sardana docs, StartOne() should not be called. I am wondering, why should StateAll() (and ReadAll()) have an effect, because the implementation of Controller:StateAll is just “pass” and I did not override this method. On the other hand, I wonder why StateOne() is not called when the motor controller is started. That's what I want: StateOne() is called at startup and with a low repetition rate when the axis is stopped. When the axis is moving, StateOne() should be called frequently, that happens as expected. When I call mot.position, it should call ReadOne() use the cached value without HW access. Is it possible to achieve this behavior with a “pure” Sardana motor controller without interfacing a Tango DS? A Q outside the topic: is in the Sardana MotorController class something like self.debug_stream() availiable? Can you give me a hint, which are the best practice how to debug sardana code? |