Results 1 to 11 of 11

Thread: Why is QtConcurrent so slow?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Nov 2009
    Posts
    22
    Thanks
    2

    Default Re: Why is QtConcurrent so slow?

    Quote Originally Posted by wysota View Post
    What does QThread::idealThreadCount() return?
    It returns 2, and I'm running Linux on a dual-core Intel.

    There is some kind of system overhead when running more than one thread, and that causes multi-threaded version of all examples I've tried to run drastically slower than the single-threaded version. I just can't figure out what it is.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,372
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Why is QtConcurrent so slow?

    Is your system doing anything heavy in the background? Does your system have free memory or is it swapping?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Nov 2009
    Posts
    22
    Thanks
    2

    Default Re: Why is QtConcurrent so slow?

    Quote Originally Posted by wysota View Post
    Is your system doing anything heavy in the background? Does your system have free memory or is it swapping?
    No, my system isn't doing anything heavy, and I have more than enough ram on it. 2GB total, and i'm not running anything else that would exhaust the CPU or memory.

    Question: Does the multi-threaded version (using QtConcurrent::map or mapped) run faster than the single-threaded version on your system??

  4. #4
    Join Date
    Jul 2009
    Posts
    139
    Thanks
    13
    Thanked 59 Times in 52 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Why is QtConcurrent so slow?

    rand() is not thread-safe*. Changing to rand_r and re-running, the multi-threaded version takes slightly less real time, although about 50% extra user time, so there is reasonable overhead using QtConcurrent for very short tasks.

    *Or maybe rand is thread safe and the extra time is waiting for a lock on the state information kept by rand.
    Last edited by numbat; 29th December 2009 at 10:44.

Similar Threads

  1. Very slow repainting ofPixmaps in QGraphicsView images
    By drexiya in forum Qt Programming
    Replies: 3
    Last Post: 21st October 2009, 18:13
  2. Why is drawText so terribly slow?
    By Ntoskrnl in forum Qt Programming
    Replies: 8
    Last Post: 1st August 2008, 19:15
  3. QtConcurrent Performance
    By tomf in forum Qt Programming
    Replies: 3
    Last Post: 15th July 2008, 15:41
  4. QTextEdit slow to insert text
    By thomaspu in forum Qt Programming
    Replies: 4
    Last Post: 10th January 2008, 12:05

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
  •  
Qt is a trademark of The Qt Company.