From owner-freebsd-net@FreeBSD.ORG Tue Jun 10 09:19:52 2014 Return-Path: Delivered-To: net@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 88F9F442; Tue, 10 Jun 2014 09:19:52 +0000 (UTC) Received: from mail.ipfw.ru (mail.ipfw.ru [IPv6:2a01:4f8:120:6141::2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4AB3F2CD8; Tue, 10 Jun 2014 09:19:52 +0000 (UTC) Received: from [2a02:6b8:0:401:222:4dff:fe50:cd2f] (helo=ptichko.yndx.net) by mail.ipfw.ru with esmtpsa (TLSv1:DHE-RSA-AES128-SHA:128) (Exim 4.82 (FreeBSD)) (envelope-from ) id 1WuEIY-0004ZN-DK; Tue, 10 Jun 2014 09:08:38 +0400 Message-ID: <5396CD41.2080300@FreeBSD.org> Date: Tue, 10 Jun 2014 13:17:53 +0400 From: "Alexander V. Chernikov" User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 MIME-Version: 1.0 To: Bryan Venteicher , John-Mark Gurney Subject: Re: dhclient sucks cpu usage... References: <20140610000246.GW31367@funkthat.com> <100488220.4292.1402369436876.JavaMail.root@daemoninthecloset.org> In-Reply-To: <100488220.4292.1402369436876.JavaMail.root@daemoninthecloset.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: current@FreeBSD.org, net@FreeBSD.org X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Jun 2014 09:19:52 -0000 On 10.06.2014 07:03, Bryan Venteicher wrote: > Hi, > > ----- Original Message ----- >> So, after finding out that nc has a stupidly small buffer size (2k >> even though there is space for 16k), I was still not getting as good >> as performance using nc between machines, so I decided to generate some >> flame graphs to try to identify issues... (Thanks to who included a >> full set of modules, including dtraceall on memstick!) >> >> So, the first one is: >> https://www.funkthat.com/~jmg/em.stack.svg >> >> As I was browsing around, the em_handle_que was consuming quite a bit >> of cpu usage for only doing ~50MB/sec over gige.. Running top -SH shows >> me that the taskqueue for em was consuming about 50% cpu... Also pretty >> high for only 50MB/sec... Looking closer, you'll see that bpf_mtap is >> consuming ~3.18% (under ether_nh_input).. I know I'm not running tcpdump >> or anything, but I think dhclient uses bpf to be able to inject packets >> and listen in on them, so I kill off dhclient, and instantly, the taskqueue >> thread for em drops down to 40% CPU... (transfer rate only marginally >> improves, if it does) >> >> I decide to run another flame graph w/o dhclient running: >> https://www.funkthat.com/~jmg/em.stack.nodhclient.svg >> >> and now _rxeof drops from 17.22% to 11.94%, pretty significant... >> >> So, if you care about performance, don't run dhclient... >> > Yes, I've noticed the same issue. It can absolutely kill performance > in a VM guest. It is much more pronounced on only some of my systems, > and I hadn't tracked it down yet. I wonder if this is fallout from > the callout work, or if there was some bpf change. > > I've been using the kludgey workaround patch below. Hm, pretty interesting. dhclient should setup proper filter (and it looks like it does so: 13:10 [0] m@ptichko s netstat -B Pid Netif Flags Recv Drop Match Sblen Hblen Command 1224 em0 -ifs--l 41225922 0 11 0 0 dhclient ) see "match" count. And BPF itself adds the cost of read rwlock (+ bgp_filter() calls for each consumer on interface). It should not introduce significant performance penalties. > > diff --git a/sys/net/bpf.c b/sys/net/bpf.c > index cb3ed27..9751986 100644 > --- a/sys/net/bpf.c > +++ b/sys/net/bpf.c > @@ -2013,9 +2013,11 @@ bpf_gettime(struct bintime *bt, int tstype, struct mbuf *m) > return (BPF_TSTAMP_EXTERN); > } > } > +#if 0 > if (quality == BPF_TSTAMP_NORMAL) > binuptime(bt); > else > +#endif bpf_getttime() is called IFF packet filter matches some traffic. Can you show your "netstat -B" output ? > getbinuptime(bt); > > return (quality); > > >> -- >> John-Mark Gurney Voice: +1 415 225 5579 >> >> "All that I will do, has been done, All that I have, has not." >> _______________________________________________ >> freebsd-current@freebsd.org mailing list >> http://lists.freebsd.org/mailman/listinfo/freebsd-current >> To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org" >> > _______________________________________________ > freebsd-net@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-net > To unsubscribe, send any mail to "freebsd-net-unsubscribe@freebsd.org" >