Return-Path: X-Original-To: apmail-tomcat-users-archive@www.apache.org Delivered-To: apmail-tomcat-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A050418D1D for ; Mon, 2 Nov 2015 20:24:27 +0000 (UTC) Received: (qmail 85044 invoked by uid 500); 2 Nov 2015 20:24:23 -0000 Delivered-To: apmail-tomcat-users-archive@tomcat.apache.org Received: (qmail 84975 invoked by uid 500); 2 Nov 2015 20:24:23 -0000 Mailing-List: contact users-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Users List" Delivered-To: mailing list users@tomcat.apache.org Received: (qmail 84964 invoked by uid 99); 2 Nov 2015 20:24:23 -0000 Received: from Unknown (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 02 Nov 2015 20:24:23 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 4F427C28CC for ; Mon, 2 Nov 2015 20:24:23 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -0.01 X-Spam-Level: X-Spam-Status: No, score=-0.01 tagged_above=-999 required=6.31 tests=[SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-us-west.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id Cyv91eloyC6V for ; Mon, 2 Nov 2015 20:24:12 +0000 (UTC) Received: from vms173023pub.verizon.net (vms173023pub.verizon.net [206.46.173.23]) by mx1-us-west.apache.org (ASF Mail Server at mx1-us-west.apache.org) with ESMTPS id 87D122326B for ; Mon, 2 Nov 2015 20:24:12 +0000 (UTC) MIME-version: 1.0 Content-transfer-encoding: 8BIT Content-type: text/plain; charset=utf-8; format=flowed Received: from [172.17.47.42] ([65.199.184.146]) by vms173023.mailsrvcs.net (Oracle Communications Messaging Server 7.0.5.32.0 64bit (built Jul 16 2014)) with ESMTPA id <0NX700G4XFBCC680@vms173023.mailsrvcs.net> for users@tomcat.apache.org; Mon, 02 Nov 2015 14:23:37 -0600 (CST) X-CMAE-Score: 0 X-CMAE-Analysis: v=2.1 cv=EdU1O6SC c=1 sm=1 tr=0 a=ghRDmrgUihQ+t5fp33utJQ==:117 a=o1OHuDzbAAAA:8 a=oR5dmqMzAAAA:8 a=IkcTkHD0fZMA:10 a=qtqOOiqGOCEA:10 a=yPCof4ZbAAAA:8 a=inuow5TUAAAA:8 a=lMZTjQlnAAAA:8 a=mV9VRH-2AAAA:8 a=-57I09spAAAA:8 a=yMhMjlubAAAA:8 a=NjCR172NKLT2-Op6_90A:9 a=rozzrBQhyHYZk-D1:21 a=cdkNow0ivsprbd_N:21 a=QEXdDO2ut3YA:10 a=aweWAO5CVXQA:10 Subject: Re: [OT] RE: 80ms delay switching between worker threads To: Tomcat Users List References: <000501d113be$57a992e0$06fcb8a0$@apache.org> <4BECF8F2CDD74E4A8127421DB201BA2B58E169E7@mail.hermes.si> <56375D86.8060707@verizon.net> From: David kerber Message-id: <5637C648.4000104@verizon.net> Date: Mon, 02 Nov 2015 15:23:36 -0500 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 In-reply-to: On 11/2/2015 3:09 PM, Farzad Panahi wrote: > Quoting from David Holme's blog: > >> The nanoTime method uses the highest resolution clock available on the platform, and while its return value is in nanoseconds, the update resolution is typically only microseconds. > https://blogs.oracle.com/dholmes/entry/inside_the_hotspot_vm_clocks > > I think we can rely on nanoTime as a clock with microsecond > resolution. Having said that can't we say printing out nanoTime in > websocket message handler will give us a fair number (with microsecond > accuracy) to measure how quickly the message handler is being called? > > All I am saying is that I see an obvious hiccup in order of > milliseconds when threads are switching which I have no explanation > for. > > Please advise if you think the way I am measuring is wrong. I'm with Chris on this one: I think it's due to running on a VM rather than on real hardware. > > Cheers > > Farzad > > On Mon, Nov 2, 2015 at 4:56 AM, David kerber wrote: >> On 10/31/2015 10:51 AM, David Balažic wrote: >>> >>> Just a note: When most of you say "resolution" what you think about is >>> actually called "accuracy". >>> (also see "precision" , here is a good roundup: >>> http://www.tutelman.com/golf/measure/precision.php ) >> >> >> I'm not sure about the others, but as an Electrical Engineer, I know the >> difference between resolution, precision, and accuracy. In the post I made >> earlier, I said and meant "resolution". >> >> >> >> >>> >>> David Balažic >>> Software Engineer >>> www.comtrade.com >>> >>>> -----Original Message----- >>>> From: Konstantin Preißer [mailto:kpreisser@apache.org] >>>> Sent: 31. October 2015 10:27 >>>> To: Tomcat Users List >>>> Subject: [OT] RE: 80ms delay switching between worker threads >>>> Importance: Low >>>> >>>> Hi Christopher, >>>> >>>>> -----Original Message----- >>>>> From: Christopher Schultz [mailto:chris@christopherschultz.net] >>>>> Sent: Saturday, October 31, 2015 3:43 AM >>>>> >>>>> What OS are you using? IIRC, the Windows timer has horrible resolution. >>>>> you can call System.currentTimeNanos all you want, but you won't get >>>>> anything meaningful lower than some threshold regardless of the actual >>>>> least significant digits coming back from those calls. >>>> >>>> >>>> While that may have been true in ancient versions like XP and Vista, at >>>> least >>>> starting with Win7 QueryPerformanceCounter() uses the processor's TSC [1] >>>> (where Vista used the HPET if available) so you should have a very high >>>> resolution here. E.g. running the following Java program: >>>> >>>> int[] iterations = { 100, 120, 150, 250 }; >>>> >>>> for (int i = 0; i < iterations.length; i++) { >>>> for (int j = 0; j < 3; j++) { >>>> long currentTime = System.nanoTime(); >>>> double startValue = 1000; >>>> for (int z = 0; z < iterations[i]; z++) { >>>> startValue = Math.pow(startValue, 0.99); >>>> } >>>> long difference = System.nanoTime() - currentTime; >>>> System.out.println(iterations[i] + " pow iterations ms took >>>> " + >>>> (difference / 1000L) + " µs"); >>>> } >>>> } >>>> >>>> prints on my system something like: >>>> >>>> 100 pow iterations ms took 25 µs >>>> 100 pow iterations ms took 7 µs >>>> 100 pow iterations ms took 7 µs >>>> 120 pow iterations ms took 8 µs >>>> 120 pow iterations ms took 9 µs >>>> 120 pow iterations ms took 8 µs >>>> 150 pow iterations ms took 11 µs >>>> 150 pow iterations ms took 10 µs >>>> 150 pow iterations ms took 13 µs >>>> 250 pow iterations ms took 18 µs >>>> 250 pow iterations ms took 17 µs >>>> 250 pow iterations ms took 17 µs >>>> >>>> >>>> So there should at least be a microsecond resolution. On a C# program >>>> using >>>> Stopwatch I get similar results in the range from 5 to 12 µs. >>>> >>>> Note, QueryPerformanceFrequency() [2] can be used to get the frequency >>>> of the timer which is exposed in .Net through static >>>> System.Diagnostics.Stopwatch.Frequency field as ticks per second. On my >>>> system it prints "3323580" so the resolution should be around ~0.3 >>>> microseconds. >>>> >>>> >>>> Regards, >>>> Konstantin Preißer >>>> >>>> [1] https://msdn.microsoft.com/en- >>>> us/library/windows/desktop/dn553408%28v=vs.85%29.aspx >>>> [2] https://msdn.microsoft.com/de- >>>> de/library/windows/desktop/ms644905%28v=vs.85%29.aspx --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org For additional commands, e-mail: users-help@tomcat.apache.org