From owner-freebsd-hackers@FreeBSD.ORG Thu Oct 2 18:13:52 2014 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id AA0A8491; Thu, 2 Oct 2014 18:13:52 +0000 (UTC) Received: from exchange.glccom.com (exchange.glccom.com [209.152.99.146]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (Client CN "exchange.glccom.com", Issuer "Network Solutions DV Server CA" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 5FB02B6B; Thu, 2 Oct 2014 18:13:51 +0000 (UTC) Received: from karen-pc.local.glccom.com (192.168.10.71) by exchange.glccom.com (209.152.99.146) with Microsoft SMTP Server (TLS) id 8.3.83.0; Thu, 2 Oct 2014 13:13:38 -0500 MIME-Version: 1.0 (Mac OS X Mail 7.3 \(1878.6\)) Subject: Re: freebsd 10 kqueue timer regression From: Paul Albrecht In-Reply-To: Date: Thu, 2 Oct 2014 13:13:36 -0500 Message-ID: <8587D819-AA2F-4387-A4E9-523014384672@glccom.com> References: <8ABC0977-FB8F-45E7-ACCC-BFA92EE22E1C@glccom.com> To: Adrian Chadd X-Mailer: Apple Mail (2.1878.6) Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.18-1 Cc: "freebsd-hackers@freebsd.org" X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 02 Oct 2014 18:13:52 -0000 On Oct 2, 2014, at 12:18 PM, Adrian Chadd wrote: > On 2 October 2014 08:07, Paul Albrecht wrote: >>=20 >> Hi, >>=20 >> What=92s up with freebsd 10? I=92m testing some code that uses the = kqueue timer for timing and it doesn=92t work because the precision of = the timer is off. >=20 > Can you provide a test case for it? Here=92s the code: #include #include #include #include #include #include #include #include int main(void) { int i,msec; int kq,nev; struct kevent inqueue; struct kevent outqueue; struct timeval start,end; if ((kq =3D kqueue()) =3D=3D -1) { fprintf(stderr, "kqueue error!? errno =3D %s", = strerror(errno)); exit(EXIT_FAILURE); } EV_SET(&inqueue, 1, EVFILT_TIMER, EV_ADD | EV_ENABLE, 0, 20, 0); gettimeofday(&start, 0); for (i =3D 0; i < 50; i++) { if ((nev =3D kevent(kq, &inqueue, 1, &outqueue, 1, = NULL)) =3D=3D -1) { fprintf(stderr, "kevent error!? errno =3D %s", = strerror(errno)); exit(EXIT_FAILURE); } else if (outqueue.flags & EV_ERROR) { fprintf(stderr, "EV_ERROR: %s\n", = strerror(outqueue.data)); exit(EXIT_FAILURE); } } gettimeofday(&end, 0); msec =3D ((end.tv_sec - start.tv_sec) * 1000) + (((1000000 + = end.tv_usec - start.tv_usec) / 1000) - 1000); printf("msec =3D %d\n", msec); close(kq); return EXIT_SUCCESS; } When I run it on my system I get these results: ./a.out msec =3D 1072 ./a.out msec =3D 1071 ./a.out msec =3D 1071 Which is over about 3.5 times the wait time per second. >=20 > I just chased down one of those recently; maybe it's the same thing > (callout() API changes.) >=20 >=20 > -a