improving zonec performance on many zones

Erik Rozendaal erik at NLnetLabs.nl
Tue Apr 19 13:53:01 CEST 2005


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.

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

Erik
-------------- next part --------------
Index: zonec.c
===================================================================
RCS file: /cvs/nsd/zonec.c,v
retrieving revision 1.232.4.3
diff -u -r1.232.4.3 zonec.c
--- zonec.c	27 Jan 2005 10:38:53 -0000	1.232.4.3
+++ zonec.c	19 Apr 2005 11:50:47 -0000
@@ -1034,23 +1034,18 @@
 		     
 	if (rr->type == TYPE_SOA) {
 		/*
-		 * This is a SOA record, start a new zone or continue
-		 * an existing one.
+		 * This is a SOA record, start a new zone.
 		 */
-		zone = namedb_find_zone(parser->db, rr->owner);
-		if (!zone) {
-			/* new zone part */
-			zone = (zone_type *) region_alloc(parser->region,
-							  sizeof(zone_type));
-			zone->apex = rr->owner;
-			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;
-		}
+		zone = (zone_type *) region_alloc(parser->region,
+						  sizeof(zone_type));
+		zone->apex = rr->owner;
+		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;
 		
 		/* parser part */
 		parser->current_zone = zone;


More information about the nsd-users mailing list