Results 1 to 4 of 4

Thread: Poor asynchronous performance in PyQT

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2017
    Posts
    3
    Thanks
    2
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Poor asynchronous performance in PyQT

    Recently I really got into async stuff in Python. Unfortunately, it seems like Python's stock asynchronous capabilities do not mesh well with Qt's QEventLoop.

    Boiled down test program: receive stuff from a client on a socket and insert rows into an QAbstractTableModel that's connected to a QTableView. Receive a message, create a new row in a table -- real simple.

    Threaded test code uses socketserver module. Async code uses asyncio.Server, while Quamash is used to "bridge the gap" between Python's native async and QEventLoop (it should be noted that replacing Quamash with a bare-bones solution has no effect on the program. uvloop doesn't help either).
    All Qt-relevant code is shared, so there's no difference in views or models.

    Threaded program has no problem receiving and displaying tens of thousands messages per second. Asynchronous program can barely handle 150 messages per second.
    The peculiar thing is that the size of the window has a great effect on the async program. If I make it full screen, it drops to 70 messages per second. If I make it the smallest it can be, then it reaches 350 messages per second. If I hide the table view completely, the program becomes practically as fast as the threaded one.


    Is this how Qt normally behaves in asynchronous Python code? If not, I would really appreciate some explanation of why it could be acting like this.

    But if you think I should not bother with QEventLoop stuff, then I see 2 options:
    • Rip out all the async stuff and just write synchronous threaded code like a normal person? This is a feasible option, because I don't really need async in this project, I just wanted to have it because I like it and it has its benefits.
    • Fork async server stuff out into a thread and keep the Qt stuff synchronous? I tried this, it's maximum jank, but at least it's as fast as I need it to be. Could probably be a reasonable solution with some architectural changes to the project.


    Any advice is welcome, since there's barely any information on this topic.

    P.S. I didn't bother to include any code, sorry. Tell me if you feel like it's necessary. It'll take a bit of time, though.
    Last edited by busimus; 12th October 2017 at 18:02.

Similar Threads

  1. DashLine drawing poor performance
    By jecaro in forum Qt Programming
    Replies: 0
    Last Post: 11th August 2010, 14:46
  2. QTableView - resizeRowsToContents() poor performance
    By antarctic in forum Qt Programming
    Replies: 2
    Last Post: 11th December 2009, 14:13
  3. Poor OpenGL performance
    By rakkar in forum Newbie
    Replies: 1
    Last Post: 3rd September 2009, 20:51
  4. Qt4 poor printing performance
    By seneca in forum Qt Programming
    Replies: 4
    Last Post: 22nd January 2009, 15:23
  5. Poor performance with Qt 4.3 and Microsoft SQL Server
    By Korgen in forum Qt Programming
    Replies: 2
    Last Post: 23rd November 2007, 11:28

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.