From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from m0.truegem.net (m0.truegem.net [69.55.228.47]) by sourceware.org (Postfix) with ESMTPS id E89E9384B110 for ; Fri, 11 Jun 2021 05:52:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E89E9384B110 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=maxrnd.com Authentication-Results: sourceware.org; spf=none smtp.mailfrom=maxrnd.com Received: (from daemon@localhost) by m0.truegem.net (8.12.11/8.12.11) id 15B5q8Qi040110 for ; Thu, 10 Jun 2021 22:52:08 -0700 (PDT) (envelope-from mark@maxrnd.com) Received: from 162-235-43-67.lightspeed.irvnca.sbcglobal.net(162.235.43.67), claiming to be "[192.168.1.20]" via SMTP by m0.truegem.net, id smtpdbCUFmH; Thu Jun 10 22:52:02 2021 Subject: Re: C++ program using To: cygwin@cygwin.com References: From: Mark Geisert Message-ID: Date: Thu, 10 Jun 2021 22:52:02 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Firefox/52.0 SeaMonkey/2.49.4 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.8 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, NICE_REPLY_A, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: cygwin@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: General Cygwin discussions and problem reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Jun 2021 05:52:12 -0000 Hi André, André Bleau via Cygwin wrote: > Hi all, > > I have a small C++ program using . Mainly, I have a series of long tasks for which I can use a chosen number of threads. I create a given number of instances of the std::thread class, each executing the same function but with different data. After launching the threads, my program waits for the results by calling thread.join() on each thread. Some threads finish sooner than others, depending on the data they process. > > I have 16 cores with hyperthreading, so 32 virtual cores. I tried a big run with 63 threads. > > If I compile as a Cygwin program with g++ 10.2.0, when the program runs with 63 threads the CPU load for the program never exceeds 6 or 7%. It remains constants when some of the threads finish, unless the number of threads remaining goes down to about 4. > > If I compile as a Mingw program with x86_64-w64-mingw32-c++ 10.2.0, when the program runs with 63 threads the CPU load for the program reaches 98% then gradually diminishes as threads finish their task. > > Needless to say, the total running time for the Mingw version is much shorter. > > So, is there a limit to the CPU load that a threaded Cygwin program can get? If yes, how can it be changed? Fascinating report; thanks! I doubt there's an intentional limit, but perhaps there is some difference between the Cygwin and MinGW environments that explains the symptoms. No idea at this point though. Oh, does your program set process or thread affinity anywhere? Would you be able to post the source of your test program, or provide it to me by private email? I would run my cygmon profiler on it to look for clues. There have been several other reports of multi-threaded programs taking far too long to complete, but the reports came in as possibly malloc-related issues so they may differ from yours. But cygmon has found something troubling in those cases that I'm still investigating. Regards, ..mark