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 1guft3-00075i-MP for pgsql-hackers@arkaria.postgresql.org; Fri, 15 Feb 2019 15:58:49 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1guft2-0000U4-B7 for pgsql-hackers@arkaria.postgresql.org; Fri, 15 Feb 2019 15:58:48 +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 1guft2-0000Tx-0T for pgsql-hackers@lists.postgresql.org; Fri, 15 Feb 2019 15:58:48 +0000 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gufsy-0003vc-Go for pgsql-hackers@lists.postgresql.org; Fri, 15 Feb 2019 15:58:46 +0000 Received: by mail-wm1-x341.google.com with SMTP id x7so10367264wmj.0 for ; Fri, 15 Feb 2019 07:58:44 -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=EYPfl5ynIUuLlalRjW0y3OITRLQXFXUGw7OxgeYBC3A=; b=ZyT+erNMsEsrIP/9kfdrs88vlFdp6T49o3WaEK8woqUe/QOijTi4LfH3Sq7A0C318S KjKN2pSLbPM/Emg3qg4/caEWGULjuVMHqe6j/uyQMVzvfuxEjqbxif75BPCNWWZODPFS 5KjSq7MPPflMv/UG8ES4mJxi3BR6vgy28Necgc0bc0gRdlAEy26L5K6erOyTa9JoJfG/ iatngNSfM3gXeFxz4J5AUh3J5e+0clRSCHuuoipMZPE2koG46OOAKw48eLvsdz/k2rwm DjRZUdU6p+DPhBTIqlN0gaw6zNJPG32/qEVrrUfwTth4aLtLK1luju6RNTs6KIhzR8l+ aU4g== 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=EYPfl5ynIUuLlalRjW0y3OITRLQXFXUGw7OxgeYBC3A=; b=d+QMwKdphJZwb0i5Bw65VizxmmWDdMqMWIZZm7VY6pNK/zPwctmVkXuZhb6KPBoQrM jK2inneK1HrSonrRooWe6tkbq4DFTGwhJxOXsvQZafgz1jCBhQm0UU4s/zBvhVxDw75L mWZZg442GgWLM+YZtzvsDfv5mnEhZDeKvuputnzfcxMzT5NFQ508wfoxDvdPMbdgkISp bzzuox6QS9KFs++g9E0kl7QBvKnZ+D3RqXgDFP7U2u46Jhf7l8fxS5Lj2OKv5ymvDr1B WisM3Di4qPJQOdDSKmYkSU5LOkxsm2qYwLEwSZ2WADQPFo52eWjjl7dKMALpqfL1IQwi jhag== X-Gm-Message-State: AHQUAuZUIspe5daEUVR+5RtYxeUOUk8mQw+lrCmZSv9M+utXSZQQ94vg 8nt+JanqmksZ3eN7jdrIoaI8rA== X-Google-Smtp-Source: AHgI3IZtRsb8KldYff56O6LRkuopnO/q2XbYqeBgieUKXhX13JbYy/CjU15qW2GKgnivQd8r94veyw== X-Received: by 2002:a1c:ce06:: with SMTP id e6mr1474707wmg.41.1550246322665; Fri, 15 Feb 2019 07:58:42 -0800 (PST) Received: from [10.137.0.17] (ip-86-49-246-90.net.upcbroadband.cz. [86.49.246.90]) by smtp.gmail.com with ESMTPSA id e67sm5976240wmg.1.2019.02.15.07.58.41 (version=TLS1_3 cipher=AEAD-AES128-GCM-SHA256 bits=128/128); Fri, 15 Feb 2019 07:58:41 -0800 (PST) Subject: Re: Protect syscache from bloating with negative cache entries To: Bruce Momjian , Andres Freund Cc: Kyotaro HORIGUCHI , tsunakawa.takay@jp.fujitsu.com, alvherre@2ndquadrant.com, robertmhaas@gmail.com, tgl@sss.pgh.pa.us, ideriha.takeshi@jp.fujitsu.com, pgsql-hackers@lists.postgresql.org, michael.paquier@gmail.com, david@pgmasters.net, craig@2ndquadrant.com References: <20190207.211845.263152487.horiguchi.kyotaro@lab.ntt.co.jp> <0A3221C70F24FB45833433255569204D1FB972A6@G01JPEXMBYT05> <20190212.203628.118792892.horiguchi.kyotaro@lab.ntt.co.jp> <20190213.153114.239737674.horiguchi.kyotaro@lab.ntt.co.jp> <20190214084010.bdn6tmba2j7szo3m@alap3.anarazel.de> <20190214144647.GA19578@momjian.us> From: Tomas Vondra Message-ID: Date: Fri, 15 Feb 2019 16:58:40 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: <20190214144647.GA19578@momjian.us> 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 2/14/19 3:46 PM, Bruce Momjian wrote: > On Thu, Feb 14, 2019 at 12:40:10AM -0800, Andres Freund wrote: >> Hi, >> >> On 2019-02-13 15:31:14 +0900, Kyotaro HORIGUCHI wrote: >>> Instead, I added an accounting(?) interface function. >>> >>> | MemoryContextGettConsumption(MemoryContext cxt); >>> >>> The API returns the current consumption in this memory >>> context. This allows "real" memory accounting almost without >>> overhead. >> >> That's definitely *NOT* almost without overhead. This adds additional >> instructions to one postgres' hottest set of codepaths. >> >> I think you're not working incrementally enough here. I strongly suggest >> solving the negative cache entry problem, and then incrementally go from >> there after that's committed. The likelihood of this patch ever getting >> merged otherwise seems extremely small. > > Agreed --- the patch is going in the wrong direction. > I recall endless discussions about memory accounting in the "memory-bounded hash-aggregate" patch a couple of years ago, and the overhead was one of the main issues there. So yeah, trying to solve that problem here is likely to kill this patch (or at least significantly delay it). ISTM there's a couple of ways to deal with that: 1) Ignore the memory amounts entirely, and do just time-base eviction. 2) If we want some size thresholds (e.g. to disable eviction for backends with small caches etc.) use the number of entries instead. I don't think that's particularly worse that specifying size in MB. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services