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 1isBJy-0004Ui-1L for pgsql-hackers@arkaria.postgresql.org; Thu, 16 Jan 2020 20:00:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1isBJw-0000iG-1s for pgsql-hackers@arkaria.postgresql.org; Thu, 16 Jan 2020 20:00:48 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1isBJv-0000i9-Ov for pgsql-hackers@lists.postgresql.org; Thu, 16 Jan 2020 20:00:47 +0000 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1isBJq-0007yG-5h for pgsql-hackers@postgresql.org; Thu, 16 Jan 2020 20:00:46 +0000 Received: by mail-wr1-x442.google.com with SMTP id w15so20489802wru.4 for ; Thu, 16 Jan 2020 12:00:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=THXTnYUzxNtWrL9e3ANJ2T11OA9Tkh5/PRUCYTbAPZ4=; b=Okyi1nkQdQG7yhbyieAmYISlbXtxroYK0nuU4yIWOH5P0ggJIPYv5LL3p9LffbZSRZ 8vUpO8Dt0FD2WgZoxK0t+zpm6zuSdonRAh3qXI6RGn/axjmnNr52XbPMChOTvb6d7I5D AgACIMfVWPoNACSLhQlJf+s550QsHpBzwefPYELdOesnpUDdbc7PspsTK8Dqqwj5BaBY alIB89DxL4pEWzD2DXngMBJfvCLl+9qPcgJriCSgL7AEl2eNnj9Rlw9lWMzW00gO+stC 1vW7HDaCJaXA7fBkmsE82Emg486MIEu2iDG3dQ1g+AbLAn9OKOy+YdvHpDWOnDDGhmhJ cD5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=THXTnYUzxNtWrL9e3ANJ2T11OA9Tkh5/PRUCYTbAPZ4=; b=EjPfgd3+eHZomEaIlCkERSK+9czLEUXwxk/s5GpuO57mQjOhyXWCxpKSraiSPP4/r6 ZNBriKkPdSEJ7lNSZl8HDVXNRB0xWlbUNonRKUrpeKTCntjlMJ0b73EANLNs0rGb60jn xc+enPKwUrWh7sYiSvBvvJj+Hgh+Gmof13HwmAM7dEJN1AAnxb8Wznfa0lnMWc4/3UX0 tHw5vghGduosYjtD0gnHIhRNBxUn+SgLPJxW90l7pEso7RM9D8GMdZOGoYLc/0h1BCk1 mTGyOhHYGJJUw5peYQet5Y6xOJMAhUgEiZ3TBu/L3h+iKC9BJDOaxMYO+0PSz9Vu+uyI PInA== X-Gm-Message-State: APjAAAWF90n7xkTog+qr3HOa2j2b7vUf2a9eCjUxhjrAW1jRsrYfzprr zbKuM9PvojZ0855d06TD3xXWKg== X-Google-Smtp-Source: APXvYqzg6YNd3BAIQBD7mPX6w+Teab7nhGPniw53zIMBtLbDCZheBsWUJZK0SBrt5LOShthwvL04HQ== X-Received: by 2002:a5d:4b4e:: with SMTP id w14mr5062881wrs.187.1579204840314; Thu, 16 Jan 2020 12:00:40 -0800 (PST) Received: from localhost (ip-86-49-253-92.net.upcbroadband.cz. [86.49.253.92]) by smtp.gmail.com with ESMTPSA id w20sm1557317wmk.34.2020.01.16.12.00.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jan 2020 12:00:39 -0800 (PST) Date: Thu, 16 Jan 2020 21:00:38 +0100 From: Tomas Vondra To: Tom Lane Cc: Andres Freund , Tomas Vondra , pgsql-hackers@postgresql.org Subject: Re: SlabCheck leaks memory into TopMemoryContext Message-ID: <20200116200038.rfqfnqsrjcdv5kwk@development> References: <20200116044119.g45f7pmgz4jmodxj@alap3.anarazel.de> <23952.1579151393@sss.pgh.pa.us> <20200116061732.vvpyexenaortpu5y@alap3.anarazel.de> <27213.1579155900@sss.pgh.pa.us> <20200116064143.opcu2vhcktddpzbh@alap3.anarazel.de> <19743.1579188421@sss.pgh.pa.us> <20200116162500.pcgxmykirm677mt6@development> <20200116164849.75rzho6zn4qppnf3@alap3.anarazel.de> <20200116170153.qp36chsyhikvgvxt@development> <2646.1579195983@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <2646.1579195983@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Thu, Jan 16, 2020 at 12:33:03PM -0500, Tom Lane wrote: >Tomas Vondra writes: >> On Thu, Jan 16, 2020 at 08:48:49AM -0800, Andres Freund wrote: >>> I don't get why it's advantageous to allocate this once for each slab, >>> rather than having it as a global once for all slabs. But anyway, still >>> clearly better than the current situation. > >> It's largely a matter of personal preference - I agree there are cases >> when global variables are the best solution, but I kinda dislike them. >> It seems cleaner to just allocate it as part of the slab, not having to >> deal with different number of chunks per block between slabs. >> Plus we don't have all that many slabs (like 2), and it's only really >> used in debug builds anyway. So I'm not all that woried about this >> wasting a couple extra kB of memory. > >A positive argument for doing it like this is that the overhead goes away >when the SlabContexts are all deallocated, while a global variable would >presumably stick around indefinitely. But I concur that in current usage, >there's hardly any point in worrying about the relative benefits. We >should just keep it simple, and this seems marginally simpler than the >other way. > I think the one possible argument against this approach might be that it adds a field to the struct, so if you have an extension using a Slab context, it'll break if you don't rebuild it. But that only matters if we want to backpatch it (which I think is not the plan) and with memory context checking enabled (which does not apply to regular packages). regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services