Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lrUxZ-0000ti-2c for pgsql-admin@arkaria.postgresql.org; Fri, 11 Jun 2021 00:23:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lrUxX-00032p-WC for pgsql-admin@arkaria.postgresql.org; Fri, 11 Jun 2021 00:23:40 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lrUxX-00032h-JI for pgsql-admin@lists.postgresql.org; Fri, 11 Jun 2021 00:23:39 +0000 Received: from mail-io1-xd2c.google.com ([2607:f8b0:4864:20::d2c]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lrUxU-0003mj-Pl for pgsql-admin@postgresql.org; Fri, 11 Jun 2021 00:23:38 +0000 Received: by mail-io1-xd2c.google.com with SMTP id 5so29048666ioe.1 for ; Thu, 10 Jun 2021 17:23:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=nhbNwM/5pveZQ+QuNLV5vYIfapVwa7w2E+tKjFZ+6Nk=; b=zk0bFgcFmyE89M4GTnP3/pGv8QCPYjbn4MoQplTcIbePvZpHGTjXZmYveyZAEWDOtL MekERxrw91L/aRxdHImeoArPc/asw53iqeXmj81gxOGjG2MspSJJBfns6XJBE3Id8gTh vGtdPYGwM4tNQHRrpRy2tq7FqTPHFocJxgClEMVZ2u8CkHFsi7Kc4/In3sn54J69QdEY 6nEqZDZgQTWRDVQ8GJCRgaSc6nEousQVb/5EzJrAcWlRIhmklGD3ew6FiH5uahmNJiJd k3wHWIWqGz+st+0cWepfJroBiAQf0bPgC22wJprS6qHAvDfVMzrkqzvjcJehU3sCabgf lPxg== 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:user-agent; bh=nhbNwM/5pveZQ+QuNLV5vYIfapVwa7w2E+tKjFZ+6Nk=; b=S/00GnDBW5Z4xXkA826Jydl8IKgffSeWJbcRoS9u88R8wsPiaVXOpI0Eb8EY5kVsaC vEw/3ieUeE6fsFq50VKjlrS2kPCvcQYRvcLmzn84DQKNTte0v16TVlgy4NDLjlAugqBX 7X0Dde+OlYs8Gp6sqMdWIn55OSOpiAjGg689lQg9LHU8pgTPNgDoHhmqKa3jG2H8cFGP l63iYIHhTZMv7ybNkQc/OsvCHv9FOAlbOL1eyaLgdI1mcq1+ybXz/V5ZRU3ml43Nahkn 33ePeJ4RtvNcnXQjxW+03KvvsRpMGVqf8hJ4kDFY1KXZsQi7jeh7CZMX3jzbJiivzaJr 9mzw== X-Gm-Message-State: AOAM5324DX9RkyRaxJKo3zucVFc1/D+f6+9R8WKDnPfT1AauoSl64RGm kY2CxctHIyQOfVbhldWHH5cyxA== X-Google-Smtp-Source: ABdhPJxux6pu4GbEUxjT4kyFdvqAD9xVFPPmhly3EL2PaCCFsH7f7oMta+jCZbAnglThUFRfj1X4Ig== X-Received: by 2002:a02:9621:: with SMTP id c30mr1121636jai.113.1623371015798; Thu, 10 Jun 2021 17:23:35 -0700 (PDT) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id r11sm2525361ilo.10.2021.06.10.17.23.34 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 10 Jun 2021 17:23:35 -0700 (PDT) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id 025B2800A36; Thu, 10 Jun 2021 19:23:33 -0500 (CDT) Date: Thu, 10 Jun 2021 19:23:33 -0500 From: Justin Pryzby To: Don Seiler Cc: P C , Magnus Hagander , Julien Rouhaud , Tom Lane , pgsql-admin@postgresql.org Subject: Re: Estimating HugePages Requirements? Message-ID: <20210611002333.GK16435@telsasoft.com> References: <1428485.1623266137@sss.pgh.pa.us> <1429225.1623266925@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, Jun 09, 2021 at 10:55:08PM -0500, Don Seiler wrote: > On Wed, Jun 9, 2021, 21:03 P C wrote: > > > I agree, its confusing for many and that confusion arises from the fact > > that you usually talk of shared_buffers in MB or GB whereas hugepages have > > to be configured in units of 2mb. But once they understand they realize its > > pretty simple. > > > > Don, we have experienced the same not just with postgres but also with > > oracle. I havent been able to get to the root of it, but what we usually do > > is, we add another 100-200 pages and that works for us. If the SGA or > > shared_buffers is high eg 96gb, then we add 250-500 pages. Those few > > hundred MBs may be wasted (because the moment you configure hugepages, the > > operating system considers it as used and does not use it any more) but > > nowadays, servers have 64 or 128 gb RAM easily and wasting that 500mb to > > 1gb does not hurt really. > > I don't have a problem with the math, just wanted to know if it was > possible to better estimate what the actual requirements would be at > deployment time. My fallback will probably be you did and just pad with an > extra 512MB by default. It's because the huge allocation isn't just shared_buffers, but also wal_buffers: | The amount of shared memory used for WAL data that has not yet been written to disk. | The default setting of -1 selects a size equal to 1/32nd (about 3%) of shared_buffers, ... .. and other stuff: src/backend/storage/ipc/ipci.c * Size of the Postgres shared-memory block is estimated via * moderately-accurate estimates for the big hogs, plus 100K for the * stuff that's too small to bother with estimating. * * We take some care during this phase to ensure that the total size * request doesn't overflow size_t. If this gets through, we don't * need to be so careful during the actual allocation phase. */ size = 100000; size = add_size(size, PGSemaphoreShmemSize(numSemas)); size = add_size(size, SpinlockSemaSize()); size = add_size(size, hash_estimate_size(SHMEM_INDEX_SIZE, sizeof(ShmemIndexEnt))); size = add_size(size, dsm_estimate_size()); size = add_size(size, BufferShmemSize()); size = add_size(size, LockShmemSize()); size = add_size(size, PredicateLockShmemSize()); size = add_size(size, ProcGlobalShmemSize()); size = add_size(size, XLOGShmemSize()); size = add_size(size, CLOGShmemSize()); size = add_size(size, CommitTsShmemSize()); size = add_size(size, SUBTRANSShmemSize()); size = add_size(size, TwoPhaseShmemSize()); size = add_size(size, BackgroundWorkerShmemSize()); size = add_size(size, MultiXactShmemSize()); size = add_size(size, LWLockShmemSize()); size = add_size(size, ProcArrayShmemSize()); size = add_size(size, BackendStatusShmemSize()); size = add_size(size, SInvalShmemSize()); size = add_size(size, PMSignalShmemSize()); size = add_size(size, ProcSignalShmemSize()); size = add_size(size, CheckpointerShmemSize()); size = add_size(size, AutoVacuumShmemSize()); size = add_size(size, ReplicationSlotsShmemSize()); size = add_size(size, ReplicationOriginShmemSize()); size = add_size(size, WalSndShmemSize()); size = add_size(size, WalRcvShmemSize()); size = add_size(size, PgArchShmemSize()); size = add_size(size, ApplyLauncherShmemSize()); size = add_size(size, SnapMgrShmemSize()); size = add_size(size, BTreeShmemSize()); size = add_size(size, SyncScanShmemSize()); size = add_size(size, AsyncShmemSize()); #ifdef EXEC_BACKEND size = add_size(size, ShmemBackendArraySize()); #endif /* freeze the addin request size and include it */ addin_request_allowed = false; size = add_size(size, total_addin_request); /* might as well round it off to a multiple of a typical page size */ size = add_size(size, 8192 - (size % 8192)); BTW, I think it'd be nice if this were a NOTICE: | elog(DEBUG1, "mmap(%zu) with MAP_HUGETLB failed, huge pages disabled: %m", allocsize); -- Justin