Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h1ufh-00033f-Cv for pgsql-hackers@arkaria.postgresql.org; Thu, 07 Mar 2019 15:10:57 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1h1ufg-0004HL-23 for pgsql-hackers@arkaria.postgresql.org; Thu, 07 Mar 2019 15:10:56 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h1uff-0004HE-NU for pgsql-hackers@lists.postgresql.org; Thu, 07 Mar 2019 15:10:55 +0000 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h1ufc-0005Pt-KB for pgsql-hackers@lists.postgresql.org; Thu, 07 Mar 2019 15:10:54 +0000 Received: by mail-wr1-x441.google.com with SMTP id w17so17831296wrn.12 for ; Thu, 07 Mar 2019 07:10:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=IF8jHMfLcbhvHlZhV/+GgZk/lwyWdqUwlmanxN7OXHs=; b=aglpca6m0fOOKnR/zNNKQKOAhf35C3NClsxED0pdb0yOIUSJ++4tSLR+IOXg+rlDhc uayd7/39grt60kF4EEgaIu8SSoqKq954Eko55+sP4ab8MJssYwH/g5SwN5qGTnHRG2f0 PFLtPFfeeH+m+K/GYdmQCCleBAB2taSvM1ytzQd8GW/Q5XORP7MwC/6LBlaS9wCaFBuf nBhLBSRHEfSQeva76JoppEsCicQzL52EUt0TpMVbTZT3xiuQNhxnOftdApfOVAMA5uhm UZvALxMXa7OAJR1yyA6Ild1O7aiLozi5wcaBZMobqBZ3LddaBavF1hfK70DmWBdsx0nU 79hA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=IF8jHMfLcbhvHlZhV/+GgZk/lwyWdqUwlmanxN7OXHs=; b=KmnxHyGNCZM63vnxGnmQfZaDZYbodcAwHknlaBBJQUtyCie+ZZ4tlfwB7N5OxlfjjH 48mC9jv3LUNfaZ8879BCjGgMTHzMz1HdH2vzfISL3ywIeINOjtKFe3rHSOBHlzXLjvGj MMQwYNVnz+dVff7oB9R9IDHzHxMBbMUkPPfcwKz5uCYA1ItNUuIlyaPC0xDAPoWUGdsx L4XRzBx8RqCHP4qR8VFcF9CnCy40pScpW32R56T77LwnsO+gEnDw9eya8VEYvlRMj1H5 YiteK5Jx7XgQfVut0yMQn5FL5wpfxAOuMi7hOcnIwVcOsyRB13S8sFq60xxyA3yM25hJ GJJQ== X-Gm-Message-State: APjAAAW9dp+jHkGkFRODi6fTUb6dFYfNCQWaJTNl+6ex2bf1qmKt0DnK vCuMAT8+71a/4WuPewUNeevcrA== X-Google-Smtp-Source: APXvYqzw6xE79rc2HiCVfpRzdPqeELUUnTT0b0tEarkoF3odJGPPSy/UDl37RdmkDXXxWzykqMTNGw== X-Received: by 2002:a05:6000:10c9:: with SMTP id b9mr7105993wrx.281.1551971450819; Thu, 07 Mar 2019 07:10:50 -0800 (PST) Received: from [10.137.0.18] (static-84-42-175-93.net.upcbroadband.cz. [84.42.175.93]) by smtp.gmail.com with ESMTPSA id g15sm7415220wmg.16.2019.03.07.07.10.49 (version=TLS1_3 cipher=AEAD-AES128-GCM-SHA256 bits=128/128); Thu, 07 Mar 2019 07:10:50 -0800 (PST) Subject: Re: Protect syscache from bloating with negative cache entries To: Robert Haas Cc: Tom Lane , Kyotaro HORIGUCHI , Andres Freund , "Tsunakawa, Takayuki" , Alvaro Herrera , Bruce Momjian , "Ideriha, Takeshi" , PostgreSQL Hackers , Michael Paquier , David Steele , Craig Ringer References: <20190225.152653.211323929.horiguchi.kyotaro@lab.ntt.co.jp> <20190301.173245.25820912.horiguchi.kyotaro@lab.ntt.co.jp> <1752.1551903431@sss.pgh.pa.us> <0846ed27-2732-0f1b-e285-6380dfbc17e1@2ndquadrant.com> From: Tomas Vondra Message-ID: <1d2d403c-a1dd-b6c9-d599-e94204442a15@2ndquadrant.com> Date: Thu, 7 Mar 2019 16:10:48 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 3/7/19 4:01 PM, Robert Haas wrote: > On Thu, Mar 7, 2019 at 9:49 AM Tomas Vondra > wrote: >> I don't think this shows any regression, but perhaps we should do a >> microbenchmark isolating the syscache entirely? > > Well, if we need the LRU list, then yeah I think a microbenchmark > would be a good idea to make sure we really understand what the impact > of that is going to be. But if we don't need it and can just remove > it then we don't. > >> What I had in mind is more along these lines: >> >> (a) track number of active syscache entries (increment when adding a new >> one, decrement when evicting one) >> >> (b) track peak number of active syscache entries >> >> (c) after clock-sweep, if (peak > K*active) where K=2 or K=4 or so, do a >> memory context swap, i.e. create a new context, copy active entries over >> and destroy the old one >> >> That would at least free() the memory. Of course, the syscache entries >> may have different sizes, so tracking just numbers of entries is just an >> approximation. But I think it'd be enough. > > Yeah, that could be done. I'm not sure how expensive it would be, and > I'm also not sure how much more effective it would be than what's > currently proposed in terms of actually freeing memory. If you free > enough dead syscache entries, you might manage to give some memory > back to the OS: after all, there may be some locality there. And even > if you don't, you'll at least prevent further growth, which might be > good enough. > I have my doubts about that happening in practice. It might happen for some workloads, but I think the locality is rather unpredictable. > We could consider doing some version of what has been proposed here > and the thing you're proposing here could later be implemented on top > of that. I mean, evicting entries at all is a prerequisite to > copy-and-compact. > Sure. I'm not saying the patch must do this to make it committable. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services