Re: Adding wait events statistics
От | Michael Paquier |
---|---|
Тема | Re: Adding wait events statistics |
Дата | |
Msg-id | aG2-KtUK7-Ocz8Gd@paquier.xyz обсуждение исходный текст |
Ответ на | Re: Adding wait events statistics (Bertrand Drouvot <bertranddrouvot.pg@gmail.com>) |
Ответы |
Re: Adding wait events statistics
|
Список | pgsql-hackers |
On Tue, Jul 08, 2025 at 03:25:26PM +0000, Bertrand Drouvot wrote: > So, something like: > > ClassInfo LWLockClassInfo = { > .numberOfEvents = NB_LWLOCK_WAIT_EVENTS, > .pendingCounts = PendingWaitEventStats.lwlock_counts > }; > > and then the "global" one: > > WaitClassInfo *AllWaitClasses[] = { > NULL, /* gap - no class with ID 0 */ > &LWLockClassInfo, > NULL, /* gap - no class with ID 2 */ > &LockClassInfo, > &BufferPinClassInfo, > &ActivityClassInfo, > &ClientClassInfo, > &ExtensionClassInfo, > &IPCClassInfo, > &TimeoutClassInfo, > &IOClassInfo, > }; Okay. I'm guessing that all this information is automatically built based on the contents of wait_event_names.txt (with some tweaks for the LWLock part?), so why not even if there are gaps as long as we know the length of AllWaitClasses. The stats code would be simple by doing an O(n^2) across the array when flushing the individual contents of each wait event. > That way: > > - we do not need a mapping between ClassID and "Arrays" and the gaps > in the ClassID are handled. So we can acces directly the class of interest > knowing its classID. > - we can easily iterate (again no mapping needed) over all the pending stats > thanks to AllWaitClasses[] > > What do you think? It looks like the most elegant approach to me. I think that's pretty cool. > Bonus point, as you can see above, while working on this approach I've been able > to remove storing the className and the array of eventName per wait class (would > have worked in v1 too). You mean the extra set of names generated? Yes, I was getting the impression while reading your patch that this did not require this complexity when generating the code for the pending data. Getting rid of this part would be a nice outcome. -- Michael
Вложения
В списке pgsql-hackers по дате отправления: