2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 14:35:26 +00:00

damp interations adjustments [RT#15404

This commit is contained in:
Mark Andrews
2005-09-20 04:22:46 +00:00
parent 2524b3e666
commit 4c1817c29c
4 changed files with 76 additions and 27 deletions

View File

@@ -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

View File

@@ -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;

View File

@@ -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;

View File

@@ -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