From owner-svn-src-all@freebsd.org Mon Oct 15 19:52:16 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 357DF10C75FA; Mon, 15 Oct 2018 19:52:16 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: from mail-qt1-x833.google.com (mail-qt1-x833.google.com [IPv6:2607:f8b0:4864:20::833]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id C8C1F828D1; Mon, 15 Oct 2018 19:52:15 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: by mail-qt1-x833.google.com with SMTP id e22-v6so22953635qto.6; Mon, 15 Oct 2018 12:52:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=Z8XHKU8FtxPiDtnUIKDRQwFisS324bTp06c7mVMkuD4=; b=LE9+O4oErRgZUyS/+kK3sq35NGAK5b7v+RRemLu2rAWVPFiDVXl7VBfzDi2SmwBhNo T5WZ9U7F3s98drxHcumynq7juQMib0LrJqln3DgSORR/vNB91+Ex+k0lBpJeybtRzfZ7 OsAgNaMtmwhdD2x8N1rp75J2F2p809Vy3p9nedHOpuwUedhXmtRullh+vLc72GwAXPF5 skilANJRDIBlOsw79EgEqu9LmtFpJTHzyxK2jkV9lUjchLlXr5b+GxDGhr3q9B0mQDoJ ZorHXJkfOx5P5UfVtffCTldfEfHXBSKpiaZhqfD3IDEq+39YD7hKRZPTAiAcqQDv5CK1 1nMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=Z8XHKU8FtxPiDtnUIKDRQwFisS324bTp06c7mVMkuD4=; b=O+DcO/X5H6by8Y1e4wmXdYM139FTxcyK851uFPAs3MxI77c2T8A4hKi/IO53S2v79n GC07hT98GEfdGak8j4IJM1A90uTQUKPyAxKom4xVa7XcRF2ObHJ7UcIcJSyzFHSPQHZ4 Ea+qFziNwDkSGRCCpT5eI8kFpCoOXN5dSHnPFRMALFds+wYemihdeNgXhP6+7wtDIVBs n5dz63hiAGADPMGhi79aMWoV8EoT7dUMweH09z3cCsoRSIjHJbDoEEDpaJv+Wtb9IrhF gAszKL3+7iIV+wvq6nnVccqghIBFQf18ke0VZv/A8vQxZP9RbCVytpCndeD3PLWCYCvt JcAw== X-Gm-Message-State: ABuFfoiyHcQzIJuTm0aEi6LzyuEL9EI9uD5DGm7IqvqaanHnAXrI6tJ0 oUbf/7/Rifwz9oTqUV90WfobUaLUFJ/R3ff+GJ7ZSg== X-Google-Smtp-Source: ACcGV60f+WY/dmUi9AL/8WfOo9+FxonXJHWWvsnZbGI7T150oS1r6EaVGktp+orTl3/2TbrImFvWX1PN/+F20jgR5fM= X-Received: by 2002:a0c:8545:: with SMTP id n63-v6mr18188749qva.205.1539633134992; Mon, 15 Oct 2018 12:52:14 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:ac8:362e:0:0:0:0:0 with HTTP; Mon, 15 Oct 2018 12:52:14 -0700 (PDT) In-Reply-To: <20181015191924.GF1044@FreeBSD.org> References: <201810132118.w9DLIW3R017391@repo.freebsd.org> <20181015191924.GF1044@FreeBSD.org> From: Mateusz Guzik Date: Mon, 15 Oct 2018 21:52:14 +0200 Message-ID: Subject: Re: svn commit: r339349 - in head/sys/amd64: amd64 include To: Gleb Smirnoff Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset="UTF-8" X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 15 Oct 2018 19:52:16 -0000 On 10/15/18, Gleb Smirnoff wrote: > Mateusz, > > On Sat, Oct 13, 2018 at 09:18:32PM +0000, Mateusz Guzik wrote: > M> Return is almost always 0. The change replaces 3 branches with 1 in the > common > M> case. > > This isn't true. For a webserver working with blocking sockets > returning EAGAIN for a very large number of syscalls is normal. > > I just dtraced on a random Netflix server and in our case we > get 12% of syscalls with non zero error. But our clients are > special, they request data in small chunks. I believe a regular > web server that serves mostly open ended requests will have a > greater ratio of non-zero returns, up to 50%. > > Here is script: > > #!/usr/sbin/dtrace -s > > fbt::cpu_set_syscall_retval:entry > { > @[args[1]] = count(); > } > > I would be interested if anybody reports results on a busy > web server running nginx. > > So, I doubt that using __predict_true() is an optimisation here. This should be a win even for your somewhat degenerate case. Code handling all cases is disjoint - regardless of my change it has to jump over something. The previous code tests 3 conditions. The case o errno EAGAIN or similar is handled by the last. So returning zero requires 3 tests and 0 jumps. Returning EAGAIN requires 3 tests and 1 jump. With the committed patch returning zero requires 1 test and 0 jumps. Returning EAGAIN requires 3 tests and 2 jumps. Given how much more frequent returning zero is, I think it's a net win. However, the code can be further modified to just get rid of the second jump. Either way, the entire syscall path is extremely pessimized. -- Mateusz Guzik