Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1soxsZ-00FCS4-1b for pgsql-hackers@arkaria.postgresql.org; Fri, 13 Sep 2024 04:25:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1soxsX-00A3sj-QS for pgsql-hackers@arkaria.postgresql.org; Fri, 13 Sep 2024 04:25:53 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1soxsX-00A3s3-GC for pgsql-hackers@lists.postgresql.org; Fri, 13 Sep 2024 04:25:53 +0000 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1soxsT-000vNh-9a for pgsql-hackers@lists.postgresql.org; Fri, 13 Sep 2024 04:25:52 +0000 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-42cb8dac900so15882095e9.3 for ; Thu, 12 Sep 2024 21:25:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726201549; x=1726806349; darn=lists.postgresql.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=9YArSqFvdVqeNB8I/Y7WofO1tatlm2JdGFOp6dAtZmk=; b=OW3wj19sOEGnc/CmJ9Qc9NcM8dXxFHT6sdPLr/7rzZCbhEjgDOrmAvCt4OdE96uc+L EqCKDCSRqHW+3mHGPvXXGcHJ09aFiYjro2eqt5hQw53+eaWzqGqUsm3EV9bbXBNUvP4n +vnuy6VQt7/BL0NAMk6hzwElApA2pHZFwNAtdbueCshW/yMRNuZreSvF+bidoic3DQEh BBrC/RvaKURWROoCqzNiFoJQqfyFvWyVn6ELFmRjISO3cUuxkjQyiyK6e0BXVBwvz/NK 2woYdtrm+5aKhTmEcOCFxv4h4vULYbYQJGp2tCk5YVt0dQx5nUiyVzdF8hdKLQVD0Mi8 yPUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726201549; x=1726806349; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=9YArSqFvdVqeNB8I/Y7WofO1tatlm2JdGFOp6dAtZmk=; b=su2krVUYubGzWyl+H8BPrHJrjhmxZ46tARUMnUbX01grlWvDN8N1ycG/a/WvsoMkHO mV6+HPYJfu2LSNPZTU6vENFfDJBnYYRDeEwcvWY2quzFLWM4pT9V3axOSyWA2D5UI7qK yMbXhXOPCrAyx5+h3AIMtTw7+g2L/c1KoayTcoI9FML2MYH3M6LvgigL4Rd4HfsYswdl DGvduXcglNl1+B9hTOrh8VYsNqlZzBifOWqqlEF1GYxO98Kg0J25Kgk0pnb8nUtcgUf2 +sWquhZSefcybG01xqeyUv9phFYTKxHqonDRADM6nCO25kQN/sWZocIgvwZ7Sj5tp4m7 m8UA== X-Forwarded-Encrypted: i=1; AJvYcCULnHj0oFHWd9whBNaPO22FmLPJ1c9oKvUidptAnitsxQvJ+r8RD4CudB9WUapj9fm1nGZDAOrNYQkC2rBY@lists.postgresql.org X-Gm-Message-State: AOJu0YwbKFhutSnVlRF0dLViC/2VgH/+uYiOKu0LZpSlG3/XIhxbBuo3 PYj+cr7cYGacQEcY4Y6TpxX+xd9mn+BZyrLeW6tFoz4PGjjj+rXI X-Google-Smtp-Source: AGHT+IEK40xMeuZvgEs5PTzt9C5WONPYSVIoB4LCpUzwiCVbgwS8hzZF6XuBGyoZ+qnyyv79c/qQWw== X-Received: by 2002:a05:600c:1d1a:b0:42c:b45d:4a7b with SMTP id 5b1f17b1804b1-42cdb56ade7mr45762725e9.25.1726201548593; Thu, 12 Sep 2024 21:25:48 -0700 (PDT) Received: from ip-10-97-1-34.eu-west-3.compute.internal (ec2-15-236-134-5.eu-west-3.compute.amazonaws.com. [15.236.134.5]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37895675c11sm15660381f8f.55.2024.09.12.21.25.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Sep 2024 21:25:48 -0700 (PDT) Date: Fri, 13 Sep 2024 04:25:46 +0000 From: Bertrand Drouvot To: Alvaro Herrera Cc: Kyotaro Horiguchi , pgsql-hackers@lists.postgresql.org Subject: Re: per backend I/O statistics Message-ID: References: <202409051303.qumelxccgzzn@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On Fri, Sep 06, 2024 at 03:03:17PM +0000, Bertrand Drouvot wrote: > The struct size is 1040 Bytes and that's much more reasonable than the size > needed for per backend I/O stats in v1 (about 16KB). One could think that's a high increase of shared memory usage with a high number of connections (due to the fact that it's implemented as "fixed amount" stats based on the max number of backends). So out of curiosity, I did some measurements with: dynamic_shared_memory_type=sysv shared_memory_type=sysv max_connections=20000 On my lab, ipcs -m gives me: - on master key shmid owner perms bytes nattch status 0x00113a04 51347487 postgres 600 1149394944 6 0x4bc9f2fa 51347488 postgres 600 4006976 6 0x46790800 51347489 postgres 600 1048576 2 - with v3 applied key shmid owner perms bytes nattch status 0x00113a04 51347477 postgres 600 1170227200 6 0x08e04b0a 51347478 postgres 600 4006976 6 0x74688c9c 51347479 postgres 600 1048576 2 So, with 20000 max_connections (not advocating that's a reasonable number in all the cases), that's a 1170227200 - 1149394944 = 20 MB increase of shared memory (expected with 20K max_connections and the new struct size of 1040 Bytes) as compare to master which is 1096 MB. It means that v3 produces about 2% shared memory increase with 20000 max_connections. Out of curiosity with max_connections=100000, then: - on master: ------ Shared Memory Segments -------- key shmid owner perms bytes nattch status 0x00113a04 52953134 postgres 600 5053915136 6 0x37abf5ce 52953135 postgres 600 20006976 6 0x71c07d5c 52953136 postgres 600 1048576 2 - with v3: ------ Shared Memory Segments -------- key shmid owner perms bytes nattch status 0x00113a04 52953144 postgres 600 5157945344 6 0x7afb24de 52953145 postgres 600 20006976 6 0x2695af58 52953146 postgres 600 1048576 2 So, with 100000 max_connections (not advocating that's a reasonable number in all the cases), that's a 5157945344 - 5053915136 = 100 MB increase of shared memory (expected with 100K max_connections and the new struct size of 1040 Bytes) as compare to master which is about 4800 MB. It means that v3 produces about 2% shared memory increase with 100000 max_connections. Then, based on those numbers, I think that the "fixed amount" approach is a good one as 1/ the amount of shared memory increase is "relatively" small and 2/ most probably provides performance benefits as compare to the "non fixed" approach. Regards, -- Bertrand Drouvot PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com