From owner-freebsd-performance@FreeBSD.ORG Mon Feb 4 00:04:44 2008 Return-Path: Delivered-To: freebsd-performance@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 193EF16A421 for ; Mon, 4 Feb 2008 00:04:44 +0000 (UTC) (envelope-from marka@isc.org) Received: from drugs.dv.isc.org (drugs.dv.isc.org [IPv6:2001:470:1f00:820:214:22ff:fed9:fbdc]) by mx1.freebsd.org (Postfix) with ESMTP id B1C8B13C457 for ; Mon, 4 Feb 2008 00:04:43 +0000 (UTC) (envelope-from marka@isc.org) Received: from drugs.dv.isc.org (localhost [127.0.0.1]) by drugs.dv.isc.org (8.14.2/8.14.1) with ESMTP id m1404eNS038322; Mon, 4 Feb 2008 11:04:42 +1100 (EST) (envelope-from marka@drugs.dv.isc.org) Message-Id: <200802040004.m1404eNS038322@drugs.dv.isc.org> To: Attila Nagy From: Mark Andrews In-reply-to: Your message of "Sun, 03 Feb 2008 20:24:25 BST." <47A614E9.4030501@fsn.hu> Date: Mon, 04 Feb 2008 11:04:40 +1100 Sender: marka@isc.org X-Mailman-Approved-At: Mon, 04 Feb 2008 00:15:29 +0000 Cc: =?UTF-8?B?SklOTUVJIFRhdHV5YSAvIOelnuaYjumBlOWTiQ==?= , freebsd-performance@freebsd.org, bind-users@isc.org Subject: Re: max-cache-size doesn't work with 9.5.0b1 X-BeenThere: freebsd-performance@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Performance/tuning List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Feb 2008 00:04:44 -0000 > On 2008.01.30. 3:28, JINMEI Tatuya / 神明達哉 wrote: > > Okay, please use the attached patch (applicable to 9.5.0b1, and also > > to 9.5.0b2 when it's published). Build it with: > > % STD_CDEFINES='-DLRU_DEBUG2=2' ./configure --enable-threads > > (or set STD_CDEFINES using setenv if you use a csh variant) > > > > The log messages shouldn't be very noisy, but if you find them too > > frequent, rebuild it with: > > % STD_CDEFINES='-DLRU_DEBUG2=1' ./configure --enable-threads > > > > Note that, if this is a thread-related bug, it may not always be > > reproduceable; please try several times if the problem doesn't seem to > > happen. (BTW: did it always occur when you first found the problem?) > > > Yes, if bind was built with threads, the memory usage always grew behind > max-cache-size very quickly. > > Here is the log: > http://people.fsn.hu/~bra/freebsd/bind950-memory-20080203/bind950b1 > the memory usage (RSS, reported by top) in megabytes: > 19:10:37 466 > 19:11:20 522 > 19:11:53 566 > 19:13:06 666 > 19:14:17 766 > > max-cache-size was set to 64M. Please try this patch. Mark Index: lib/dns/cache.c =================================================================== RCS file: /proj/cvs/prod/bind9/lib/dns/cache.c,v retrieving revision 1.76 diff -u -r1.76 cache.c --- lib/dns/cache.c 19 Oct 2007 17:15:53 -0000 1.76 +++ lib/dns/cache.c 3 Feb 2008 23:59:46 -0000 @@ -708,8 +708,11 @@ LOCK(&cache->cleaner.lock); - dns_db_overmem(cache->db, overmem); - cache->cleaner.overmem = overmem; + if (overmem != cache->cleaner.overmem) { + dns_db_overmem(cache->db, overmem); + cache->cleaner.overmem = overmem; + isc_mem_water(cache->mctx, mark); + } UNLOCK(&cache->cleaner.lock); } Index: lib/isc/mem.c =================================================================== RCS file: /proj/cvs/prod/bind9/lib/isc/mem.c,v retrieving revision 1.140 diff -u -r1.140 mem.c --- lib/isc/mem.c 18 Jan 2008 23:46:58 -0000 1.140 +++ lib/isc/mem.c 3 Feb 2008 23:59:48 -0000 @@ -1086,7 +1086,6 @@ ADD_TRACE(ctx, ptr, size, file, line); if (ctx->hi_water != 0U && !ctx->hi_called && ctx->inuse > ctx->hi_water) { - ctx->hi_called = ISC_TRUE; call_water = ISC_TRUE; } if (ctx->inuse > ctx->maxinuse) { @@ -1144,8 +1143,6 @@ */ if (ctx->hi_called && (ctx->inuse < ctx->lo_water || ctx->lo_water == 0U)) { - ctx->hi_called = ISC_FALSE; - if (ctx->water != NULL) call_water = ISC_TRUE; } @@ -1155,6 +1152,18 @@ (ctx->water)(ctx->water_arg, ISC_MEM_LOWATER); } +void +isc_mem_water(isc_mem_t *ctx, int flag) { + REQUIRE(VALID_CONTEXT(ctx)); + + MCTXLOCK(ctx, &ctx->lock); + if (flag == ISC_MEM_LOWATER) + ctx->hi_called = ISC_FALSE; + else if (flag == ISC_MEM_HIWATER) + ctx->hi_called = ISC_TRUE; + MCTXUNLOCK(ctx, &ctx->lock); +} + #if ISC_MEM_TRACKLINES static void print_active(isc_mem_t *mctx, FILE *out) { -- Mark Andrews, ISC 1 Seymour St., Dundas Valley, NSW 2117, Australia PHONE: +61 2 9871 4742 INTERNET: Mark_Andrews@isc.org