Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gC9bR-0000Av-0M for pgsql-hackers@arkaria.postgresql.org; Mon, 15 Oct 2018 20:36:37 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gC9bO-0006vp-MD for pgsql-hackers@arkaria.postgresql.org; Mon, 15 Oct 2018 20:36:34 +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_SHA384:256) (Exim 4.89) (envelope-from ) id 1gC9bO-0006vi-FB for pgsql-hackers@lists.postgresql.org; Mon, 15 Oct 2018 20:36:34 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gC9bM-0003Xt-9e for pgsql-hackers@postgresql.org; Mon, 15 Oct 2018 20:36:34 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id w9FKaQnN018431; Mon, 15 Oct 2018 16:36:26 -0400 From: Tom Lane To: Andres Freund cc: pgsql-hackers@postgresql.org, Thomas Munro Subject: Re: Large writable variables In-reply-to: <20181015200754.7y7zfuzsoux2c4ya@alap3.anarazel.de> References: <20181015200754.7y7zfuzsoux2c4ya@alap3.anarazel.de> Comments: In-reply-to Andres Freund message dated "Mon, 15 Oct 2018 13:07:54 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <18429.1539635786.1@sss.pgh.pa.us> Date: Mon, 15 Oct 2018 16:36:26 -0400 Message-ID: <18430.1539635786@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Andres Freund writes: > So we have 500kb of not-initialized memory mapped into every > process. That's, uh, not nothing. Bleah. > 0000000008585088 0000000000131104 b hist_entries > 0000000008716192 0000000000016384 b hist_start I'm unsure what fraction of processes would have use for these. > 0000000008435040 0000000000085280 b DCHCache > 0000000008391168 0000000000043840 b NUMCache We could surely allocate these on first use. > 0000000008560224 0000000000023440 b tzdefrules_s > 0000000008536704 0000000000023440 b gmtmem.7009 I think that tzdefrules_s is not used in common cases (though I could be wrong about that), so we could win by alloc-on-first-use. The same might be true for gmtmem, but there's a sticking point: there is no provision for failure there, so I'm unsure how we avoid crashing on OOM. > 0000000008238336 0000000000008192 b PqRecvBuffer > 0000000008734208 0000000000005136 B BackendWritebackContext > 0000000008386368 0000000000003200 b held_lwlocks These are below my personal threshold of pain. > fmgr_builtins isn't readonly even though declared a const - I assume > because it's full of addresses that will be mapped differently from > execution to execution. Check. > I'm unclear as to why ScanKeywords, DCH_keywords aren't in a readonly > section. I think it's the same problem: pointers can't be truly const because they have to be changed if one relocates the executable. We could possibly fix these by changing the data structure so that what's in a ScanKeywords entry is an offset into some giant string constant somewhere. No idea how that would affect performance, but I do notice that we could reduce the sizeof(ScanKeyword), which can't hurt. regards, tom lane