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 1v3B66-00CkUp-1c for pgsql-hackers@arkaria.postgresql.org; Mon, 29 Sep 2025 10:27:10 +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 1v3B64-000TOr-25 for pgsql-hackers@arkaria.postgresql.org; Mon, 29 Sep 2025 10:27:08 +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 1v3B63-000TOj-GI for pgsql-hackers@lists.postgresql.org; Mon, 29 Sep 2025 10:27:08 +0000 Received: from fout-b3-smtp.messagingengine.com ([202.12.124.146]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1v3B61-000hE5-1H for pgsql-hackers@lists.postgresql.org; Mon, 29 Sep 2025 10:27:07 +0000 Received: from phl-compute-10.internal (phl-compute-10.internal [10.202.2.50]) by mailfout.stl.internal (Postfix) with ESMTP id 451461D00077; Mon, 29 Sep 2025 06:27:02 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-10.internal (MEProxy); Mon, 29 Sep 2025 06:27:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=burd.me; h=cc:cc :content-transfer-encoding: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=1759141622; x=1759228022; bh=npivc7g/IImHBo7W6CBkdgEqCcjcSRHHcgkVSHJeve0=; b= ZSvUAaqY+pdd0T/cgqdfP7ufYjOwyW4HYle2eTYwzFoxeq9yirsceRXySi6dlsiz o6dzkqrSeFmFsClcGErOtP9vju2DM9K+if3n97P59tXnBwk9pT7/iDVURh1J8K+z YJ4NvYbn8XYRLEhkwKeCrE82xQd8JRk0H6jTaytBVCbMubqCMPoMJhx0IEBC1ABZ ATy8XDZKySnYt6lxkc3NNHIqUKySbqcwib4u65Dey1x8JDXspqyDwqWJ1iiYUJBh 6qPj4A6K1EtZdsLhVRzQcCy/vNymWGjnGrrXX5ez1YM8GVzyPtrVhoRz6CMY6lp5 1jDe6N/gJTrojSI3IXeOJw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :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=1759141622; x= 1759228022; bh=npivc7g/IImHBo7W6CBkdgEqCcjcSRHHcgkVSHJeve0=; b=P 6GN05Bn6agA1OL4XhC/iQdm4ViD0EuAvICzFaNdEXrkzbhGj+bCTUIzUdRTVpkeS g6aE8a1z2ystJAttOnX0e0YPQSdqoIcv725A/FJOgO1iersBllwtcffa9UGEaz/V ieVPm0cUdJP3p1WiiSdMHDBd0gz1EhRCfjleDz51tBxsC47ufoO4QEzLEGpLVXdT d9tuowD7FOybnrWXOccyfJdZNGml8+q9vEBjlrsRx6EnQ2hpoSNgsxWoFG33JJwo iTjQ2MD5K9eNI2nNQiGR6EWZgfh3hVB5A5+epXP2wSGZ+uPJYsrCLvRb0MTL3j5K wYNkG93U8zX+pNGU+k/fQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggdejjeejiecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjug hrpeffhffvvefkjghfuffogggtgfgusehtjehmtdertdejnecuhfhrohhmpefirhgvghcu uehurhguuceoghhrvghgsegsuhhrugdrmhgvqeenucggtffrrghtthgvrhhnpefhvdffhf eugeeutefhiefggfelvdeileevffevtdevueelvdegleeuvddtteeutdenucffohhmrghi nhepphhoshhtghhrvghsqhhlrdhorhhgnecuvehluhhsthgvrhfuihiivgeptdenucfrrg hrrghmpehmrghilhhfrhhomhepghhrvghgsegsuhhrugdrmhgvpdhnsggprhgtphhtthho pedvpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehmihgthhgrvghlsehprghquh hivghrrdighiiipdhrtghpthhtohepphhgshhqlhdqhhgrtghkvghrsheslhhishhtshdr phhoshhtghhrvghsqhhlrdhorhhg X-ME-Proxy: Feedback-ID: i675e48f3:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 29 Sep 2025 06:27:01 -0400 (EDT) Date: Mon, 29 Sep 2025 06:27:01 -0400 From: Greg Burd To: Michael Paquier Cc: PostgreSQL Hackers Message-ID: <791EFF06-DE5A-4E91-83E1-4C35550B55DA@getmailspring.com> In-Reply-To: References: Subject: Re: [PATCH] Add tests for Bitmapset X-Mailer: Mailspring MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Sep 29 2025, at 2:20 am, Michael Paquier wrote: > On Sat, Sep 27, 2025 at 10:03:14AM -0400, Greg Burd wrote: >> >> On Sep 24 2025, at 7:28 pm, Michael Paquier wrote: >> >> > 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 tree. >> > >> > By the way, Greg, do you think that we should aim for a state where we >> > are closer to completion? >> >> Hi Michael, >> >> We've come this far, why not go all the way? :) >> >> > 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. >> >> Agreed. >> >> > 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 >> >> Thanks for the detailed analysis, I tried to address each of these in >> the patch. >> >> > 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_bitmapset.c.gcov.html >> >> Agreed. >> >> > The coverage of the latter matters less than the coverage of the >> > former, of course. >> >> Agreed. >> test_bitmapset.c >> lines......: 98.9% >> functions..: 100% >> branches...: 82.6% >> >> 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. >> >> >> bitmapset.c >> lines......: 99.8% >> functions..: 100% >> branches...: 89.4% Hello Michael, > 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. Yes, redundant. Thanks for leaving them. > Added a comment for bms_del_members() for the two cases that trigger > word count changes. Thanks, I considered adding comments to cases that were more subtle but didn't find the time to review/add them. I appreciate that you added that. > The test changed with test_bms_difference() is indeed long, but not > that bad with 140-ish characters, so left it as-is. Thanks. > Good catch with bms_del_members() that was missing. There are so many > APIs that it's easy to miss one. Indeed, but it's covered now. > 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. Doh, I see what you mean. Thanks for the adaptation. >> 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 sets. >> >> test_bms_subset_compare('(b 1 64 65)', '(b 1 2 64)') -> BMS_DIFFERENT >> >> 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. Excellent, thanks. > 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 Yes, I think that does it. Thanks so much for the guidance and help taking this to its logical end. I greatly appreciate your guidance and time. > -- > Michael best. -greg