From owner-freebsd-current@FreeBSD.ORG Tue Jun 10 18:49:27 2014 Return-Path: Delivered-To: current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id B98F1131; Tue, 10 Jun 2014 18:49:27 +0000 (UTC) Received: from h2.funkthat.com (gate2.funkthat.com [208.87.223.18]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "funkthat.com", Issuer "funkthat.com" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 93E812642; Tue, 10 Jun 2014 18:49:27 +0000 (UTC) Received: from h2.funkthat.com (localhost [127.0.0.1]) by h2.funkthat.com (8.14.3/8.14.3) with ESMTP id s5AInLnC081441 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 10 Jun 2014 11:49:21 -0700 (PDT) (envelope-from jmg@h2.funkthat.com) Received: (from jmg@localhost) by h2.funkthat.com (8.14.3/8.14.3/Submit) id s5AInK72081440; Tue, 10 Jun 2014 11:49:20 -0700 (PDT) (envelope-from jmg) Date: Tue, 10 Jun 2014 11:49:20 -0700 From: John-Mark Gurney To: "Alexander V. Chernikov" Subject: Re: dhclient sucks cpu usage... Message-ID: <20140610184920.GJ31367@funkthat.com> Mail-Followup-To: "Alexander V. Chernikov" , Bryan Venteicher , current@freebsd.org, net@freebsd.org References: <20140610000246.GW31367@funkthat.com> <100488220.4292.1402369436876.JavaMail.root@daemoninthecloset.org> <5396CD41.2080300@FreeBSD.org> <1520746932.4518.1402423896830.JavaMail.root@daemoninthecloset.org> <53974CA3.7010701@FreeBSD.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <53974CA3.7010701@FreeBSD.org> User-Agent: Mutt/1.4.2.3i X-Operating-System: FreeBSD 7.2-RELEASE i386 X-PGP-Fingerprint: 54BA 873B 6515 3F10 9E88 9322 9CB1 8F74 6D3F A396 X-Files: The truth is out there X-URL: http://resnet.uoregon.edu/~gurney_j/ X-Resume: http://resnet.uoregon.edu/~gurney_j/resume.html X-TipJar: bitcoin:13Qmb6AeTgQecazTWph4XasEsP7nGRbAPE X-to-the-FBI-CIA-and-NSA: HI! HOW YA DOIN? can i haz chizburger? X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.2.2 (h2.funkthat.com [127.0.0.1]); Tue, 10 Jun 2014 11:49:21 -0700 (PDT) Cc: Bryan Venteicher , current@freebsd.org, net@freebsd.org X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Jun 2014 18:49:27 -0000 Alexander V. Chernikov wrote this message on Tue, Jun 10, 2014 at 22:21 +0400: > On 10.06.2014 22:11, Bryan Venteicher wrote: > > > >----- Original Message ----- > >>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. > >> > > > >It will be a bit before I'm able to capture that. Here's a Flamegraph from > >earlier in the year showing an absurd amount of time spent in bpf_mtap(): > Can you briefly describe test setup? For mine, one machine is sink: nc -l 2387 > /dev/null The machine w/ dhclient is source: nc carbon 2387 < /dev/zero > (Actually I'm interested in overall pps rate, bpf filter used and match > ratio). the overal rate is ~26k pps both in and out (so total ~52kpps)... So, netstat -B; sleep 5; netstat -B gives: Pid Netif Flags Recv Drop Match Sblen Hblen Command 919 em0 --fs--l 6275907 6275938 6275961 4060 2236 dhclient 937 em0 -ifs--l 6275992 0 1 0 0 dhclient Pid Netif Flags Recv Drop Match Sblen Hblen Command 919 em0 --fs--l 6539717 6539752 6539775 4060 2236 dhclient 937 em0 -ifs--l 6539806 0 1 0 0 dhclient -- John-Mark Gurney Voice: +1 415 225 5579 "All that I will do, has been done, All that I have, has not."