Bug 134231 - [sysctl] sysctl() 80% slower in 7.2 than 6.2 [regression]
Summary: [sysctl] sysctl() 80% slower in 7.2 than 6.2 [regression]
Status: Open
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: Unspecified
Hardware: Any Any
: Normal Affects Only Me
Assignee: Mark Linimon
Depends on:
Reported: 2009-05-05 14:20 UTC by Michel Henaut
Modified: 2020-07-11 02:32 UTC (History)
0 users

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Michel Henaut 2009-05-05 14:20:02 UTC
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:
real    0m2.098s
user    0m0.000s
sys     0m2.073s
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).


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");
Comment 1 Ed Schouten 2009-05-17 13:57:26 UTC
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.

 Ed Schouten <ed@80386.nl>
 WWW: http://80386.nl/
Comment 2 Volker Werth freebsd_committer 2010-08-21 15:26:42 UTC
State Changed
From-To: open->suspended

submitter wasn't providing feedback for a long time 

Comment 3 Volker Werth freebsd_committer 2010-08-21 15:26:42 UTC
Responsible Changed
From-To: freebsd-bugs->vwe

Comment 4 Eitan Adler freebsd_committer freebsd_triage 2018-05-28 19:41:46 UTC
batch change:

For bugs that match the following
-  Status Is In progress 
- Untouched since 2018-01-01.
- Affects Base System OR Documentation


Reset to open status.

I did a quick pass but if you are getting this email it might be worthwhile to double check to see if this bug ought to be closed.
Comment 5 Mark Linimon freebsd_committer freebsd_triage 2020-07-11 02:32:44 UTC
To submitter: is this antique PR still relevant?