Hi, folks.
I'm testing NSD server performance on serveral zones and I found zonec
improvement point.
"zonec" needs large compile time for many(10000 or 1 million or more)
zones.
At each SOA RR, namedb_find_zone() is called and each SOA ownername
pointer is always compared with all zones->apex in this function.
As a result, this compare loop runs N(N-1)/2 times. (N = number of zones)
namedb_find_zone() processing time grows dominant as number of zones
grows.
To fix this, I added one member (zone_type pointer) to domain_type
and record zone pointer to APEX domainname.
This patch needs more memory space(number of ownernames * sizeof(pointer)).
But large number of zones case, it improves "zonec" performance.
--
Fujiwara, Kazunori JPRS
diff -ub nsd-2.2.1/namedb.c nsd-2.2.1+/namedb.c
--- nsd-2.2.1/namedb.c Wed Feb 9 19:19:53 2005
+++ nsd-2.2.1+/namedb.c Mon Apr 18 16:34:23 2005
@@ -43,6 +43,7 @@
result->plugin_data = NULL;
#endif
result->is_existing = 0;
+ result->apexzone = NULL;
return result;
}
diff -ub nsd-2.2.1/namedb.h nsd-2.2.1+/namedb.h
--- nsd-2.2.1/namedb.h Tue Jan 4 21:26:22 2005
+++ nsd-2.2.1+/namedb.h Mon Apr 18 16:32:46 2005
@@ -52,6 +52,7 @@
* This domain name exists (see wildcard clarification draft).
*/
unsigned is_existing : 1;
+ zone_type *apexzone;
};
struct zone
diff -ub nsd-2.2.1/zonec.c nsd-2.2.1+/zonec.c
--- nsd-2.2.1/zonec.c Thu Jan 27 19:38:53 2005
+++ nsd-2.2.1+/zonec.c Mon Apr 18 17:16:42 2005
@@ -1037,7 +1037,8 @@
* This is a SOA record, start a new zone or continue
* an existing one.
*/
- zone = namedb_find_zone(parser->db, rr->owner);
+ zone = rr->owner->apexzone;
+
if (!zone) {
/* new zone part */
zone = (zone_type *) region_alloc(parser->region,
@@ -1050,6 +1051,8 @@
/* insert in front of zone list */
zone->next = parser->db->zones;
parser->db->zones = zone;
+
+ rr->owner->apexzone = zone;
}
/* parser part */