Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QThread performance
Forum Updated to NodeBB v4.3 + New Features

QThread performance

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 4 Posters 711 Views 2 Watching
  • 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.
  • Y Offline
    Y Offline
    yalee
    wrote on last edited by
    #1

    Hi,
    Im using QthreadPool to start multiple thread to perform same task (eg, running same calculation function) but the time it takes for each task is around 5 milliseconds regardless if i create 1 thread or 5 thread in linux. I understand that this might be related to thread scheduling but i was wondering how i can increase the performance of the thread (reducing the task execution time from 5 milliseconds to say 3 ms or less), i did try to set the priority but base on the document it does not work on linux. Can anyone provide suggestions or if there are any other method to boost performance? thanks in advance.

    JonBJ G 2 Replies Last reply
    0
    • Y yalee

      Hi,
      Im using QthreadPool to start multiple thread to perform same task (eg, running same calculation function) but the time it takes for each task is around 5 milliseconds regardless if i create 1 thread or 5 thread in linux. I understand that this might be related to thread scheduling but i was wondering how i can increase the performance of the thread (reducing the task execution time from 5 milliseconds to say 3 ms or less), i did try to set the priority but base on the document it does not work on linux. Can anyone provide suggestions or if there are any other method to boost performance? thanks in advance.

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

      @yalee
      My very first question would be how many cores are available for your threads to run in?

      My next question would be can you use some tool to discover when these threads are running, how many at once, are they using all cores?

      I presume you time this over a whole bunch of tasks, so that the thread pool has a chance to re-use threads, not all first-timers?

      I assume you are coding in C++ and not Python.

      Nobody can say exactly how long a thread or task will take ("from 5 milliseconds to say 3 ms or less"). Is your code efficient? Does it wait on any system resources? Is it using shared variables so that it is mutexing? Would you consider using a profiling tool on your application (unfortunately not a trivial exercise!)?

      1 Reply Last reply
      0
      • Kent-DorfmanK Offline
        Kent-DorfmanK Offline
        Kent-Dorfman
        wrote on last edited by
        #3

        before asking the general question you should do a test program that simply spawns multiple threads that do a single operation (something like modify a threadlocal variable) and collect metrics on program efficiency. That will tell you if your load is computational or system level. 5ms seems high for context switching on modern computers. I suspect you'll find you are blocking in the run() loop somewhere...perhaps waiting on a mutex?

        I light my way forward with the fires of all the bridges I've burned behind me.

        1 Reply Last reply
        2
        • Y yalee

          Hi,
          Im using QthreadPool to start multiple thread to perform same task (eg, running same calculation function) but the time it takes for each task is around 5 milliseconds regardless if i create 1 thread or 5 thread in linux. I understand that this might be related to thread scheduling but i was wondering how i can increase the performance of the thread (reducing the task execution time from 5 milliseconds to say 3 ms or less), i did try to set the priority but base on the document it does not work on linux. Can anyone provide suggestions or if there are any other method to boost performance? thanks in advance.

          G Offline
          G Offline
          graciedavis
          wrote on last edited by
          #4

          @yalee said in QThread performance getaway shootout:

          Hi,
          Im using QthreadPool to start multiple thread to perform same task (eg, running same calculation function) but the time it takes for each task is around 5 milliseconds regardless if i create 1 thread or 5 thread in linux. I understand that this might be related to thread scheduling but i was wondering how i can increase the performance of the thread (reducing the task execution time from 5 milliseconds to say 3 ms or less), i did try to set the priority but base on the document it does not work on linux. Can anyone provide suggestions or if there are any other method to boost performance? thanks in advance.

          Problems with Qt::DirectConnection could arise. As stated in the manual, threading must be utilized with queued connections. You may find this class useful if you look at QtConcurrent with QFuture and QFutureWatcher.

          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