Thread
-
Re: [Proposal] Expose internal MultiXact member count function for efficient monitoring
Michael Paquier <michael@paquier.xyz> — 2025-12-25T01:30:37Z
On Thu, Dec 25, 2025 at 09:45:33AM +0900, Michael Paquier wrote: > Seems basically sensible here for the structure, including the hints > and recommendations for the GUCs. +/* Calculate storage space in bytes for a given number of members */ +static inline int64 +MultiXactMemberStorageSize(MultiXactOffset members) +{ + return (int64) (members / MULTIXACT_MEMBERS_PER_MEMBERGROUP) * + MULTIXACT_MEMBERGROUP_SIZE; +} By the way, this bit also feels a bit confusing, and this comes down to the fact that "members" is not an offset, isn't it? This relates to MultiXactMemberFreezeThreshold(), that considers the number of members as an offset, but it is a number of members, a difference between two offsets. I am wondering if it would not be cleaner and less confusing to do things slightly differently (sorry I did not pay much attention to that previously): - Change GetMultiXactInfo() to return two offsets, nextOffset and oldestOffset. - Use uint64 for members and recalculate the difference in MultiXactMemberFreezeThreshold() and the function code. Heikki has just switched multixact offsets to be 64 bits, yippee. - Redefine MultiXactMemberStorageSize() so as it does not take a number of members in input, but as the amount of space taken between two offsets. At least that would be more consistent with all the other inline functions of multixact.h that rely on MultiXactOffset inputs. Using a int64 is still OK I guess, there may be a case to detect "negative" numbers and give a change to the users of the new inline function to notice that they did a computation wrong, rather than hiding a signedness problem. -- Michael