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 1uEnRr-00DATn-0w for pgsql-hackers@arkaria.postgresql.org; Tue, 13 May 2025 11:05:23 +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 1uEnQr-004mVj-Pt for pgsql-hackers@arkaria.postgresql.org; Tue, 13 May 2025 11:04:21 +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 1uEnQr-004mVZ-Fd for pgsql-hackers@lists.postgresql.org; Tue, 13 May 2025 11:04:21 +0000 Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uEnQo-001f9L-1q for pgsql-hackers@postgresql.org; Tue, 13 May 2025 11:04:20 +0000 Received: by mail-pj1-x1032.google.com with SMTP id 98e67ed59e1d1-30c3a038acfso5801343a91.3 for ; Tue, 13 May 2025 04:04:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1747134257; x=1747739057; darn=postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=2c7zWZFScb+xrAwzMKuATw392sK54iuK3mTrE5hTaSg=; b=Sx1MvP1xVryKnO5LNaA0/ZO3Gl/Cvg+3PeJ16FXLSomRewkqOO5YY6wV51PYaJkU0X PJIXWEkL4W8dyO3zVCh8CGMlCkxqlsStVGux9ATDYYHlvONmLZ5yJVkDNPYQjZMNBjOA 0+ExsfbEZ9pT3MuMzjaxm0uq2f99iAKTlEy5CuZbPVX4O63y3PG0WgDrrXQHc3wkWP2X g1IxjHAnCJW4udnngler1VxJ5p78f82zIYfRm2XgzFqJtviVntUs0+C91N0hYaSo7l8e tR3EdZgUmrQTEYmMvo7wX4jE+yhpTc9JH6kKuTf86HE9aqk6JRFHnMjz63CWLPKhwozm bs2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747134257; x=1747739057; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2c7zWZFScb+xrAwzMKuATw392sK54iuK3mTrE5hTaSg=; b=bJvp4/2qQrpFNbbGh9b9WJmUd+JQqrrpp/srqjV9cQ1hEzoaudl43upex5uZywqnQ6 PdvZNoHrDN8VO+OEUYWY1UKMjGbPpLuoRgOgDzTgIuXTS9beMh3UxwWjgFpwZPZyDQTp lLv5SS7KRDa105H3Fzy+PLajrtepccME1aIabVg5GFhXoXgZv7az4CDaU3cld8KH9Eky AnVKL6RWfcm1ohBFZCZf+5AYjsJvH+tJiuYZHMqxBXiQcD6gqHdtav73aPVRkq2b9LDX 1LtOcAMfW/5NwfmGan9wNCLQIAR877jXr6/LiCmp8q+vp+dqvD/ENB/wRTmbdHwZADRG wrig== X-Forwarded-Encrypted: i=1; AJvYcCUxagz9x8WZkNeieeayMemM6aRYXzxJx3jlQShW27b/2SVBUkBKEWrzlwqUltdh93Rganw4YFCIt8k0CASN@postgresql.org X-Gm-Message-State: AOJu0Yy5rI8hn3fUj3BQUIUYN1Zv73gUr7ZFRaqivQX7aYd08tHpQbyd DJHDNaR1WU7zkJ/uIl2dq/Nmc35P4oxwxDgp6C8nVSrHwLyHi4dZdgpGCvk5ivDw/hqG+tHBAo/ ux+uz9Sy+wS08aFQ7WyWFE3HX5d1SheHm4Kk= X-Gm-Gg: ASbGncuMJt3oFw6KD1VStM97ztQ23dF3InB8DdycdhUPmEsMYvJBz5jEusuLmk3i0yy xvYDVxnei+piizY7XInCvU34rSBHAYeGJewiL3QyDlE2kEQNLp6+cbEKqW6pVX+o0zktlQQo3CQ 83OflI2mDYW5ppBFtBkV+JTjttYWk18P8w8IM= X-Google-Smtp-Source: AGHT+IF1iIXEyxSo3aoHvXPQ019Fr61ZXLaB6cK+Dqf2rrbH8MJXy/LvcndSMPyDDQoENx/leVGg0BFiFoXB9tFOB6E= X-Received: by 2002:a17:90b:558f:b0:2ee:5958:828 with SMTP id 98e67ed59e1d1-30c3ce050edmr30239096a91.9.1747134256480; Tue, 13 May 2025 04:04:16 -0700 (PDT) MIME-Version: 1.0 References: <3e40eeec-d8bf-4496-854e-485dd901f6a2@vondra.me> <6bf7194e-4c34-4e6d-8215-f6acf8903974@vondra.me> <6705dbd2-060b-4f3c-9fcb-1c7f10880b26@vondra.me> <66283922-0448-44e7-bbdd-38aaf2be34b9@vondra.me> <7987a0b5-9933-457a-b5ba-d28e9cce883b@vondra.me> <4e9a124d-29cb-4fd5-99fb-a5016e508f20@vondra.me> In-Reply-To: From: Amit Kapila Date: Tue, 13 May 2025 16:34:05 +0530 X-Gm-Features: AX0GCFtYkPW987cgEmnd1xGeDJtXwXEooHS0BphnynEDD8_uh3WKP5CuVOqhI10 Message-ID: Subject: Re: Improve monitoring of shared memory allocations To: Rahila Syed Cc: Tomas Vondra , Nazir Bilal Yavuz , Andres Freund , PostgreSQL-development Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, Apr 4, 2025 at 9:15=E2=80=AFPM Rahila Syed = wrote: > > Please find attached the patch which removes the changes for non-shared h= ash tables > and keeps them for shared hash tables. > /* Allocate initial segments */ + i =3D 0; for (segp =3D hashp->dir; hctl->nsegs < nsegs; hctl->nsegs++, segp++) { - *segp =3D seg_alloc(hashp); - if (*segp =3D=3D NULL) - return false; + /* Assign initial segments, which are also pre-allocated */ + if (hashp->isshared) + { + *segp =3D (HASHSEGMENT) HASH_SEGMENT_PTR(hashp, i++); + MemSet(*segp, 0, HASH_SEGMENT_SIZE(hashp)); + } + else + { + *segp =3D seg_alloc(hashp); + i++; + } In the non-shared hash table case, previously, we used to return false from here when seg_alloc() fails, but now it seems to be proceeding without returning false. Is there a reason for the same? > I tested this by running make-check, make-check world and the reproducer = script shared > by David. I also ran pgbench to test creation and expansion of some of th= e > shared hash tables. > This covers the basic tests for this patch. I think we should do some low-level testing of both shared and non-shared hash tables by having a contrib module or such (we don't need to commit such a contrib module, but it will give us confidence that the low-level data structure allocation change is thoroughly tested). We also need to focus on negative tests where there is insufficient memory in the system. --=20 With Regards, Amit Kapila.