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 1v37FW-00Bkir-OL for pgsql-hackers@arkaria.postgresql.org; Mon, 29 Sep 2025 06:20:39 +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 1v37FU-00Gwib-P2 for pgsql-hackers@arkaria.postgresql.org; Mon, 29 Sep 2025 06:20:37 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1v37FT-00GwiT-Rb for pgsql-hackers@lists.postgresql.org; Mon, 29 Sep 2025 06:20:37 +0000 Received: from fout-a4-smtp.messagingengine.com ([103.168.172.147]) by makus.postgresql.org with smtp (Exim 4.96) (envelope-from ) id 1v37FR-000SSw-1U for pgsql-hackers@lists.postgresql.org; Mon, 29 Sep 2025 06:20:35 +0000 Received: from phl-compute-11.internal (phl-compute-11.internal [10.202.2.51]) by mailfout.phl.internal (Postfix) with ESMTP id EA2BAEC0101; Mon, 29 Sep 2025 02:20:32 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-11.internal (MEProxy); Mon, 29 Sep 2025 02:20:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1759126832; x=1759213232; bh=i3tbrt0o4o Y4+SaggwS9wIDtGgVbh9+W0jGtepj9a/0=; b=Mb812uIRLQWSywTwgM8+9l5/U4 7ZReJWIzQAqwyu3OMPk/dWhKbSB7GfEv36pFo4oqRRVQ6qPzqxDEFh8Aby063tbg jrW0Ilsla3pwczcP5zCE7R6/PX2qc67oqYyWW6+tFB1513VWQRe6CmEuTk8PBRFN sNOUksqyEdHNQvJLfS1MgNcK2rei+IJF3flAToCAviMe72ujVf1R3dzUwKVd8mof 43xaa05Qju2/CYRDYlUBZoGgTdMWQizLY3ZBL1qV40kYeLo+dTeqB7ejnBMarJNO 0CbTPul/1IMOdzWR2d4ux2gxQOI+5/y5ZvvAHdn/3WznOi7E8SQ85Ev3PriA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t= 1759126832; x=1759213232; bh=i3tbrt0o4oY4+SaggwS9wIDtGgVbh9+W0jG tepj9a/0=; b=QtU87qbzGik/PYkfB8LbzhDP5MNxsinkE9WTywbbovy7XNEBMRT lAeq2BxmjlGqORkn58Nz9Ra3XdAFWHm5BoV+L2UIT6mJgj3VFeIygVXFzyaLLhX9 Zc4gbSMWC5DF7FD31xzF4meI18eA5X7RpOPa3/fVZpwa7d9p4RaHt0QhSHzYS/d5 93Ny4SNqwOXArzSCAIICJgdV9J/S4O1S9OehfhbhYN+45o5/2g1uwqhtmqfxsgsO 1hFLQFZXzqVDJby/mQULdK9pLSVnTytnPJmFECJFpTQynKYgJ6jGVpxhettYRlI+ du2F9CWr3hESoy7DjHYM2KMu58dQqivB3Sg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggdejjedvjecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenfghrlh cuvffnffculdefhedmnecujfgurhepfffhvfevuffkfhggtggujgesghdtreertddtvden ucfhrhhomhepofhitghhrggvlhcurfgrqhhuihgvrhcuoehmihgthhgrvghlsehprghquh hivghrrdighiiiqeenucggtffrrghtthgvrhhnpeegffejvefgveduvdejtddvtdeijeeh udeuledvudeftdfgfeejvdekveekiedvvdenucffohhmrghinhepphhoshhtghhrvghsqh hlrdhorhhgnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhho mhepmhhitghhrggvlhesphgrqhhuihgvrhdrgiihiidpnhgspghrtghpthhtohepvddpmh houggvpehsmhhtphhouhhtpdhrtghpthhtohepghhrvghgsegsuhhrugdrmhgvpdhrtghp thhtohepphhgshhqlhdqhhgrtghkvghrsheslhhishhtshdrphhoshhtghhrvghsqhhlrd horhhg X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 29 Sep 2025 02:20:31 -0400 (EDT) Date: Mon, 29 Sep 2025 15:20:18 +0900 From: Michael Paquier To: Greg Burd Cc: PostgreSQL Hackers Subject: Re: [PATCH] Add tests for Bitmapset Message-ID: References: <837A4747-B56C-49FD-B6D0-1C40D79A5C47@greg.burd.me> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="Bz0Vg62wYCF9Tz9S" Content-Disposition: inline In-Reply-To: <837A4747-B56C-49FD-B6D0-1C40D79A5C47@greg.burd.me> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --Bz0Vg62wYCF9Tz9S Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, Sep 27, 2025 at 10:03:14AM -0400, Greg Burd wrote: >=20 > On Sep 24 2025, at 7:28 pm, Michael Paquier wrote: >=20 > > On Wed, Sep 24, 2025 at 07:39:59AM -0400, Greg Burd wrote: > >> Thanks Michael, Tom, for the help getting this into shape and in the t= ree. > >=20 > > By the way, Greg, do you think that we should aim for a state where we > > are closer to completion? >=20 > Hi Michael, >=20 > We've come this far, why not go all the way? :) >=20 > > We have the module up to the point where we > > are in pretty good shape, with most things and the infrastructure done > > but it can be improved a bit more, as well. >=20 > Agreed. >=20 > > Based on the information provided by the coverage report at > > https://coverage.postgresql.org/src/backend/nodes/bitmapset.c.gcov.html, > > we still have the following things: > > - bms_equal for different word counts > > - bms_union, bms_nonempty_difference, bms_is_subset and bms_intersect > > with shorter word counts. > > - bms_different with different word counts > > - A couple more cases with bms_subset_compare > > - bms_member_index and word counts > > - bms_overlap_list with negative number in input list. > > - bms_singleton_member ERROR with empty input. > > - bms_get_singleton_member with NULL input > > - bms_del_member with word counts > > - bms_replace_members and repalloc case > > - bms_add_range, bms_join and bms_del_members, more word count cases > > - bms_prev_member and the prevbit business >=20 > Thanks for the detailed analysis, I tried to address each of these in > the patch. >=20 > > There is not much we can do with the random function, still we could > > do something about the NULL paths in the internal functions: > > https://coverage.postgresql.org/src/test/modules/test_bitmapset/test_bi= tmapset.c.gcov.html >=20 > Agreed. >=20 > > The coverage of the latter matters less than the coverage of the > > former, of course. >=20 > Agreed. > test_bitmapset.c > lines......: 98.9% > functions..: 100% > branches...: 82.6% >=20 > Here I removed a bit of code I thought was unnecessary and added a few > test cases. The coverage is better overall, not much to say about it. >=20 >=20 > bitmapset.c > lines......: 99.8% > functions..: 100% > branches...: 89.4% No need for three tests for the word count case in bms_del_member(), only one is enough, but I've let them as they you have proposed, as you wanted to check more positioning with the members. These are cheap, that's fine. Added a comment for bms_del_members() for the two cases that trigger word count changes. The test changed with test_bms_difference() is indeed long, but not that bad with 140-ish characters, so left it as-is. Good catch with bms_del_members() that was missing. There are so many APIs that it's easy to miss one. The changes in test_bms_get_singleton_member() don't seem adapted, because we also want to test if the default value given by the function caller is changed, bms_get_singleton_member() returning a boolean status. The patch did not use arg1 at all. Also, if arg0 is NULL, let's return the input value. > A few branches were really tricky, my (least) favorite was the > bms_subset_compare(). To get to the first BMS_DIFFERENT return you have > to have a test case where the shorter bitmap is long enough to force two > or more iterations of the loop and in the first iteration the first word > in a needs to be a subset of b and then for the second word the opposite > where the second word of b is a subset of a and yet there can be no > overlapping bits in the two sets and the same number of words in both set= s. >=20 > test_bms_subset_compare('(b 1 64 65)', '(b 1 2 64)') -> BMS_DIFFERENT >=20 > Technically the '(b 64 200)', '(b 1 201)' test case is also > BMS_DIFFERENT and so redundant, but I was so happy to find the test case > for this branch I kept them both. I can see that you have expanded on these quite a bit, impressive. One thing that was confusing is that some of the tests already existed, so I've slightly reworded things to reduce the diffs. Per my measurements, we are at more than 99% in the module and bitmapset.c when only running make check in the module, which is nice -- Michael --Bz0Vg62wYCF9Tz9S Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmjaJSIACgkQnvQgOdby QH0XSg//YQdSNdKynT+KVHlJjnfbtwXbDrDPR5o3PYaAm/5/UV+CkDo/hNhLqDeX k+jqK9H+3u9gjFqNLLbBXs0CoI6NXdp90/L/76DOtbNEGQy8ITLrJ9XTwPAcRaLY 7LPch09PffgNjgG7xOTSE9qA4xJCgc+BuEcLHJre7BVVnE/udntQGQof/vsKH+KZ PJVFSCr2nWsKYQDoNC8kp+jQDtuS/DxopiBjUdNXGmGuvclMGj5SzXfHdc3dZWrE zk4ipJFA4kZm8d15TTndXymKvajEADA7GFk8lHoh1Q4+hGvfrN0nvLjKG/InIUtv fD5THG1gjqTSxnES1lN1bYuttBqh8+n3TRxNYMGWWXUvaE3g1ax+7gkf60c10SWU aF6EBji7dVkzelFXOTDg7VK2ERRm7iG7gbbdiDTlT7YLhuyC9azo8lzZRlxqhLbr qByx3Dpr3JufDMTEyPx+b2uu0PJmO1io+HK+rb2p05NivqXFSdg/e1c7jltufx8q 52+EiwvRodYVRXQQbLsqNs9nJw+WnGmZGglTwKjlpklPN0yn1kzFt5lG42EPXyVf i8RmqivYHs7bJdSVzSGWTm02la+ueW6uI9LyHU/pZLGMCStTBgsyexMYteyZCxi5 yStFTnP4n3qulGdN3Lug0gWP34Wec+liMP6rrCBgoZaF/ICtjzg= =rdPT -----END PGP SIGNATURE----- --Bz0Vg62wYCF9Tz9S--