LCOV - differential code coverage report
Current view: top level - src/include/utils - wait_event.h (source / functions) Coverage Total Hit CBC
Current: c70b6db34ffeab48beef1fb4ce61bcad3772b8dd vs 06473f5a344df8c9594ead90a609b86f6724cff8 Lines: 100.0 % 6 6 6
Current Date: 2025-09-06 07:49:51 +0900 Functions: 100.0 % 2 2 2
Baseline: lcov-20250906-005545-baseline Line coverage date bins:
Baseline Date: 2025-09-05 08:21:35 +0100 (360..) days: 100.0 % 6 6 6
Legend: Lines:     hit not hit Function coverage date bins:
(360..) days: 100.0 % 2 2 2

 Age         Owner                  TLA  Line data    Source code
                                  1                 : /*-------------------------------------------------------------------------
                                  2                 :  * wait_event.h
                                  3                 :  *    Definitions related to wait event reporting
                                  4                 :  *
                                  5                 :  * Copyright (c) 2001-2025, PostgreSQL Global Development Group
                                  6                 :  *
                                  7                 :  * src/include/utils/wait_event.h
                                  8                 :  * ----------
                                  9                 :  */
                                 10                 : #ifndef WAIT_EVENT_H
                                 11                 : #define WAIT_EVENT_H
                                 12                 : 
                                 13                 : /* enums for wait events */
                                 14                 : #include "utils/wait_event_types.h"
                                 15                 : 
                                 16                 : extern const char *pgstat_get_wait_event(uint32 wait_event_info);
                                 17                 : extern const char *pgstat_get_wait_event_type(uint32 wait_event_info);
                                 18                 : static inline void pgstat_report_wait_start(uint32 wait_event_info);
                                 19                 : static inline void pgstat_report_wait_end(void);
                                 20                 : extern void pgstat_set_wait_event_storage(uint32 *wait_event_info);
                                 21                 : extern void pgstat_reset_wait_event_storage(void);
                                 22                 : 
                                 23                 : extern PGDLLIMPORT uint32 *my_wait_event_info;
                                 24                 : 
                                 25                 : 
                                 26                 : /*
                                 27                 :  * Wait Events - Extension, InjectionPoint
                                 28                 :  *
                                 29                 :  * Use InjectionPoint when the server process is waiting in an injection
                                 30                 :  * point.  Use Extension for other cases of the server process waiting for
                                 31                 :  * some condition defined by an extension module.
                                 32                 :  *
                                 33                 :  * Extensions can define their own wait events in these categories.  They
                                 34                 :  * should call one of these functions with a wait event string.  If the wait
                                 35                 :  * event associated to a string is already allocated, it returns the wait
                                 36                 :  * event information to use.  If not, it gets one wait event ID allocated from
                                 37                 :  * a shared counter, associates the string to the ID in the shared dynamic
                                 38                 :  * hash and returns the wait event information.
                                 39                 :  *
                                 40                 :  * The ID retrieved can be used with pgstat_report_wait_start() or equivalent.
                                 41                 :  */
                                 42                 : extern uint32 WaitEventExtensionNew(const char *wait_event_name);
                                 43                 : extern uint32 WaitEventInjectionPointNew(const char *wait_event_name);
                                 44                 : 
                                 45                 : extern void WaitEventCustomShmemInit(void);
                                 46                 : extern Size WaitEventCustomShmemSize(void);
                                 47                 : extern char **GetWaitEventCustomNames(uint32 classId, int *nwaitevents);
                                 48                 : 
                                 49                 : /* ----------
                                 50                 :  * pgstat_report_wait_start() -
                                 51                 :  *
                                 52                 :  *  Called from places where server process needs to wait.  This is called
                                 53                 :  *  to report wait event information.  The wait information is stored
                                 54                 :  *  as 4-bytes where first byte represents the wait event class (type of
                                 55                 :  *  wait, for different types of wait, refer WaitClass) and the next
                                 56                 :  *  3-bytes represent the actual wait event.  Currently 2-bytes are used
                                 57                 :  *  for wait event which is sufficient for current usage, 1-byte is
                                 58                 :  *  reserved for future usage.
                                 59                 :  *
                                 60                 :  *  Historically we used to make this reporting conditional on
                                 61                 :  *  pgstat_track_activities, but the check for that seems to add more cost
                                 62                 :  *  than it saves.
                                 63                 :  *
                                 64                 :  *  my_wait_event_info initially points to local memory, making it safe to
                                 65                 :  *  call this before MyProc has been initialized.
                                 66                 :  * ----------
                                 67                 :  */
                                 68                 : static inline void
 1618 andres@anarazel.de         69 CBC     9332338 : pgstat_report_wait_start(uint32 wait_event_info)
                                 70                 : {
                                 71                 :     /*
                                 72                 :      * Since this is a four-byte field which is always read and written as
                                 73                 :      * four-bytes, updates are atomic.
                                 74                 :      */
 1617                            75         9332338 :     *(volatile uint32 *) my_wait_event_info = wait_event_info;
 1618                            76         9332338 : }
                                 77                 : 
                                 78                 : /* ----------
                                 79                 :  * pgstat_report_wait_end() -
                                 80                 :  *
                                 81                 :  *  Called to report end of a wait.
                                 82                 :  * ----------
                                 83                 :  */
                                 84                 : static inline void
                                 85         9365846 : pgstat_report_wait_end(void)
                                 86                 : {
                                 87                 :     /* see pgstat_report_wait_start() */
 1617                            88         9365846 :     *(volatile uint32 *) my_wait_event_info = 0;
 1618                            89         9365846 : }
                                 90                 : 
                                 91                 : 
                                 92                 : #endif                          /* WAIT_EVENT_H */
        

Generated by: LCOV version 2.4-beta