From: Mark Andrews Date: Tue, 20 Sep 2005 04:22:46 +0000 (+0000) Subject: damp interations adjustments [RT#15404 X-Git-Tag: v9.4.0a2~31^2~17 X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=4c1817c29c78d533eae9f4bdf8c9b4d5c90ebfdb;p=thirdparty%2Fbind9.git damp interations adjustments [RT#15404 --- diff --git a/lib/dns/cache.c b/lib/dns/cache.c index 4313dea2aab..e95c46b3575 100644 --- a/lib/dns/cache.c +++ b/lib/dns/cache.c @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: cache.c,v 1.64 2005/09/05 02:54:37 marka Exp $ */ +/* $Id: cache.c,v 1.65 2005/09/20 04:22:44 marka Exp $ */ /*! \file */ @@ -157,6 +157,12 @@ cleaner_shutdown_action(isc_task_t *task, isc_event_t *event); static void overmem_cleaning_action(isc_task_t *task, isc_event_t *event); +/*% + * Work out how many nodes can be cleaned in the time between two + * requests to the nameserver. Smooth the resulting number and use + * it as a estimate for the number of nodes to be cleaned in the next + * iteration. + */ static void adjust_increment(cache_cleaner_t *cleaner, unsigned int remaining, isc_time_t *start) @@ -169,14 +175,14 @@ adjust_increment(cache_cleaner_t *cleaner, unsigned int remaining, unsigned int names; /* - * Tune for minumum of 100 pps. + * Tune for minumum of 100 packets per second (pps). */ if (pps < 100) pps = 100; isc_time_now(&end); - interval = 1000000 / pps; + interval = 1000000 / pps; /* Interval between packets in usecs. */ if (interval == 0) interval = 1; @@ -190,14 +196,18 @@ adjust_increment(cache_cleaner_t *cleaner, unsigned int remaining, interval, names, usecs); if (usecs == 0) { + /* + * If we cleaned all the nodes in unmeasurable time + * double the number of nodes to be cleaned next time. + */ if (names == cleaner->increment) { cleaner->increment *= 2; if (cleaner->increment > DNS_CACHE_CLEANERINCREMENT) cleaner->increment = DNS_CACHE_CLEANERINCREMENT; isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE, DNS_LOGMODULE_CACHE, ISC_LOG_INFO, - "new clear->increment = %d\n", - cleaner->increment); + "%p:new clear->increment = %d\n", + cleaner, cleaner->increment); } return; } @@ -209,10 +219,14 @@ adjust_increment(cache_cleaner_t *cleaner, unsigned int remaining, else if (new > DNS_CACHE_CLEANERINCREMENT) new = DNS_CACHE_CLEANERINCREMENT; + /* Smooth */ + new = (new + cleaner->increment * 7) / 8; + cleaner->increment = (unsigned int)new; + isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE, DNS_LOGMODULE_CACHE, - ISC_LOG_INFO, "new clear->increment = %u\n", - cleaner->increment); + ISC_LOG_INFO, "%p:new clear->increment = %u\n", + cleaner, cleaner->increment); } static inline isc_result_t diff --git a/lib/dns/include/dns/lib.h b/lib/dns/include/dns/lib.h index 5f384fd6923..0e160bfbbcb 100644 --- a/lib/dns/include/dns/lib.h +++ b/lib/dns/include/dns/lib.h @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: lib.h,v 1.11 2005/08/15 01:21:07 marka Exp $ */ +/* $Id: lib.h,v 1.12 2005/09/20 04:22:46 marka Exp $ */ #ifndef DNS_LIB_H #define DNS_LIB_H 1 @@ -27,6 +27,9 @@ ISC_LANG_BEGINDECLS +/*% + * Tuning: external query load in packets per seconds. + */ LIBDNS_EXTERNAL_DATA extern unsigned int dns_pps; LIBDNS_EXTERNAL_DATA extern isc_msgcat_t *dns_msgcat; diff --git a/lib/dns/masterdump.c b/lib/dns/masterdump.c index 790c19d7240..705050232ed 100644 --- a/lib/dns/masterdump.c +++ b/lib/dns/masterdump.c @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: masterdump.c,v 1.80 2005/09/05 02:54:37 marka Exp $ */ +/* $Id: masterdump.c,v 1.81 2005/09/20 04:22:44 marka Exp $ */ /*! \file */ @@ -1370,8 +1370,14 @@ dumptostreaminc(dns_dumpctx_t *dctx) { result = dns_dbiterator_next(dctx->dbiter); } + /* + * Work out how many nodes can be written in the time between + * two requests to the nameserver. Smooth the resulting number and + * use it as a estimate for the number of nodes to be written in the + * next iteration. + */ if (dctx->nodes != 0 && result == ISC_R_SUCCESS) { - unsigned int pps = dns_pps; + unsigned int pps = dns_pps; /* packets per second */ unsigned int interval; isc_uint64_t usecs; isc_time_t end; @@ -1379,7 +1385,7 @@ dumptostreaminc(dns_dumpctx_t *dctx) { isc_time_now(&end); if (pps < 100) pps = 100; - interval = 1000000 / pps; + interval = 1000000 / pps; /* interval in usecs */ if (interval == 0) interval = 1; usecs = isc_time_microdiff(&end, &start); @@ -1388,12 +1394,20 @@ dumptostreaminc(dns_dumpctx_t *dctx) { if (dctx->nodes > 1000) dctx->nodes = 1000; } else { - dctx->nodes = dctx->nodes * interval; - dctx->nodes /= (unsigned int)usecs; - if (dctx->nodes == 0) - dctx->nodes = 1; - else if (dctx->nodes > 1000) - dctx->nodes = 1000; + nodes = dctx->nodes * interval; + nodes /= (unsigned int)usecs; + if (nodes == 0) + nodes = 1; + else if (nodes > 1000) + nodes = 1000; + + /* Smooth and assign. */ + dctx->nodes = (nodes + dctx->nodes * 7) / 8; + + isc_log_write(dns_lctx, ISC_LOGCATEGORY_GENERAL, + DNS_LOGMODULE_MASTERDUMP, ISC_LOG_INFO, + "dumptostreaminc(%p) new nodes -> %d\n", + dctx, dctx->nodes); } dns_dbiterator_pause(dctx->dbiter); result = DNS_R_CONTINUE; diff --git a/lib/dns/rbtdb.c b/lib/dns/rbtdb.c index 2e7a55d995e..6d89a19f6ae 100644 --- a/lib/dns/rbtdb.c +++ b/lib/dns/rbtdb.c @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: rbtdb.c,v 1.216 2005/09/05 02:54:37 marka Exp $ */ +/* $Id: rbtdb.c,v 1.217 2005/09/20 04:22:45 marka Exp $ */ /*! \file */ @@ -551,34 +551,52 @@ free_rbtdb_callback(isc_task_t *task, isc_event_t *event) { free_rbtdb(rbtdb, ISC_TRUE, event); } +/*% + * Work out how many nodes can be deleted in the time between two + * requests to the nameserver. Smooth the resulting number and use it + * as a estimate for the number of nodes to be deleted in the next + * iteration. + */ static unsigned int adjust_quantum(unsigned int old, isc_time_t *start) { - unsigned int pps = dns_pps; + unsigned int pps = dns_pps; /* packets per second */ unsigned int interval; isc_uint64_t usecs; isc_time_t end; + unsigned int new; if (pps < 100) pps = 100; isc_time_now(&end); - interval = 1000000 / pps; + interval = 1000000 / pps; /* interval in usec */ if (interval == 0) interval = 1; usecs = isc_time_microdiff(&end, start); if (usecs == 0) { + /* + * We were unable to measure the amount of time taken. + * Double the nodes deleted next time. + */ old *= 2; if (old > 1000) old = 1000; return (old); } - old = old * interval; - old /= (unsigned int)usecs; - if (old == 0) - old = 1; - else if (old > 1000) - old = 1000; - return (old); + new = old * interval; + new /= (unsigned int)usecs; + if (new == 0) + new = 1; + else if (new > 1000) + new = 1000; + + /* Smooth */ + new = (new + old * 3) / 4; + + isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE, DNS_LOGMODULE_CACHE, + ISC_LOG_INFO, "adjust_quantum -> %d\n", new); + + return (new); } static void