From owner-freebsd-hackers@FreeBSD.ORG Thu Oct 2 19:42:41 2014 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 1AA02A3 for ; Thu, 2 Oct 2014 19:42:41 +0000 (UTC) Received: from mail-wg0-x22e.google.com (mail-wg0-x22e.google.com [IPv6:2a00:1450:400c:c00::22e]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id A93AF827 for ; Thu, 2 Oct 2014 19:42:40 +0000 (UTC) Received: by mail-wg0-f46.google.com with SMTP id l18so1245952wgh.29 for ; Thu, 02 Oct 2014 12:42:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type:content-transfer-encoding; bh=z8Gjy26b2CKg3+TWhoREzfBDFEGGVL+SUgvqozwiyhE=; b=RDhbVZNUovkijEBLo1LT4ZaKZjrr2DXYkBqvq0NDDrRu28f2fy9U66bs+56LGNJYdZ prtdhPh9Jd7/UTLeBMj9NQsaA2mzpEUFHmE8es21Q4hBJSOFzHMVZaeYi/T8Y28HdGCQ NyjjlzJiEGVASJaiyN2F7f/ysXElwcvb9gY08ZwbaFnZlt6Jnk2m+Nt7ZevL044tsbD8 c6xp8Bg2bgUybOrHxeRoVAnEgOlJlKAuLa4Go07SHvWm6Y5nbhbc0mwBN0mOB6wJjLud KyQhZTJRAMZvk88Wi76GGjbyVZFdvPnNbntdlAauXJpHllZCs1Uw/2vVvJFBR61+dV+w sjiA== MIME-Version: 1.0 X-Received: by 10.194.202.138 with SMTP id ki10mr1331291wjc.68.1412278959001; Thu, 02 Oct 2014 12:42:39 -0700 (PDT) Sender: adrian.chadd@gmail.com Received: by 10.216.106.136 with HTTP; Thu, 2 Oct 2014 12:42:38 -0700 (PDT) In-Reply-To: <8587D819-AA2F-4387-A4E9-523014384672@glccom.com> References: <8ABC0977-FB8F-45E7-ACCC-BFA92EE22E1C@glccom.com> <8587D819-AA2F-4387-A4E9-523014384672@glccom.com> Date: Thu, 2 Oct 2014 12:42:38 -0700 X-Google-Sender-Auth: 0bIwtvTWfQ-Olm2GjOTW7wmlS5Y Message-ID: Subject: Re: freebsd 10 kqueue timer regression From: Adrian Chadd To: Paul Albrecht Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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 19:42:41 -0000 Right, and jhb@ mentioned callout() and related stuff. Let me take a look. I bet it's not doing things "right". -a On 2 October 2014 11:13, Paul Albrecht wrote: > > On Oct 2, 2014, at 12:18 PM, Adrian Chadd wrote: > > On 2 October 2014 08:07, Paul Albrecht wrote: > > > Hi, > > What=E2=80=99s up with freebsd 10? I=E2=80=99m testing some code that use= s the kqueue timer > for timing and it doesn=E2=80=99t work because the precision of the timer= is off. > > > Can you provide a test case for it? > > > Here=E2=80=99s 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. > > > > I just chased down one of those recently; maybe it's the same thing > (callout() API changes.) > > > -a > >