From owner-freebsd-questions@FreeBSD.ORG Sun Nov 9 21:17:54 2014 Return-Path: Delivered-To: freebsd-questions@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 A3047536; Sun, 9 Nov 2014 21:17:54 +0000 (UTC) Received: from mail-wi0-x234.google.com (mail-wi0-x234.google.com [IPv6:2a00:1450:400c:c05::234]) (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 34146301; Sun, 9 Nov 2014 21:17:54 +0000 (UTC) Received: by mail-wi0-f180.google.com with SMTP id hi2so8675698wib.7 for ; Sun, 09 Nov 2014 13:17:52 -0800 (PST) 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; bh=c4FooW7pkjI+36YGm2jOK5F8GGAzZQ9hTw+n63Ejxew=; b=sdB/TAO3NcCi4+Mdm5Sdt6ABofkY7iEzhvxj0zsusqVAHNn5FIHDJr9rT3xHJsSfvo i62q9TtGDk6syb7Y0lArOIXisvMGeKlt5Goa9yWH1GGxwMTBjPS/9EhbWRKDI0phd4Xh 5Qxb7cwWQ7jZDB2unHX4hHIGhUTExnMO9i8BYOQrnsS3gq+WDjo+TjlHTQ3ogVNpesf0 5WiB0FiP8WVy29bUAnJFl/gTEm6k3PgNLpooewCsKr4ZJsco5ZXmCVCEynUyNTihjfkm 9dwn6nomm9/BQC9WOf7p7trE+oVFCRLyabFch8uYJJzNtvhwvaW3exHPkpYUMdYJTmu0 pXgg== MIME-Version: 1.0 X-Received: by 10.194.80.100 with SMTP id q4mr37052625wjx.15.1415567872583; Sun, 09 Nov 2014 13:17:52 -0800 (PST) Sender: adrian.chadd@gmail.com Received: by 10.216.106.136 with HTTP; Sun, 9 Nov 2014 13:17:52 -0800 (PST) In-Reply-To: References: Date: Sun, 9 Nov 2014 13:17:52 -0800 X-Google-Sender-Auth: Cqc3dEbZvM6byXK9dl7Ww2R-E6g Message-ID: Subject: Re: How thread-friendly is kevent? From: Adrian Chadd To: J David Content-Type: text/plain; charset=UTF-8 Cc: "freebsd-hackers@freebsd.org" , "freebsd-questions@freebsd.org" X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 09 Nov 2014 21:17:54 -0000 Hi! Are you putting the same FD into multiple threads and hoping that only one note will wake up on one listening kqueue? -adrian On 9 November 2014 11:57, J David wrote: > How thread-friendly is kevent()? > > In most cases, a dedicated thread does the kevent()-ing and > dispatching work to the thread pool, but at extremely high rates that > thread becomes a significant bottleneck. > > As an example, consider a pool of, say, 17 threads on a 16 core > machine all in kevent() waiting for one of 32000 open TCP connections > to be read-ready. One connection becomes read-ready. How many > threads will have kevent() return with that event in eventlist? Is > there potential for a thundering herd problem? > > Limited small-scale experimentation suggests that only one thread > returns per event, but it's not documented that way, so it's not clear > if that behavior is intended, an implementation detail, or a > coincidence that won't hold up at scale. > > Is this behavior at all guaranteed / by design / intentional? > > Although it would be ideal if so, it would also make sense to have to > rely on EV_DISPATCH in multithreaded applications to prevent events > from being delivered more than once, or to use EV_ONESHOT and re-add > the event entirely, depending on which approach better suits the > internal data structure the kernel uses for kqueue. > > Thanks for any advice! > _______________________________________________ > freebsd-questions@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.org"