Closed mariocaptain closed 3 years ago
I am going to try PyPy to see if performance can be improved. Has anyone any experience with taurus on PyPy?
Hi, I've run taurus GUIs with ~20 models even on a R Pi model B (single core, 512Mb Ram). Certainly not fast, but usable.
I also used an RPi3 for the demo of "taurus big &small", which yo can find in the wiki.
So I would say that either we have some performance regression in the latest releases or there is some issue with your installation.
The one thing that is certainly slow is the first load of all py modules. This is much faster the second time you launch the GUI.
Re. pypi: never tried.
@cpascual thanks so much for your input. Yes, I do believe that taurus must be usable, since its used in sardana to control scientific systems. Also I believe the Pi 4 should be as powerful as any average systems at the time tango/taurus started.
I understand that the first load can be slow since lots of stuff need to be loaded, and I can live with that. Right now, I am setting up things in my Core i5 laptop for comparison, and thus far taurus has not been running yet but Python seems to be a lot faster. The reason I want to use with the Pi 4 is that I wanted to eventually use a Pi4 powered PLC to eliminate the need for a dedicated server.
Any further input would be greatly appreciated.
Regards, Dave
AFAIK, an RPi4 should be enough for running the whole stack of tango and taurus with a reasonable number of devices and attributes involved.
Any further input would be greatly appreciated.
Thanks! I will try as you advised. In the mean time, this is my code, which runs very smoothly on my Windows x64 laptop (Core i5, 4GB RAM) but hangs on the Pi 4 4GB RAM as soon as I expand the [+] of the device class to view all the devices of the class in the model chooser.
Loading this program on laptop takes about 2 seconds while on the Pi it is about ~10 seconds, but that should not be a big problem. I have one device server with 10 exported devices on the server only. jive works flawlessly on the Pi also. Furthermore, I notice that the hang only happens when trying to browse EXPORTED devices. I have verified this with both my device server and the TaurusTest.py device server.
import sys
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QMainWindow, QApplication, QPushButton, QWidget, QAction, QTabWidget,QVBoxLayout, QGridLayout
from PyQt5.QtGui import QIcon
from PyQt5.QtCore import pyqtSlot
class App(QMainWindow):
def __init__(self):
super().__init__()
self.title = 'Dashboard'
#self.setWindowFlags(Qt.WindowStaysOnTopHint | Qt.FramelessWindowHint)
self.table_widget = MyTableWidget(self)
self.setCentralWidget(self.table_widget)
self.showMaximized()
class MyTableWidget(QWidget):
def __init__(self, parent):
super(QWidget, self).__init__(parent)
self.layout = QGridLayout(self)
# Initialize tab screen
self.tabs = QTabWidget()
self.tab1 = QWidget()
self.tab2 = QWidget()
self.tab3 = QWidget()
self.tab4 = QWidget()
# Add tabs
self.tabs.addTab(self.tab1,"Trends")
self.tabs.addTab(self.tab2,"Manual Control")
self.tabs.addTab(self.tab3,"System")
self.tabs.addTab(self.tab4,"Log")
# First tab content
self.tab1.layout = QVBoxLayout(self)
from taurus.qt.qtgui.panel import TaurusModelChooser
self.modelChooser1 = TaurusModelChooser()
self.tab1.layout.addWidget(self.modelChooser1)
from taurus.qt.qtgui.extra_guiqwt import TaurusTrendDialog
self.trendDialog1 = TaurusTrendDialog()
self.tab1.layout.addWidget(self.trendDialog1)
self.trendDialog2 = TaurusTrendDialog()
self.tab1.layout.addWidget(self.trendDialog2)
self.tab1.setLayout(self.tab1.layout)
# Add tabs to main widget
self.layout.addWidget(self.tabs)
self.setLayout(self.layout)
@pyqtSlot()
def on_click(self):
print("\n")
for currentQTableWidgetItem in self.tableWidget.selectedItems():
print(currentQTableWidgetItem.row(), currentQTableWidgetItem.column(), currentQTableWidgetItem.text())
if __name__ == '__main__':
app = QApplication(sys.argv)
ex = App()
sys.exit(app.exec_())
Thanks!
Loading this program on laptop takes about 2 seconds while on the Pi it is about ~10 seconds, but that should not be a big problem. I have one device server with 10 exported devices on the server only. jive works flawlessly on the Pi also. Furthermore, I notice that the hang only happens when trying to browse EXPORTED devices. I have verified this with both my device server and the TaurusTest.py device server.
I think that the problem might be with the connection to the DB device. Note that Taurus does more connections than jive when connecting with a device and/or attribute, and is therefore more dependent on the network not being filtered.
Is the TangoDatabaseDS running locally both in the case of the windows and of the RPi4?
If not, you can first try to run a local DB in the RPi and use it, to discard any firewall issues.
Also, for simplifying the debugging, you can run the TaurusModelChooser
alone with:
python3 -m taurus.qt.qtgui.panel.taurusmodelchooser
- In my case I always tried with raspbian and installing Tango and Taurus from the official raspbian repositories.
Yes, I have just done a fresh installation of Raspbian buster, Tango, taurus and any minimum taurus requirements for the program to run in Python3; everything from the official raspbian repo, but the same result. Just one thing I noted that when I installed guiqwt as required by taurus, it installed SciPy and though guiqwt installation was successful, in the console it says that SciPy requires numpy >= 1.16.5 but I have 1.16.2 which is incompatible. I am not sure if this is the reason, so I tried to install higher versions of numpy via pip3 but all were broken. From raspbian repo only 1.16.2 is available.
Is the TangoDatabaseDS running locally both in the case of the windows and of the RPi4?
Yes, because eventually I plan to use some commercial Raspberry Pi 4 PLC(s).
I have just run:
python3 -m taurus.qt.qtgui.panel.taurusmodelchooser
on this freshly installed Pi 4 and the same result. You can see in the attached image the console output for that command, and what happens when I tried to close the form (after clicking to expand the TAURUSTEST device class).
P.S. I am using an SSD via USB 3.0, but for this fresh installation I just use a high quality micro SD just to make sure nothing to do with the SSD.
I see the RuntimeWarning in the console as you can see in the image, but I am not sure what that means and what causes that.
P.S. If the taurus team is so kind enough I would be so grateful to send over my 16GB SD image so you can replicate the problem. Kind regards, Dave
Just to update that I managed to install a higher numpy version via pip3 (1.17.2 in my case, needed to install libatlas3-base from apt-get first) to no avail.
I have just installed fresh Raspbian buster on a Pi 3 just to replicate the issue, and it's the same. Below are the steps I used to install taurus on the Pi 3 after flashing it with a fresh Raspbian Buster
Install mariadb-server
$sudo apt update
$sudo apt install mariadb-server
$sudo mysql -u root
MariaDB [mysql]> use mysql;
MariaDB [mysql]> update user set plugin='mysql_native_password' where user='root';
MariaDB [mysql]> flush privileges;
MariaDB [mysql]> exit;
$sudo service mysql restart
Install tango
$sudo apt install tango-db tango-common
Install java tools
$sudo apt install liblog4j1.2-java
$sudo apt install openjdk-8-jdk
Download libtango-java_9.2.5a-1_all.deb to ~/Downloads
$cd Downloads/
$sudo dpkg -i ./libtango-java_9.2.5a-1_all.deb
(jive tested to browse tango database just fine)
Install pytango
$sudo apt-get install python3-pytango
Install PyQt5
$sudo apt-get install python3-pyqt5
Install Taurus 4.7
$sudo pip3 install taurus
Install guiqwt
$sudo apt-get install libatlas3-base
$sudo pip3 install numpy==1.17.0
$sudo pip3 install guidata
$sudo pip3 install Cython
$sudo pip3 install guiqwt
Test taurus modelchooser Register the TaurusTest Device Server on Jive with 10 devices: Server: TaurusTest/taurustest Class: TaurusTest Devices: sys/taurustest/01 sys/taurustest/02 sys/taurustest/03 sys/taurustest/04 sys/taurustest/05 sys/taurustest/06 sys/taurustest/07 sys/taurustest/08 sys/taurustest/09 sys/taurustest/10
Run the device server
$ ~/python3 TaurusTest.py taurustest
In another terminal:
$python3 -m taurus.qt.qtgui.panel.taurusmodelchooser
I would be so grateful to send over my 16GB SD image
I do not think it is necessary for now. Since you provided the detailed installation instructions we can use them for trying to reproduce. The problem is that I do not have any spare RPi with me at the moment.
I'll try to find one, but ... maybe some other of the @taurus-org/integrators can do the test?
By looking at your installation steps, they all seem ok for me. The only thing that I normally do different is that I install default-mysql-server
instead of mariadb-server (but I think they are aliases) and I do not configure any password in mysql after installing it. While in principle this should not be relevant, it might actually be related, because the TangoDatabaseCache.refreshAttributes()
has an optional optimization that tries to speed up the TangoDB tree collection by querying the mysql server directly. I wonder if somehow your setup is blocking this direct mysql acces...
So, just to check this, please try a fresh install with:
# it is important to do this before the tango install
# just accept all defaults if prompted for anything
$sudo apt-get install default-mysql-server
# allow debconf to configure the tango db.
# If debconf asks for the DB name, user or password and does not offer a default, just use "tango"
$sudo apt-get install tango-db
#install tango-test DS (This will automatically export it)
$sudo apt-get install tango-test
# install taurus from the deb package (just for this test)
$sudo apt install python3-taurus
# check that tango-db is running
$sudo service tango-db status
# chek if it works with just the tango-test DS
$python3 -m taurus.qt.qtgui.panel.taurusmodelchooser
If this is smooth, then try exporting your 10 instances of TaurusTest and check if it is still ok
I do not configure any password in mysql after installing it.
I do not either. After installing mariadb-sever, the server has a blank password for root. The only problem is that it requires $sudo mysql -u root
instead of $mysql -u root
to login the database. So MariaDB [mysql]> update user set plugin='mysql_native_password' where user='root';
is for tango installation to be able to login to mariadb-server without sudo.
Thanks so much for your attention. I will do a fresh installation as advised tomorrow and see how things fare. Cheers. Dave
Hi all,
Maybe we could get some more information from the application logs? Could you please try to start a new taurus form which by default should open you a model chooser:
taurus --log-level=Trace form
And then try to reproduce the problem:
I expand the [+] of the device class to view all the devices of the class in the model chooser.
Please copy and paste here the application logs from the terminal.
Also, we could ask @dschick if he found similar problems in his setups. I know that he runs Sardana on Raspberry PI and I think he was also using Taurus.
Cheers!
taurus --log-level=Trace form
This is the output in the console:
pi@raspberrypi:~ $ taurus --log-level=Trace form
MainThread DEBUG 2021-02-03 15:38:18,230 TaurusRootLogger: Qtqt5ct None.None[0]: using qt5ct plugin
MainThread DEBUG 2021-02-03 15:38:18,326 TaurusApplication: Failed to load sardana extensions
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/taurus/qt/qtgui/application/taurusapplication.py", line 255, in __registerExtensions
import sardana.taurus.qt.qtcore.tango.sardana
ModuleNotFoundError: No module named 'sardana'
MainThread TRACE 2021-02-03 15:38:18,329 TaurusManager: reInit()
MainThread DEBUG 2021-02-03 15:38:18,329 TaurusManager.TaurusTP: Starting TaurusTP.W001
MainThread DEBUG 2021-02-03 15:38:18,330 TaurusManager.TaurusTP: Starting TaurusTP.W002
MainThread DEBUG 2021-02-03 15:38:18,332 TaurusManager.TaurusTP: Starting TaurusTP.W003
MainThread DEBUG 2021-02-03 15:38:18,332 TaurusManager.TaurusTP: Starting TaurusTP.W004
MainThread DEBUG 2021-02-03 15:38:18,333 TaurusManager.TaurusTP: Starting TaurusTP.W005
MainThread DEBUG 2021-02-03 15:38:18,334 TaurusManager.TaurusTSP: Starting TaurusTSP.W001
MainThread DEBUG 2021-02-03 15:38:18,358 TaurusManager: Found plugin EpicsFactory
MainThread DEBUG 2021-02-03 15:38:18,365 TaurusManager: Found plugin EvaluationFactory
MainThread DEBUG 2021-02-03 15:38:18,366 TaurusManager: Found plugin TangoFactory
MainThread DEBUG 2021-02-03 15:38:18,368 TaurusManager: Found plugin ResourcesFactory
This is before clicking on the [+]. Clicking on it doesn't expand and doesn't produce any additional text on the console.
As shown, though I am not sure what sardana has to do here, I just install sardana:
$pip3 install sardana
This time, this is the output of the console when running that command, and the hang is still there.
pi@raspberrypi:~ $ taurus --log-level=Trace form
MainThread DEBUG 2021-02-03 15:43:22,244 TaurusRootLogger: Qtqt5ct None.None[0]: using qt5ct plugin
MainThread TRACE 2021-02-03 15:43:22,370 TaurusManager: reInit()
MainThread DEBUG 2021-02-03 15:43:22,370 TaurusManager.TaurusTP: Starting TaurusTP.W001
MainThread DEBUG 2021-02-03 15:43:22,371 TaurusManager.TaurusTP: Starting TaurusTP.W002
MainThread DEBUG 2021-02-03 15:43:22,372 TaurusManager.TaurusTP: Starting TaurusTP.W003
MainThread DEBUG 2021-02-03 15:43:22,372 TaurusManager.TaurusTP: Starting TaurusTP.W004
MainThread DEBUG 2021-02-03 15:43:22,373 TaurusManager.TaurusTP: Starting TaurusTP.W005
MainThread DEBUG 2021-02-03 15:43:22,373 TaurusManager.TaurusTSP: Starting TaurusTSP.W001
MainThread DEBUG 2021-02-03 15:43:22,397 TaurusManager: Found plugin EpicsFactory
MainThread DEBUG 2021-02-03 15:43:22,405 TaurusManager: Found plugin EvaluationFactory
MainThread DEBUG 2021-02-03 15:43:22,405 TaurusManager: Found plugin TangoFactory
MainThread DEBUG 2021-02-03 15:43:22,407 TaurusManager: Found plugin ResourcesFactory
After offering the [+] node some patience playing around, please let me correct the situation a little. In fact, clicking on the [+] node of the device class doesn't really hang the form, the form just behaves like it is doing some heavy work inside. The thing is, after 3 minutes it DOES EXPAND and things become responsive again. Then clicking [+] to further expand child nodes (device, device attributes) works very smoothly. During the 3 minutes before it works, trying to close the form will result in the system saying the form not responding.
This applies for both cases, with or without sardana installed.
The thing is, after 3 minutes it DOES EXPAND and things become responsive again. Then clicking [+] to further expand child nodes (device, device attributes) works very smoothly.
This further points in the direction of a problem with the TangoDatabaseCache.refresh()
So, in order to try to debug it, please try with an installation such as I described in my previous comment, and the run the following:
import time
t1 = t2 = time.time()
import taurus
#taurus.setLogLevel(taurus.Debug)
t1, t2 = t2, time.time()
print('----------start--------', t2 - t1)
db = taurus.Authority()
t1, t2 = t2, time.time()
print('----------get db-------', t2 - t1)
c = db.cache()
t1, t2 = t2, time.time()
print('----------cache--------', t2 - t1)
c.refresh()
t1, t2 = t2, time.time()
print('----------refresh------', t2 - t1)
If creating the cache or its refresh take a long time, we have found the issue. As a reference, in my laptop (i5 with buster), the output is (note that I run it twice, the first time after restarting the DB server in order to clean server-side caches) :
$ sudo service tango-db restart && python3 scratch_130.py
----------start-------- 0.5171859264373779
----------get db------- 0.189711332321167
----------cache-------- 0.014218330383300781
----------refresh------ 0.010216712951660156
$ python3 scratch_130.py
----------start-------- 0.5169785022735596
----------get db------- 0.19643330574035645
----------cache-------- 0.01411294937133789
----------refresh------ 0.010594844818115234
And, if I manually edit the code of taurus.core.tango.tangodatabase.TangoDatabaseCache.refresh()
to disable the direct mysql optimization, I get:
$ sudo service tango-db restart && python3 scratch_130.py
----------start-------- 0.5133464336395264
----------get db------- 0.19513273239135742
----------cache-------- 0.18700432777404785 # <------- (!)
----------refresh------ 0.07627725601196289
$ python3 scratch_130.py
----------start-------- 0.5354924201965332
----------get db------- 0.19304943084716797
----------cache-------- 0.09884452819824219
----------refresh------ 0.06628775596618652
Note that the times without the optimization are ~10 times larger than with the optimization when the server-side cache is fresh (and this is with a small DB, it gets a lot worse with a large DB)
Also, you can try to reproduce the code that is used in TangoDatabaseCache.refresh()
for optimized mysql access :
import taurus
#taurus.setLogLevel(taurus.Debug)
db = taurus.Authority() # should return the tango authority by default
print('---------db-------', db)
db_dev_name = '/'.join((db.getFullName(), db.dev_name()))
print('--db_dev_name-----', db_dev_name)
# check if the optimized access works
print('--DbMySqlSelect?--', hasattr(taurus.Device(db_dev_name), 'DbMySqlSelect'))
query = "SELECT name, alias, exported, host, server, class FROM device"
r = db.command_inout("DbMySqlSelect", query)
row_nb, column_nb = r[0][-2:]
data = r[1]
assert row_nb == len(data) // column_nb
print('-- it works --')
My output is:
$ python3 scratch_129.py
---------db------- TangoAuthority(//pt168.cells.es:10000)
--db_dev_name----- tango://pt168.cells.es:10000/sys/database/2
--DbMySqlSelect?-- True
-- it works --
Hi all,
We are using Taurus from the latest development branch on Raspi3B and 4 using the default raspberian. We use tango 9.2.5 and pytango 9.2.5 from the official debian repos.
Most of the GUIs run very smoothly at the beginning and start to become slow after a while. I guess this has to do with memory consuption and maybe with the slow SD cards we are using as storage.
I could share our installation recipie or run some tests if required.
Best
Daniel
Hi @dschick , thanks for helping!
Are you using your RPis with local tango DB, or is the DB external?
Could you please test if the ModelChooser is slow when expanding the Device node of the tree?
Also, could you please run and report the outputs of the scripts that I posted in my 2 previous comments?
So, in order to try to debug it, please try with an installation such as I described in my previous comment, and the run the following:
Thanks so much. I will try all that you have advised on this weekend and let you know. Cheers, Dave
Hi all,
we are using an external DB which runs on a Linux PC in the local network in which all PIs are in.
The ModelChooser is very responsive.
Output of your first script:
pi@raspi02:/tmp $ python3 testtaurus.py
----------start-------- 1.4442510604858398
----------get db------- 0.4887545108795166
----------cache-------- 0.060941219329833984
----------refresh------ 0.057290077209472656
and of the second
python3 testtaurus2.py
---------db------- TangoAuthority(//ampere.sxr.lab:10000)
--db_dev_name----- tango://ampere.sxr.lab:10000/sys/database/2
--DbMySqlSelect?-- True
-- it works --
I remember that Sardana was really slow on our raspis due to https://github.com/sardana-org/sardana/issues/1417 Also check my post in the tango forum: https://www.tango-controls.org/community/forum/c/general/other/multiple-network-interfaces/
So essentiall the TangoDB is running on a host with multiple network interfaces. With the tango version 9.2.5 this caused some issues and API Event Timeouts which made Sardana and i think also Taurus very slow.
I solved the issue by adjusting the omiORB.conf, but you could also start the tangoDB directly with the ORBendPoint
option.
Alternatively, you might use tango 9.3.4 which should work better with multiple network interfaces.
Best
Daniel
So, just to check this, please try a fresh install with:
# it is important to do this before the tango install # just accept all defaults if prompted for anything $sudo apt-get install default-mysql-server # allow debconf to configure the tango db. # If debconf asks for the DB name, user or password and does not offer a default, just use "tango" $sudo apt-get install tango-db #install tango-test DS (This will automatically export it) $sudo apt-get install tango-test # install taurus from the deb package (just for this test) $sudo apt install python3-taurus # check that tango-db is running $sudo service tango-db status # chek if it works with just the tango-test DS $python3 -m taurus.qt.qtgui.panel.taurusmodelchooser
If this is smooth, then try exporting your 10 instances of TaurusTest and check if it is still ok
I followed this, but with some modifications:
$sudo apt install python3-taurus
doesn't exist. So I have to install taurus from pip3Strangely, after launching $python3 -m taurus.qt.qtgui.panel.taurusmodelchooser
the modelchooser is empty (no device classes, devices etc.) because there is an exception. jive still works flawlessly browsing the database. Below is console output describing the exception.
pi@raspberrypi:~ $ python3 -m taurus.qt.qtgui.panel.taurusmodelchooser
MainThread INFO 2021-02-07 05:36:20,440 TaurusRootLogger: Using PyQt5 (v5.11.3 with Qt 5.11.3 and Python 3.7.3)
/usr/lib/python3.7/runpy.py:125: RuntimeWarning: 'taurus.qt.qtgui.panel.taurusmodelchooser' found in sys.modules after import of package 'taurus.qt.qtgui.panel', but prior to execution of 'taurus.qt.qtgui.panel.taurusmodelchooser'; this may result in unpredictable behaviour
warn(RuntimeWarning(msg))
MainThread INFO 2021-02-07 05:36:21,936 TaurusRootLogger: Cannot populate Tango Tree: TaurusException("Cannot create Factory for 'tango'")
MainThread WARNING 2021-02-07 05:36:22,370 TaurusRootLogger: Qtdefault None.None[0]: libpng warning: iCCP: known incorrect sRGB profile
MainThread WARNING 2021-02-07 05:36:22,374 TaurusRootLogger: Qtdefault None.None[0]: libpng warning: iCCP: known incorrect sRGB profile
I will try further and update.
UPDATE 1:
The exception is solved by installing pytango after installing taurus: $sudo apt-get install python3-pytango
. The modelchooser is very responsive even with TangoTest device server running: $sudo /usr/lib/tango/TangoTest test
UPDATE 2:
So I proceed to export the 10 TaurusTest devices, and guess what, modelchooser WORKS LIKE A CHARM.
So the solution is to install mysql/mariadb using $sudo apt-get install default-mysql-server
instead of $sudo apt install mariadb-server
.
Thanks a ton all!
modelchooser WORKS LIKE A CHARM.
I am very glad it works well now!
$sudo apt install python3-taurus doesn't exist. So I have to install taurus from pip3
Ah, my fault!: the python3 version is not available for buster in the official repos (we have it, but it is on internal repos, which we plan on making public this year). Te official repos have only an older python2 version (python-taurus_4.5).
Hi all,
I have been trying taurus on a Raspberry Pi 4B (Quadcore x 1.5Ghz, 4GB RAM) and so far every GUI built by taurus is very unresponsive. I am not sure if I am doing anything wrong, or is taurus meant for much more powerful workstations? I am using Python3 with the latest taurus (4.7)
PyTango works fine. The TaurusTest example works just fine, but I should say that it loads very slow, and once it loads the form is just usable, not overly responsive.
To further try taurus, I built a widget (form) on Qt Designer (4 and 5) which contains just a single Model chooser (or a few other widgets) and load the .ui in python/taurus code.
The .py file takes very long to load, and once it loads, everything is very unresponsive and eventually hangs when I try to interact with the widget (expand device class nodes). Jive still works smoothly so nothing to do with tango db server I think.
In my application I have around a hundred devices to monitor and the idea is to use taurus to quickly develop a full feature HMI, but it doesn't really work well for a single test device. This really surprises me as taurus seems to be very professional and meant for large systems.
Has taurus been deployed for such a scale or larger? Any minimum system requirement to run taurus as mooth as possible?
I definitely don't want to have to switch to C++ for GUI building because it would take me a lot of time learning and trying.
Thanks in advance. Dave
I read that python can be as much as 100 times slower than C++ because of several reasons, one of which is it being single threaded. I can bear with this fact so long as the application built (python/taurus) is usable and reliable.