Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. QApplication constructor taking very long time on Raspberry Pie python3 PyQt5
QtWS25 Last Chance

QApplication constructor taking very long time on Raspberry Pie python3 PyQt5

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
qt5 raspberry ppyqt5raspberry pi
6 Posts 2 Posters 1.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Marek Stocki
    wrote on last edited by Marek Stocki
    #1

    I am investigating extremely slow start of a python3 script running on Raspberry Pi and nailed it down to QApplication constructor. To confirm, I have created TestQt.py:

    from sys import argv
    from PyQt5.QtWidgets import QApplication
    
    app = QApplication(argv)
    

    It takes 45-49 seconds to execute, e.g.

    pi@raspberrypi:~/test-dir $ time python3 TestQt.py
    
    real   0m48.973s
    user   0m0.394s
    sys    0m0.106s
    

    While it starts, top shows very low CPU usage. Therefore, I suspect some I/O timing out, so it is probably more related to Qt5 than to python.
    Have anyone here ever seen anything like that? I would be grateful if you could share any advice, please.

    JonBJ 1 Reply Last reply
    0
    • M Marek Stocki

      I am investigating extremely slow start of a python3 script running on Raspberry Pi and nailed it down to QApplication constructor. To confirm, I have created TestQt.py:

      from sys import argv
      from PyQt5.QtWidgets import QApplication
      
      app = QApplication(argv)
      

      It takes 45-49 seconds to execute, e.g.

      pi@raspberrypi:~/test-dir $ time python3 TestQt.py
      
      real   0m48.973s
      user   0m0.394s
      sys    0m0.106s
      

      While it starts, top shows very low CPU usage. Therefore, I suspect some I/O timing out, so it is probably more related to Qt5 than to python.
      Have anyone here ever seen anything like that? I would be grateful if you could share any advice, please.

      JonBJ Online
      JonBJ Online
      JonB
      wrote on last edited by
      #2

      @Marek-Stocki
      I know nothing about Pi [sic.]. But under Linux you may get a idea of what a program is doing, especially when it pauses and you look at the latest line, if you run strace <your-executable>, assuming Pi has strace.

      1 Reply Last reply
      2
      • M Offline
        M Offline
        Marek Stocki
        wrote on last edited by
        #3

        Thanks a lot, Jon. Unfortunately, the strace log shows over 4000 syscalls for this single function call. :-( None of them is individually taking a long time, and they are quite evenly spread in time, just the number is overwhelming. Do you know, if it is typical for QApplication constructior or may indicate a problem?

        JonBJ 1 Reply Last reply
        0
        • M Marek Stocki

          Thanks a lot, Jon. Unfortunately, the strace log shows over 4000 syscalls for this single function call. :-( None of them is individually taking a long time, and they are quite evenly spread in time, just the number is overwhelming. Do you know, if it is typical for QApplication constructior or may indicate a problem?

          JonBJ Online
          JonBJ Online
          JonB
          wrote on last edited by JonB
          #4

          @Marek-Stocki
          Hmmm :(

          This is really beyond my knowledge, you need someone more expert than I to comment....

          • Google qapplication slow. There are just a few hits, mostly quite old, but worth reading through each one for ideas.

          • I assume you cannot test a C++ application? It only takes a little time to download/setup PySide2, try that to eliminate PyQt5 from being the issue?

          • It won't be this, but do check some non-Qt Python script startup time, just in case.

          • Try the lowest level QCoreApplication (no UI) instead of QApplication. Any better?

          • 4,000 syscalls in 40 seconds is 100 per second which is actually quite slow/high per syscall average. If you let the output run in a terminal in realtime you don't see any "pauses" at any point? If you redirect to file you then have to quite some analysis! Edit the file, delete out lines you're not interested in iteratively to try to narrow down. Some syscalls show filepath access, look at those, do they look like reasonable files for startup to look at?

          • What exact version of Qt are you using? Did it come with Pi or did you build yourself (make sure it's a release not a debug build)? Can you try a different version? Can you completely uninstall, check for any remaining Qt artefacts, re-install?

          Do you know, if it is typical for QApplication constructior or may indicate a problem?

          40 seconds startup indicates a problem! ;-)

          1 Reply Last reply
          1
          • M Offline
            M Offline
            Marek Stocki
            wrote on last edited by
            #5

            Thanks. I could not install PySide2 on my system, but I have managed to install PySide 1.2.4 that works with python 2.7.16 and Qt 4.8.7. With this setup, the execution time for my TestQt.py script was reduced to ~26 s. It may be OKish for a 600 MHz CPU of the Pi. Next, I will check if our software can be adapted for Python 2.7.

            JonBJ 1 Reply Last reply
            0
            • M Marek Stocki

              Thanks. I could not install PySide2 on my system, but I have managed to install PySide 1.2.4 that works with python 2.7.16 and Qt 4.8.7. With this setup, the execution time for my TestQt.py script was reduced to ~26 s. It may be OKish for a 600 MHz CPU of the Pi. Next, I will check if our software can be adapted for Python 2.7.

              JonBJ Online
              JonBJ Online
              JonB
              wrote on last edited by
              #6

              @Marek-Stocki
              Wait, wait! You absolutely do not want to move a Python3 application back to Python2! Trust me :)

              Even 26 seconds startup is quite unacceptable. Start up should be like ~1 second!! There is something wrong.....

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved