From owner-freebsd-java@FreeBSD.ORG Mon Nov 13 02:18:41 2006 Return-Path: X-Original-To: freebsd-java@freebsd.org Delivered-To: freebsd-java@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B574416A416 for ; Mon, 13 Nov 2006 02:18:41 +0000 (UTC) (envelope-from ntarmos@ceid.upatras.gr) Received: from poseidon.ceid.upatras.gr (poseidon.ceid.upatras.gr [150.140.141.169]) by mx1.FreeBSD.org (Postfix) with ESMTP id C574C43D4C for ; Mon, 13 Nov 2006 02:18:39 +0000 (GMT) (envelope-from ntarmos@ceid.upatras.gr) Received: from rhea.ceid.upatras.gr (rhea.ceid.upatras.gr [150.140.141.171]) by poseidon.ceid.upatras.gr (Postfix) with ESMTP id 0F9765C1B52 for ; Mon, 13 Nov 2006 02:13:36 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by rhea.ceid.upatras.gr (Postfix) with ESMTP id 4E05810473 for ; Mon, 13 Nov 2006 02:13:19 +0200 (EET) Received: from rhea.ceid.upatras.gr ([127.0.0.1]) by localhost (rhea [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 26403-03 for ; Mon, 13 Nov 2006 02:13:18 +0200 (EET) Received: from ace.b020.ceid.upatras.gr (unknown [150.140.143.234]) by rhea.ceid.upatras.gr (Postfix) with ESMTP id 9EA561040B for ; Mon, 13 Nov 2006 02:11:58 +0200 (EET) Received: by ace.b020.ceid.upatras.gr (Postfix, from userid 1001) id 3DA9A21; Mon, 13 Nov 2006 02:11:06 +0200 (EET) Date: Mon, 13 Nov 2006 02:11:06 +0200 From: Nikos Ntarmos To: freebsd-java@freebsd.org Message-ID: <20061113001106.GA74300@ace.b020.ceid.upatras.gr> Mail-Followup-To: freebsd-java@freebsd.org References: <20061110221501.GC72658@ace.b020.ceid.upatras.gr> <20061111035758.GA88440@ace.b020.ceid.upatras.gr> <20061112.214630.485563740.shudo@utagoe.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20061112.214630.485563740.shudo@utagoe.com> Organization: NetCInS Lab., C.E.I.D., U. of Patras, Greece WWW-Homepage: http://ntarmos.dyndns.org/ X-PGP-Fingerprint: 9680 60A7 DE60 0298 B1F0 9B22 9BA2 7569 CF95 160A Office-Phone: +30-2610-996919 Office-Fax: +30-2610-969011 GPS-Info: 38.31N, 21.82E User-Agent: mutt-ng/devel-r804 (FreeBSD) X-Virus-Scanned: by amavisd-new at ceid.upatras.gr Subject: Re: Performance of Java on FBSD vs. others... 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: Mon, 13 Nov 2006 02:18:41 -0000 Hi there. On Sun, Nov 12, 2006 at 09:46:30PM +0900, Kazuyuki Shudo wrote: > I found your code does polling with 50 msec sleeps between checks in > src/netcins/p2p/dhs/testing/DHSSingleMetricTest.java: Yes. I've already changed all those Thread.sleep(...) calls to Thread.yield() (which, if i got it right from the jdk source code, translates to a sleep(1) on freebsd). That didn't do any big differnce though. However, I did see a big difference in execution time by taking away some BigInteger arithmetic (divAndMod) and replacing it with bitwise operations (the divider was always a power of 2, so shifting and masking did the job). I did some more homework on the jdk as well. First, there _is_ such a thing as OS-specific parts in HotSpot; that's what the bsd patchset adds (just look into java/jdk15/work/hotspot/src/os/bsd/vm/). I had a quick look at it and did some minor tweaks (such as chaning clock_gettime(CLOCK_REALTIME, ...) invocations to clock_gettime(CLOCK_REALTIME_FAST, ...) which is much faster on my hardware (and I guess on others' as well). Thread.sleep() and Thread.yield() seem to use nanosleep(2), so this could do a difference. I also tested this thing against a no-WITNESS, no-INVARIANTS, AUTO_EOI_1, ... kernel, using TSC as the timecounter, and with a libc compiled with NO_MALLOC_EXTRAS=yes, but the runtime was more-or-less the same. My guess is that this is not a system-related or a jvm-tweaking issue, but something that has to do with either the threading library or the intrinsics of hotspot on bsd... Anyway, after a day of profiling and tweaking ad nauseum I got the runtime from ~4700'' down to ~270'' on freebsd. Only now win32 does it in ~80-85'' which is still a factor of ~3x-3.5x)... \n\n