From nobody@FreeBSD.org  Tue May  5 13:10:51 2009
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id C92BB10656AC
	for <freebsd-gnats-submit@FreeBSD.org>; Tue,  5 May 2009 13:10:51 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id B68BC8FC35
	for <freebsd-gnats-submit@FreeBSD.org>; Tue,  5 May 2009 13:10:51 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id n45DApxR065349
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 5 May 2009 13:10:51 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id n45DAorr065348;
	Tue, 5 May 2009 13:10:50 GMT
	(envelope-from nobody)
Message-Id: <200905051310.n45DAorr065348@www.freebsd.org>
Date: Tue, 5 May 2009 13:10:50 GMT
From: Michel Henaut <michel.henaut@everyware.ch>
To: freebsd-gnats-submit@FreeBSD.org
Subject: performance issue
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         134231
>Category:       kern
>Synopsis:       [sysctl] sysctl() 80% slower in 7.2 than 6.2 [regression]
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    vwe
>State:          suspended
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue May 05 13:20:02 UTC 2009
>Closed-Date:    
>Last-Modified:  Sat Aug 21 14:27:54 UTC 2010
>Originator:     Michel Henaut
>Release:        5.5,6.2,6.3,6.4,7.0,7.1,7.2
>Organization:
everyware ltd
>Environment:
FreeBSD freebsd72-64.local 7.2-RELEASE FreeBSD 7.2-RELEASE
>Description:
We have an application (server statistics), which uses sysctl and kvm_read. We
discovered that the Cpu use of our collector increased by 80% between 6.2 and
7.2. A small test program calling 10'000 sysctl gives the following result:
6.2:
real    0m2.098s
user    0m0.000s
sys     0m2.073s
7.0:
real    0m4.352s
user    0m0.036s
sys     0m4.119s 
Do you plan another way to get a sysctl resource other than the full scan done
in the different sysctl_find_oid. (use of tree instead of linked list).

regards
>How-To-Repeat:
#include <stdio.h>
#include <sys/types.h>
#include <sys/sysctl.h>
int main()
{
   int mib[4], st, nprocs;
   size_t size;
   int temp_op;
   int op = KERN_PROC_ALL;
   int arg = 0;
   int i;
   mib[0] = CTL_KERN;
   mib[1] = KERN_PROC;
   mib[2] = op;
   mib[3] = arg;
   temp_op = op & ~KERN_PROC_INC_THREAD;
   for (i = 0; i < 10000; i++) {
   st = sysctl(mib, 3, NULL, &size, NULL, 0);
   if (st == -1) {
      fprintf(stderr, "sysctl error\n");
      exit(1);
   }
   }
   exit(0);
}

>Fix:


>Release-Note:
>Audit-Trail:

From: Ed Schouten <ed@80386.nl>
To: bug-followup@FreeBSD.org, michel.henaut@everyware.ch
Cc:  
Subject: Re: kern/134231: [sysctl] sysctl() 80% slower in 7.2 than 6.2
	[regression]
Date: Sun, 17 May 2009 14:57:26 +0200

 --t0UkRYy7tHLRMCai
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 Content-Transfer-Encoding: quoted-printable
 
 Hi Michel,
 
 John Baldwin made some nice improvements to sysctl in HEAD. It still
 uses linked lists, but uses shared locking to lock down the tree. Be
 sure to give it a try when you have time.
 
 --=20
  Ed Schouten <ed@80386.nl>
  WWW: http://80386.nl/
 
 --t0UkRYy7tHLRMCai
 Content-Type: application/pgp-signature
 Content-Disposition: inline
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.9 (FreeBSD)
 
 iEYEARECAAYFAkoQCbYACgkQ52SDGA2eCwUtvwCeL+2X0sVp0A8NatMc+1tK/l05
 YHEAnRoSZWy2UXdDGxOLQuXcElLqz+FZ
 =/7j7
 -----END PGP SIGNATURE-----
 
 --t0UkRYy7tHLRMCai--
State-Changed-From-To: open->suspended 
State-Changed-By: vwe 
State-Changed-When: Sat Aug 21 14:26:42 UTC 2010 
State-Changed-Why:  
submitter wasn't providing feedback for a long time 


Responsible-Changed-From-To: freebsd-bugs->vwe 
Responsible-Changed-By: vwe 
Responsible-Changed-When: Sat Aug 21 14:26:42 UTC 2010 
Responsible-Changed-Why:  
track 

http://www.freebsd.org/cgi/query-pr.cgi?pr=134231 
>Unformatted:
