Small fix, big improvement

M. Warner Losh imp____village.org
Fri Feb 22 00:14:49 CET 2002


Here's a small fix to snmp++v3.1.6.  I'm doing some serious profiling
to find out why my daemon is running so slowly.  I have some test data
where I set 18929 OIDs in a row (this is our startup condition).  This
change takes the CPU time from 46.66s down to 41.04s (compiled
profiling).

It takes advantage of the fact that UdpAddress::set_port calls
format_output so we don't we don't have to call it again after it
returns.  This reduces the number of sprintf calls in the above test
case from 1,104,030[sic] to 725,450[sic].  While there is more room
for improvement, this should help right away.  I should have more of
these soon, since I'd like to shave another 600,000 to 700,000 calls
to sprintf off these numbers (and likely calls to other things as
well).

Warner

--- src/address.cpp~	Mon Feb 18 15:08:18 2002
+++ src/address.cpp	Thu Feb 21 15:44:44 2002
@@ -662,9 +662,8 @@
   smival.value.string.len = UDPIPLEN;
   smival.value.string.ptr = address_buffer;
 
-  set_port(0);
   sep = ':';
-  format_output();
+  set_port(0);
 };
 
 //-----------------[ construct an Udp address with another Udp address ]---
@@ -678,7 +677,6 @@
   // Copy the port value
   sep = ':';
   set_port(udpaddr.get_port());
-  format_output();
 };
 
 // constructor with a dotted string
@@ -731,7 +729,6 @@
   }
   sep = ':';
   set_port(port);
-  format_output();
 };
 
 
@@ -745,7 +742,6 @@
 
   sep = ':';
   set_port(0);
-  format_output();
 };
 
 
@@ -796,7 +792,6 @@
 
   (IpAddress &)*this = udpaddr; // use ancestor assignment for ipaddr value
   set_port(udpaddr.get_port());	// copy to port value
-  format_output();
   return *this;
 }
 



More information about the AGENTPP mailing list