From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4915 invoked by alias); 9 Aug 2012 08:07:21 -0000 Received: (qmail 4903 invoked by uid 22791); 9 Aug 2012 08:07:20 -0000 X-SWARE-Spam-Status: No, hits=-0.9 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,KAM_TIME,KHOP_RCVD_TRUST,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE X-Spam-Check-By: sourceware.org Received: from mail-ob0-f171.google.com (HELO mail-ob0-f171.google.com) (209.85.214.171) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 09 Aug 2012 08:07:07 +0000 Received: by obqv19 with SMTP id v19so278366obq.2 for ; Thu, 09 Aug 2012 01:07:06 -0700 (PDT) MIME-Version: 1.0 Received: by 10.182.216.99 with SMTP id op3mr4055077obc.30.1344499626645; Thu, 09 Aug 2012 01:07:06 -0700 (PDT) Received: by 10.60.64.201 with HTTP; Thu, 9 Aug 2012 01:07:06 -0700 (PDT) Date: Thu, 09 Aug 2012 08:17:00 -0000 Message-ID: Subject: App runs 8x slower on dual core machine (with test case to replicate issue) From: Zach Saw To: cygwin@cygwin.com Content-Type: text/plain; charset=ISO-8859-1 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com X-SW-Source: 2012-08/txt/msg00201.txt.bz2 Hi all, While trying to compile my multithreaded app written for Linux on Cygwin to run on Windows, I discovered the app would perform 8x slower on a machine with the same specs. I then went on to triage the issue and found that if I set CPU affinity of that process to 1 (i.e. single core), I'd get it to speed up to almost the speed I'd get under Linux (set to single core too). I dug deeper and had my suspicion on a Cygwin bug. I suspected a problem in its thread singalling (condvar). So to test my hypothesis, I created a minimal test case to show case this issue. This minimal test case compiled on MSVC++ too and the difference is staggering. What you'll find is if you started the process with CPU Aff = 1, you'll get it to run >8x as fast as the default. On my machine, it took 4300ms to run in dual core mode, 460ms to run when CPU Aff = 1. Setup: Cygwin WinXP SP3 2GB RAM Core2Duo 2.33GHz All firewalls disabled Virus / Malware scanners disabled Boost 1.48.0 (as per official Cygwin installation) [Only for test case app] Boost.Threadpool - http://threadpool.sourceforge.net Code to replicate the issue (get Boost.Threadpool from above): #include #include #include inline int GetTickCount() { timespec t; clock_gettime(CLOCK_MONOTONIC, &t); return (((int)t.tv_sec) * 1000) + (t.tv_nsec / 1000000); } class Test { public: void Add() { } void Delete() { } }; int main(int argc, char** argv) { int start; { boost::threadpool::pool tp(50); Test test; start = GetTickCount(); for (int i=0; i<100000; i++) { tp.schedule(boost::bind(&Test::Add, &test)); tp.schedule(boost::bind(&Test::Delete, &test)); } tp.wait(); } int elapsed = GetTickCount() - start; std::cout << elapsed << std::endl; std::cin.get(); return 0; } Cheers, Zach -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple