From owner-freebsd-java@FreeBSD.ORG Sat Sep 15 19:08:32 2007 Return-Path: Delivered-To: java@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 98BF416A418; Sat, 15 Sep 2007 19:08:32 +0000 (UTC) (envelope-from kris@FreeBSD.org) Received: from weak.local (hub.freebsd.org [IPv6:2001:4f8:fff6::36]) by mx1.freebsd.org (Postfix) with ESMTP id C92A113C483; Sat, 15 Sep 2007 19:08:29 +0000 (UTC) (envelope-from kris@FreeBSD.org) Message-ID: <46EC2DAA.9070602@FreeBSD.org> Date: Sat, 15 Sep 2007 21:08:26 +0200 From: Kris Kennaway User-Agent: Thunderbird 2.0.0.6 (Macintosh/20070728) MIME-Version: 1.0 To: Daniel Eischen References: <46EC1B55.4060202@FreeBSD.org> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: java@freebsd.org, performance@freebsd.org Subject: Re: Massive performance loss from OS::sleep hack X-BeenThere: freebsd-java@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting Java to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Sep 2007 19:08:32 -0000 Daniel Eischen wrote: >> When I removed this hack (i.e. revert to pthread_yield()) I got an >> immediate 7-fold performance increase, which brings FreeBSD >> performance on par with Solaris. >> >> What is the reason why this code is necessary? Does FreeBSD's >> sched_yield() really have different semantics to the other operating >> systems, or was this a libkse bug that was being worked around? > > It's certainly not a libkse bug, at least with scope process threads > libkse does the right thinng. For scope system threads and all libthr > threads, it probably depends on what scheduler you are using since > it's essentially a __sys_sched_yield(). > > On a side note, I think pthread_yield() is deprecated and not in the > latest POSIX spec. sched_yield() is in the spec and is specified > to account for behavior in a threaded environment. Yeah, libthr's pthread_yield just calls sched_yield. Anyway, it seems to me that the decision of what thread to run next is a scheduler decision, and if it is inappropriate for some reason for a scheduler to possibly choose to reschedule the same thread that just yielded, this is something that should be addressed in the scheduler rather than by adding hacks to the application. Kris