From owner-freebsd-performance@FreeBSD.ORG Fri Oct 31 10:03:42 2008 Return-Path: Delivered-To: freebsd-performance@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 779DC106568E for ; Fri, 31 Oct 2008 10:03:42 +0000 (UTC) (envelope-from xiazhongqi@huawei.com) Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [119.145.14.67]) by mx1.freebsd.org (Postfix) with ESMTP id 279FB8FC1A for ; Fri, 31 Oct 2008 10:03:42 +0000 (UTC) (envelope-from xiazhongqi@huawei.com) Received: from huawei.com (szxga04-in [172.24.2.12]) by szxga04-in.huawei.com (iPlanet Messaging Server 5.2 HotFix 2.14 (built Aug 8 2006)) with ESMTP id <0K9L00BOSL79F3@szxga04-in.huawei.com> for freebsd-performance@freebsd.org; Fri, 31 Oct 2008 18:01:57 +0800 (CST) Received: from huawei.com ([172.24.1.18]) by szxga04-in.huawei.com (iPlanet Messaging Server 5.2 HotFix 2.14 (built Aug 8 2006)) with ESMTP id <0K9L004OCL7996@szxga04-in.huawei.com> for freebsd-performance@freebsd.org; Fri, 31 Oct 2008 18:01:57 +0800 (CST) Received: from x49105 ([10.111.9.47]) by szxml03-in.huawei.com (iPlanet Messaging Server 5.2 HotFix 2.14 (built Aug 8 2006)) with ESMTPA id <0K9L009OXL78MQ@szxml03-in.huawei.com> for freebsd-performance@freebsd.org; Fri, 31 Oct 2008 18:01:57 +0800 (CST) Date: Fri, 31 Oct 2008 18:01:56 +0800 From: Sam Xia In-reply-to: <490ACA04.6060203@bulinfo.net> To: 'Krassimir Slavchev' Message-id: <000001c93b3f$b5767eb0$2f096f0a@china.huawei.com> MIME-version: 1.0 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2900.3350 X-Mailer: Microsoft Office Outlook 11 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7BIT Thread-index: Ack7OBj56+fgECyVQWyLWHTqoCSRMAABuJeA Cc: freebsd-performance@freebsd.org Subject: RE: 1. thread switching time? (Krassimir Slavchev) X-BeenThere: freebsd-performance@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Performance/tuning List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 31 Oct 2008 10:03:42 -0000 hi Krassimir, The smallest time quatum moving a thread from sleep queue to ready queue is equal to one tick(about 1 ms). This is dependent of os scheduling mechanism. Even the delay of nanosleep is less than 1 ms, actually 1 ms is the smallest unit. I guess you should modify the kernel and add clock intr frequency. BR, Sam.Xia > -----Original Message----- > From: Krassimir Slavchev [mailto:krassi@bulinfo.net] > Sent: Friday, October 31, 2008 5:04 PM > To: Julian Elischer > Cc: freebsd-performance@freebsd.org; Sam Xia > Subject: Re: 1. thread switching time? (Krassimir Slavchev) > > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Hello Julian, > > Julian Elischer wrote: > > Krassimir Slavchev wrote: > > > >> > >> Also, I am able to set HZ=100000 but the thread switching time is > >> still ~1ms. > > > > You must be talking about the time that a thread can run > before it is > > pushed out by other threads? I know I've seem many x > 10,000 context > > switches in some cases, i.e. look at very high interrupt > rates etc. so > > I guess I'm not sure what you are measuring.. > > Okay, I have a thread with: > > while(1) { > clock_gettime(CLOCK_REALTIME, &tv); > nanosleep(&delay, NULL); > clock_gettime(CLOCK_REALTIME, &tv2); > timespecsub(&tv2, &tv); > } > > If the delay is configured to be 0 < delay < 1ms I always get > ~1ms delay. > Since nanosleep() is a cancellation point this means that the > scheduler will switch to another thread. > If the delay = 0 I get ~1600ns delay. > > Yes. You are right. This is "the time that a thread can run > before it is pushed out by other threads". > > Is there a way to decrease this time? > > > > > at one time the scheduling quantum was independent of Hz. > > I am not sure how true that is now.. > > > > It seems to be independent of HZ. > > > Best Regards > > > > > _______________________________________________ > > freebsd-performance@freebsd.org mailing list > > http://lists.freebsd.org/mailman/listinfo/freebsd-performance > > To unsubscribe, send any mail to > > "freebsd-performance-unsubscribe@freebsd.org" > > > > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.7 (FreeBSD) > > iD8DBQFJCsoDxJBWvpalMpkRAteuAJ9Jd8ICvPSiWB/4eGquUunoclpeXgCgjqyE > vBXA0vGoRgsQ9eHZ/YwR/lw= > =AjjC > -----END PGP SIGNATURE----- >