* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: cache.c,v 1.57.18.7 2005/09/05 02:30:51 marka Exp $ */
+/* $Id: cache.c,v 1.57.18.8 2005/09/20 04:33:45 marka Exp $ */
/*! \file */
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)
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;
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;
}
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
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: lib.h,v 1.8.18.3 2005/08/15 01:46:51 marka Exp $ */
+/* $Id: lib.h,v 1.8.18.4 2005/09/20 04:33:48 marka Exp $ */
#ifndef DNS_LIB_H
#define DNS_LIB_H 1
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;
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: masterdump.c,v 1.73.18.7 2005/09/05 02:30:51 marka Exp $ */
+/* $Id: masterdump.c,v 1.73.18.8 2005/09/20 04:33:46 marka Exp $ */
/*! \file */
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;
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);
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;
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: rbtdb.c,v 1.196.18.18 2005/09/05 02:30:52 marka Exp $ */
+/* $Id: rbtdb.c,v 1.196.18.19 2005/09/20 04:33:46 marka Exp $ */
/*! \file */
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