Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QtConcurrent -thread not running concurrently



  • I am facing the problem on using Qtconcurrent::map() functionality in high core(>16) machine with 128GB RAM.

    The code works in my PC which is 8GB RAM and cores is 4, works is in the sense all the threads running concurrently but in high core machine only one thread is running at a time . I noticed with the help of Task manager.

    In thread, i am running the console application using QProcess.

    Please help me with resolving the issue.


  • Lifetime Qt Champion

    Hi,

    Did you compare the two machines setup ?
    Except hardware, how are they configured ?



  • The machine which is working uses Intel(R) Core i5 8350U CPU
    The machine which is not working uses Intel Xeon Silver 4114 CPU 2 Processors
    What more additional information required?


  • Lifetime Qt Champion

    Well things like OS, special options used. If Linux, type of scheduler, custom kernel, etc.


  • Moderators

    As a quick check, call this on both PCs:

    qDebug() << QThread::idealThreadCount();
    qDebug() << QThreadPool::globalInstance->maxThreadCount();
    

    What values do you get?



  • Both the machine uses windows 10 Enterprise version 1803. It is organization provided desktops so i can't have information on other specific options used



  • @jksh both are 40 for the machine that is not working,
    8 for the machine it is working


  • Moderators

    @meganathan said in QtConcurrent -thread not running concurrently:

    @jksh both are 40 for the machine that is not working,
    8 for the machine it is working

    Try setting a lower max thread count before you use QtConcurrent: QThreadPool::globalInstance->setMaxThreadCount(4);

    Does that help on the Xeon machine? (Try a few different numbers)

    Also, are you running the same executable on both machines?

    In thread, i am running the console application using QProcess.

    Do you mean you use QtConcurrent::map() to launch QProcess?



  • i tried setting the maxthreadCount to 8 but still only one executable is running out of 8, it is not running concurrently in Xeon processor machine.

    I am running the same executable in both the machine .

    Yes, in mapped function, i use Qprocess to launch and execute the console application


  • Moderators

    @meganathan said in QtConcurrent -thread not running concurrently:

    i tried setting the maxthreadCount to 8 but still only one executable is running out of 8, it is not running concurrently in Xeon processor machine.

    I am running the same executable in both the machine .

    Yes, in mapped function, i use Qprocess to launch and execute the console application

    I can think of 2 possibilities:

    1. Only 1 instance of the console application can be run at a time on the Xeon machine, OR
    2. There is an issue where Qt Concurrent can't use multiple threads in the Xeon machine

    To check (1), put debug messages at the start and end of your map function:

    QByteArray mapFunc(const QString& args)
    {
        qDebug() << "Starting " + args;
    
        QProcess p;
        // Do expensive task here
    
        qDebug() << "Finished " + args;
    }
    

    Do you see many "Starting" messages appear at the same time ("Starting" -> "Starting" -> "Starting" -> "Finished" -> "Finished" -> "Finished")?
    Or do you get a single-threaded sequence ("Starting" -> "Finished" -> "Starting" -> "Finished" -> "Starting" -> "Finished")?

    Also, how long does it take to run the console app?

    To check (2), upgrade to the latest version of Qt (I notice that you're still using Qt 4.8 which reached end-of-life in 2015). If the issue still exists in Qt 5.13, submit a report to https://bugreports.qt.io/


Log in to reply