Re: Making empty Bitmapsets always be NULL
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: David Rowley <dgrowleyml@gmail.com>
Cc: pgsql-hackers@lists.postgresql.org
Date: 2023-03-03T22:08:32Z
Lists: pgsql-hackers
Attachments
- v1-make-struct-Bitmapset-private.patch (text/x-diff) patch v1
David Rowley <dgrowleyml@gmail.com> writes: > On Fri, 3 Mar 2023 at 15:17, Tom Lane <tgl@sss.pgh.pa.us> wrote: >> Another point here is that I'm pretty sure that just about all >> bitmapsets we deal with are only one or two words, so I'm not >> convinced you're going to get any performance win to justify >> the added management overhead. > It's true that the majority of Bitmapsets are going to be just 1 word, > but it's important to acknowledge that we do suffer in some more > extreme cases when Bitmapsets become large. Partition with large > numbers of partitions is one such case. Maybe, but optimizing for that while pessimizing every other case doesn't sound very attractive from here. I think we need some benchmarks on normal-size bitmapsets before considering doing much in this area. Also, if we're going to make any sort of changes here it'd probably behoove us to make struct Bitmapset private in bitmapset.c, so that we can have confidence that nobody is playing games with them. I had a go at that and was pleasantly surprised to find that actually nobody has; the attached passes check-world. It'd probably be smart to commit this as a follow-on to 00b41463c, whether or not we go any further. Also, given that we do this, I don't think that check_bitmapset_invariants as you propose it is worth the trouble. The reason we've gone to such lengths with checking List invariants is that initially we had a large number of places doing creative and not-too-structured things with Lists, plus we've made several absolutely fundamental changes to that data structure. Despite the far larger bug surface, I don't recall that those invariant checks ever found anything after the initial rounds of changes. So I don't buy that there's an argument for a similarly expensive set of checks here. bitmapset.c is small enough that we should be able to pretty much prove it correct by eyeball. regards, tom lane
Commits
-
Remove trailing zero words from Bitmapsets
- a8c09daa8bb1 17.0 landed
-
Remove local optimizations of empty Bitmapsets into null pointers.
- 6b661b01f48b 16.0 landed
-
Require empty Bitmapsets to be represented as NULL.
- 00b41463c216 16.0 landed
-
Mop up some undue familiarity with the innards of Bitmapsets.
- 141225b2518f 16.0 landed
-
Remove bms_first_member().
- 462bb7f12851 16.0 landed