improving zonec performance on many zones

fujiwara at jprs.co.jp fujiwara at jprs.co.jp
Thu Apr 21 05:37:46 UTC 2005


> From: Erik Rozendaal <erik at nlnetlabs.nl>
> fujiwara at jprs.co.jp wrote:
> > 
> > This patch needs more memory space(number of ownernames * sizeof(pointer)).
> > But large number of zones case, it improves "zonec" performance.
> 
> If you are sure every zone is passed to zonec only once (the usual case) 
> you can simply always start a new zone when a SOA record is encountered 
> by applying the attached patch. This avoids the memory overhead of 
> another pointer in domain_type.

I know this. I found this problem a half year ago(changes between
nsd-2.1.1 and 2.1.2), someone proposed same as this patch in my
company.

But I cannot sure always usual and this should be detected.  Then, I
added one bitfield to domain_type and check it and this patch does not
cost memory usage.

Is this patch acceptable?

# operators dislike unofficial patches.

> In the future NSD will use a binary search instead here, so that should 
> also solve this performance problem.

# I believe this namedb_find_zone() search is useless.

--
Fujiwara, Kazunori	JPRS


diff -u 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	Thu Apr 21 13:22:55 2005
@@ -43,7 +43,8 @@
 	result->plugin_data = NULL;
 #endif
 	result->is_existing = 0;
-	
+	result->is_apex = 0;
+
 	return result;
 }
 
diff -u 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	Thu Apr 21 13:22:19 2005
@@ -52,6 +52,7 @@
 	 * This domain name exists (see wildcard clarification draft).
 	 */
 	unsigned     is_existing : 1;
+	unsigned     is_apex : 1;
 };
 
 struct zone
diff -u 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	Thu Apr 21 14:20:28 2005
@@ -1037,8 +1037,14 @@
 		 * This is a SOA record, start a new zone or continue
 		 * an existing one.
 		 */
-		zone = namedb_find_zone(parser->db, rr->owner);
-		if (!zone) {
+		if (rr->owner->is_apex) {
+			/*
+			   should be error!
+			   every zone should be passed to zonec only once.
+			*/
+			zone = namedb_find_zone(parser->db, rr->owner);
+			assert(zone);
+		} else {
 			/* new zone part */
 			zone = (zone_type *) region_alloc(parser->region,
 							  sizeof(zone_type));
@@ -1046,10 +1052,12 @@
 			zone->soa_rrset = NULL;
 			zone->ns_rrset = NULL;
 			zone->is_secure = 0;
-			
+
 			/* insert in front of zone list */
 			zone->next = parser->db->zones;
 			parser->db->zones = zone;
+
+			rr->owner->is_apex = 1;
 		}
 		
 		/* parser part */



More information about the nsd-users mailing list