CUBRID Engine  latest
perf_monitor.h
Go to the documentation of this file.
1 /*
2  * Copyright 2008 Search Solution Corporation
3  * Copyright 2016 CUBRID Corporation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 
20 /*
21  * perf_monitor.h - Monitor execution statistics at Client
22  */
23 
24 #ifndef _PERF_MONITOR_H_
25 #define _PERF_MONITOR_H_
26 
27 #ident "$Id$"
28 
29 #if defined (SERVER_MODE)
30 #include "connection_defs.h"
31 #include "dbtype_def.h"
32 #endif /* SERVER_MODE */
33 #if defined (SERVER_MODE) || defined (SA_MODE)
34 #include "log_impl.h"
35 #endif // SERVER_MODE or SA_MODE
36 #include "memory_alloc.h"
37 #include "porting_inline.hpp"
38 #include "storage_common.h"
39 #include "thread_compat.hpp"
40 #include "tsc_timer.h"
41 
42 #include <assert.h>
43 #include <stdio.h>
44 #if !defined(WINDOWS)
45 #include <sys/time.h>
46 #endif /* WINDOWS */
47 #include <time.h>
48 
49 /* EXPORTED GLOBAL DEFINITIONS */
50 #define MAX_DIAG_DATA_VALUE 0xfffffffffffffLL
51 
52 #define MAX_SERVER_THREAD_COUNT 500
53 #define MAX_SERVER_NAMELENGTH 256
54 #define SH_MODE 0644
55 
56 /* Statistics activation flags */
57 typedef enum
58 {
68 
69  /* must update when adding new conditions */
71 
74 
75 /* PERF_MODULE_TYPE x PERF_PAGE_TYPE x PAGE_FETCH_MODE x HOLDER_LATCH_MODE x COND_FIX_TYPE */
76 #define PERF_PAGE_FIX_COUNTERS \
77  ((PERF_MODULE_CNT) * (PERF_PAGE_CNT) * (PERF_PAGE_MODE_CNT) * (PERF_HOLDER_LATCH_CNT) * (PERF_CONDITIONAL_FIX_CNT))
78 
79 #define PERF_PAGE_PROMOTE_COUNTERS \
80  ((PERF_MODULE_CNT) * (PERF_PAGE_CNT) * (PERF_PROMOTE_CONDITION_CNT) * (PERF_HOLDER_LATCH_CNT) * (2 /* success */))
81 
82 /* PERF_MODULE_TYPE x PAGE_TYPE x DIRTY_OR_CLEAN x DIRTY_OR_CLEAN x READ_OR_WRITE_OR_MIX */
83 #define PERF_PAGE_UNFIX_COUNTERS \
84  ((PERF_MODULE_CNT) * (PERF_PAGE_CNT) * 2 * 2 * (PERF_HOLDER_LATCH_CNT))
85 
86 #define PERF_PAGE_LOCK_TIME_COUNTERS PERF_PAGE_FIX_COUNTERS
87 
88 #define PERF_PAGE_HOLD_TIME_COUNTERS \
89  ((PERF_MODULE_CNT) * (PERF_PAGE_CNT) * (PERF_PAGE_MODE_CNT) * (PERF_HOLDER_LATCH_CNT))
90 
91 #define PERF_PAGE_FIX_TIME_COUNTERS PERF_PAGE_FIX_COUNTERS
92 
93 #define PERF_PAGE_FIX_STAT_OFFSET(module,page_type,page_found_mode,latch_mode,cond_type) \
94  ((module) * (PERF_PAGE_CNT) * (PERF_PAGE_MODE_CNT) * (PERF_HOLDER_LATCH_CNT) * (PERF_CONDITIONAL_FIX_CNT) \
95  + (page_type) * (PERF_PAGE_MODE_CNT) * (PERF_HOLDER_LATCH_CNT) * (PERF_CONDITIONAL_FIX_CNT) \
96  + (page_found_mode) * (PERF_HOLDER_LATCH_CNT) * (PERF_CONDITIONAL_FIX_CNT) \
97  + (latch_mode) * (PERF_CONDITIONAL_FIX_CNT) + (cond_type))
98 
99 #define PERF_PAGE_PROMOTE_STAT_OFFSET(module,page_type,promote_cond,holder_latch,success) \
100  ((module) * (PERF_PAGE_CNT) * (PERF_PROMOTE_CONDITION_CNT) * (PERF_HOLDER_LATCH_CNT) * 2 /* success */ \
101  + (page_type) * (PERF_PROMOTE_CONDITION_CNT) * (PERF_HOLDER_LATCH_CNT) * 2 /* success */ \
102  + (promote_cond) * (PERF_HOLDER_LATCH_CNT) * 2 /* success */ \
103  + (holder_latch) * 2 /* success */ \
104  + success)
105 
106 #define PERF_PAGE_UNFIX_STAT_OFFSET(module,page_type,buf_dirty,dirtied_by_holder,holder_latch) \
107  ((module) * (PERF_PAGE_CNT) * 2 * 2 * (PERF_HOLDER_LATCH_CNT) \
108  + (page_type) * 2 * 2 * (PERF_HOLDER_LATCH_CNT) \
109  + (buf_dirty) * 2 * (PERF_HOLDER_LATCH_CNT) \
110  + (dirtied_by_holder) * (PERF_HOLDER_LATCH_CNT) \
111  + (holder_latch))
112 
113 #define PERF_PAGE_LOCK_TIME_OFFSET(module,page_type,page_found_mode,latch_mode,cond_type) \
114  PERF_PAGE_FIX_STAT_OFFSET (module, page_type, page_found_mode, latch_mode, cond_type)
115 
116 #define PERF_PAGE_HOLD_TIME_OFFSET(module,page_type,page_found_mode,latch_mode)\
117  ((module) * (PERF_PAGE_CNT) * (PERF_PAGE_MODE_CNT) * (PERF_HOLDER_LATCH_CNT) \
118  + (page_type) * (PERF_PAGE_MODE_CNT) * (PERF_HOLDER_LATCH_CNT) \
119  + (page_found_mode) * (PERF_HOLDER_LATCH_CNT) \
120  + (latch_mode))
121 
122 #define PERF_PAGE_FIX_TIME_OFFSET(module,page_type,page_found_mode,latch_mode,cond_type) \
123  PERF_PAGE_FIX_STAT_OFFSET (module, page_type, page_found_mode, latch_mode, cond_type)
124 
125 #define PERF_MVCC_SNAPSHOT_COUNTERS \
126  (PERF_SNAPSHOT_CNT * PERF_SNAPSHOT_RECORD_TYPE_CNT * PERF_SNAPSHOT_VISIBILITY_CNT)
127 
128 #define PERF_MVCC_SNAPSHOT_OFFSET(snapshot,rec_type,visibility) \
129  ((snapshot) * PERF_SNAPSHOT_RECORD_TYPE_CNT * PERF_SNAPSHOT_VISIBILITY_CNT \
130  + (rec_type) * PERF_SNAPSHOT_VISIBILITY_CNT + (visibility))
131 
132 #define PERF_OBJ_LOCK_STAT_COUNTERS (SCH_M_LOCK + 1)
133 #define PERF_DWB_FLUSHED_BLOCK_VOLUMES_CNT 10
134 
135 #define SAFE_DIV(a, b) ((b) == 0 ? 0 : (a) / (b))
136 
137 /* Count & timer values. */
138 #define PSTAT_COUNTER_TIMER_COUNT_VALUE(startvalp) (startvalp)
139 #define PSTAT_COUNTER_TIMER_TOTAL_TIME_VALUE(startvalp) ((startvalp) + 1)
140 #define PSTAT_COUNTER_TIMER_MAX_TIME_VALUE(startvalp) ((startvalp) + 2)
141 #define PSTAT_COUNTER_TIMER_AVG_TIME_VALUE(startvalp) ((startvalp) + 3)
142 
143 #if !defined(SERVER_MODE)
144 #if !defined(LOG_TRAN_INDEX)
145 #define LOG_TRAN_INDEX
146 extern int log_Tran_index; /* Index onto transaction table for current thread of execution (client) */
147 #endif /* !LOG_TRAN_INDEX */
148 #endif /* !SERVER_MODE */
149 
150 #if defined (SERVER_MODE)
151 // todo - remove from here
152 #if !defined(LOG_FIND_THREAD_TRAN_INDEX)
153 #define LOG_FIND_THREAD_TRAN_INDEX(thrd) \
154  ((thrd) ? (thrd)->tran_index : logtb_get_current_tran_index())
155 #endif
156 #else
157 #if !defined(LOG_FIND_THREAD_TRAN_INDEX)
158 #define LOG_FIND_THREAD_TRAN_INDEX(thrd) (log_Tran_index)
159 #endif
160 #endif
161 
162 typedef enum
163 {
167 
170 
171 typedef enum
172 {
176 
179 
180 typedef enum
181 {
185 
188 
189 typedef enum
190 {
193 
196 
197 typedef enum
198 {
204 
207 
208 /* extension of PAGE_TYPE (storage_common.h) - keep value compatibility */
209 typedef enum
210 {
211  PERF_PAGE_UNKNOWN = 0, /* used for initialized page */
212  PERF_PAGE_FTAB, /* file allocset table page */
213  PERF_PAGE_HEAP, /* heap page */
214  PERF_PAGE_VOLHEADER, /* volume header page */
215  PERF_PAGE_VOLBITMAP, /* volume bitmap page */
216  PERF_PAGE_QRESULT, /* query result page */
217  PERF_PAGE_EHASH, /* ehash bucket/dir page */
218  PERF_PAGE_OVERFLOW, /* overflow page (with ovf_keyval) */
219  PERF_PAGE_AREA, /* area page */
220  PERF_PAGE_CATALOG, /* catalog page */
221  PERF_PAGE_BTREE_GENERIC, /* b+tree index (uninitialized) */
222  PERF_PAGE_LOG, /* NONE - log page (unused) */
223  PERF_PAGE_DROPPED_FILES, /* Dropped files page. */
224  PERF_PAGE_VACUUM_DATA, /* Vacuum data */
225  PERF_PAGE_BTREE_ROOT, /* b+tree root index page */
226  PERF_PAGE_BTREE_OVF, /* b+tree overflow index page */
227  PERF_PAGE_BTREE_LEAF, /* b+tree leaf index page */
228  PERF_PAGE_BTREE_NONLEAF, /* b+tree nonleaf index page */
231 
232 typedef enum
233 {
238 
241 
242 typedef enum
243 {
244  PERF_SNAPSHOT_RECORD_INSERTED_VACUUMED = 0, /* already vacuumed */
245  PERF_SNAPSHOT_RECORD_INSERTED_CURR_TRAN, /* needs commit and vacuum */
246  PERF_SNAPSHOT_RECORD_INSERTED_OTHER_TRAN, /* needs commit and vacuum */
247  PERF_SNAPSHOT_RECORD_INSERTED_COMMITED, /* commited, needs vacuum */
248  PERF_SNAPSHOT_RECORD_INSERTED_COMMITED_LOST, /* commited, unvacuumed/lost */
249 
250  PERF_SNAPSHOT_RECORD_INSERTED_DELETED, /* inserted, than deleted */
251 
252  PERF_SNAPSHOT_RECORD_DELETED_CURR_TRAN, /* deleted by current tran */
253  PERF_SNAPSHOT_RECORD_DELETED_OTHER_TRAN, /* deleted by other active tran */
254  PERF_SNAPSHOT_RECORD_DELETED_COMMITTED, /* deleted, and committed */
255  PERF_SNAPSHOT_RECORD_DELETED_COMMITTED_LOST, /* deleted, and committed, unvacuumed/lost */
256 
259 
260 typedef enum
261 {
264 
267 
268 typedef enum
269 {
270  PSTAT_BASE = -1, /* not a real entry. just to avoid compile warnings */
271 
272  /* Execution statistics for the file io */
281 
282  /* Page buffer basic module */
283  /* Execution statistics for the page buffer manager */
289  /* peeked stats */
298 
299  /* Execution statistics for the log manager */
310 
311  /* Execution statistics for the lock manager */
320  PSTAT_LK_NUM_WAITED_TIME_ON_OBJECTS, /* include this to avoid client-server compat issue even if extended stats are
321  * disabled */
322 
323  /* Execution statistics for transactions */
334 
335  /* Execution statistics for the btree manager */
346 
351 
356 
357  /* Execution statistics for the query manager */
371 
372  /* Execution statistics for external sort */
375 
376  /* Execution statistics for network communication */
378 
379  /* flush control stat */
383 
384  /* prior lsa info */
388 
389  /* HA replication delay */
391 
392  /* Execution statistics for Plan cache */
401 
406 
407  /* Track heap modify counters. */
435 
436  /* Track heap modify timers. */
449 
450  /* Execution statistics for the heap manager */
451  /* best space info */
460 
461  /* B-tree ops detailed statistics. */
489 
490  /* Vacuum master/worker timers. */
495 
496  /* Log statistics */
502 
503  /* Computed statistics */
504  /* ((pb_num_fetches - pb_num_ioreads) x 100 / pb_num_fetches) x 100 */
506  /* ((log_num_fetches - log_num_ioreads) x 100 / log_num_fetches) x 100 */
508  /* ((fetches of vacuum - fetches of vacuum not found in PB) x 100 / fetches of vacuum) x 100 */
510  /* (100 x Number of unfix with of dirty pages of vacuum / total num of unfixes from vacuum) x 100 */
512  /* (100 x Number of unfix from vacuum / total num of unfix) x 100 */
514  /* total time to acquire page lock (stored as 10 usec unit, displayed as miliseconds) */
516  /* total time to acquire page hold (stored as 10 usec unit, displayed as miliseconds) */
518  /* total time to acquire page fix (stored as 10 usec unit, displayed as miliseconds) */
520  /* ratio of time required to allocate a buffer for a page : (100 x (fix_time - lock_time - hold_time) / fix_time) x
521  * 100 */
523  /* total successful promotions */
525  /* total failed promotions */
527  /* total promotion time */
529 
530  /* Page buffer extended */
531  /* detailed unfix module */
546  /* vacuum */
551  /* aout */
556  /* hash anchor */
559  /* flushing */
574  /* allocate and victim assignments */
581  /* direct assignments */
592  /* successful searches */
596  /* failed searches */
601  /* search lru's */
606  /* lock-free circular queues with lru lists having victims */
612 
613  /* DWB statistics */
622 
623  /* LOG LZ4 compress statistics */
626 
627  /* peeked stats */
636 
637  /* Complex statistics */
651 
653 } PERF_STAT_ID;
654 
655 /* All globals on statistics will be here. */
656 typedef struct pstat_global PSTAT_GLOBAL;
658 {
660 
661  UINT64 *global_stats;
662 
663  int n_trans;
664  UINT64 **tran_stats;
665 
666  bool *is_watching;
667 #if !defined (HAVE_ATOMIC_BUILTINS)
668  pthread_mutex_t watch_lock;
669 #endif /* !HAVE_ATOMIC_BUILTINS */
670 
671  INT32 n_watchers;
672 
675 };
676 
678 
679 typedef enum
680 {
681  PSTAT_ACCUMULATE_SINGLE_VALUE, /* A single accumulator value. */
682  PSTAT_PEEK_SINGLE_VALUE, /* A single value peeked from database. */
683  /* TODO: Currently this type of statistics is set by active workers. I think in
684  * most cases we could peek it at "compute". There can be two approaches:
685  * if f_compute is provided, it is read at compute phase. If not, the
686  * existing value is used and it must be set by active workers.
687  */
688  PSTAT_COUNTER_TIMER_VALUE, /* A counter/timer. Counter is incremented, timer is accumulated, max time
689  * is compared with all registered timers and average time is computed.
690  */
691  PSTAT_COMPUTED_RATIO_VALUE, /* Value is computed based on other values in statistics. A ratio is obtained
692  * at the end.
693  */
694  PSTAT_COMPLEX_VALUE /* A "complex" value. The creator must handle loading, adding, dumping and
695  * computing values.
696  */
698 
699 /* PSTAT_METADATA
700  * This structure will keep meta-data information on each statistic we are monitoring.
701  */
703 
704 typedef void (*PSTAT_DUMP_IN_FILE_FUNC) (FILE *, const UINT64 * stat_vals);
705 typedef void (*PSTAT_DUMP_IN_BUFFER_FUNC) (char **, const UINT64 * stat_vals, int *remaining_size);
706 typedef int (*PSTAT_LOAD_FUNC) (void);
707 
709 {
710  /* These members must be set. */
712  const char *stat_name;
714 
715  /* These members are computed at startup. */
717  int n_vals;
718 
722 };
723 
725 
728 {
731  int server_long_query_time; /* min 1 sec */
732 };
733 
736 {
749 };
750 
753 {
758 };
759 
760 /* Monitor config related structure */
761 
764 {
765  char head;
766  char body[2];
767 };
768 
771 {
772  char head[2];
773  char body[8];
774 };
775 
778 {
781 };
782 
783 /* Shared memory data struct */
784 
787 {
788  int magic;
791  char servername[MAX_SERVER_NAMELENGTH];
793 };
794 
796 {
799 };
801 
803 {
804  DIAG_SERVER_DB = 00000,
808 };
810 
811 extern void perfmon_server_dump_stats (const UINT64 * stats, FILE * stream, const char *substr);
812 
813 extern void perfmon_server_dump_stats_to_buffer (const UINT64 * stats, char *buffer, int buf_size, const char *substr);
814 
815 extern void perfmon_get_current_times (time_t * cpu_usr_time, time_t * cpu_sys_time, time_t * elapsed_time);
816 
817 extern int perfmon_calc_diff_stats (UINT64 * stats_diff, UINT64 * new_stats, UINT64 * old_stats);
818 extern int perfmon_initialize (int num_trans);
819 extern void perfmon_finalize (void);
821 extern UINT64 *perfmon_allocate_values (void);
822 extern char *perfmon_allocate_packed_values_buffer (void);
823 extern void perfmon_copy_values (UINT64 * src, UINT64 * dest);
824 
825 #if defined (SERVER_MODE) || defined (SA_MODE)
826 extern void perfmon_start_watch (THREAD_ENTRY * thread_p);
827 extern void perfmon_stop_watch (THREAD_ENTRY * thread_p);
828 extern void perfmon_er_log_current_stats (THREAD_ENTRY * thread_p);
829 #endif /* SERVER_MODE || SA_MODE */
830 
833 STATIC_INLINE bool perfmon_is_perf_tracking_force (bool always_collect) __attribute__ ((ALWAYS_INLINE));
834 STATIC_INLINE void perfmon_add_stat (THREAD_ENTRY * thread_p, PERF_STAT_ID psid, UINT64 amount)
835  __attribute__ ((ALWAYS_INLINE));
836 STATIC_INLINE void perfmon_add_stat_to_global (PERF_STAT_ID psid, UINT64 amount) __attribute__ ((ALWAYS_INLINE));
837 STATIC_INLINE void perfmon_add_at_offset (THREAD_ENTRY * thread_p, int offset, UINT64 amount)
838  __attribute__ ((ALWAYS_INLINE));
839 STATIC_INLINE void perfmon_inc_stat (THREAD_ENTRY * thread_p, PERF_STAT_ID psid) __attribute__ ((ALWAYS_INLINE));
841 STATIC_INLINE void perfmon_set_stat (THREAD_ENTRY * thread_p, PERF_STAT_ID psid, int statval, bool check_watchers)
842  __attribute__ ((ALWAYS_INLINE));
843 STATIC_INLINE void perfmon_set_at_offset (THREAD_ENTRY * thread_p, int offset, int statval, bool check_watchers)
844  __attribute__ ((ALWAYS_INLINE));
845 STATIC_INLINE void perfmon_add_at_offset_to_global (int offset, UINT64 amount) __attribute__ ((ALWAYS_INLINE));
846 STATIC_INLINE void perfmon_set_stat_to_global (PERF_STAT_ID psid, int statval) __attribute__ ((ALWAYS_INLINE));
847 STATIC_INLINE void perfmon_set_at_offset_to_global (int offset, int statval) __attribute__ ((ALWAYS_INLINE));
848 STATIC_INLINE void perfmon_time_at_offset (THREAD_ENTRY * thread_p, int offset, UINT64 timediff)
849  __attribute__ ((ALWAYS_INLINE));
850 STATIC_INLINE void perfmon_time_bulk_at_offset (THREAD_ENTRY * thread_p, int offset, UINT64 timediff, UINT64 count)
851  __attribute__ ((ALWAYS_INLINE));
852 STATIC_INLINE void perfmon_time_stat (THREAD_ENTRY * thread_p, PERF_STAT_ID psid, UINT64 timediff)
853  __attribute__ ((ALWAYS_INLINE));
854 STATIC_INLINE int perfmon_get_activation_flag (void) __attribute__ ((ALWAYS_INLINE));
855 extern char *perfmon_pack_stats (char *buf, UINT64 * stats);
856 extern char *perfmon_unpack_stats (char *buf, UINT64 * stats);
857 
858 STATIC_INLINE void perfmon_diff_timeval (struct timeval *elapsed, struct timeval *start, struct timeval *end)
859  __attribute__ ((ALWAYS_INLINE));
860 STATIC_INLINE void perfmon_add_timeval (struct timeval *total, struct timeval *start, struct timeval *end)
861  __attribute__ ((ALWAYS_INLINE));
862 
863 #ifdef __cplusplus
864 /* TODO: it looks ugly now, but it should be fixed with stat tool patch */
865 
866 /*
867  * Add/set stats section.
868  */
869 
870 /*
871  * perfmon_add_stat () - Accumulate amount to statistic.
872  *
873  * return : Void.
874  * thread_p (in) : Thread entry.
875  * psid (in) : Statistic ID.
876  * amount (in) : Amount to add.
877  */
878 STATIC_INLINE void
879 perfmon_add_stat (THREAD_ENTRY * thread_p, PERF_STAT_ID psid, UINT64 amount)
880 {
881  assert (PSTAT_BASE < psid && psid < PSTAT_COUNT);
882 
883  if (!perfmon_is_perf_tracking ())
884  {
885  /* No need to collect statistics since no one is interested. */
886  return;
887  }
888 
889  assert (pstat_Metadata[psid].valtype == PSTAT_ACCUMULATE_SINGLE_VALUE);
890 
891  /* Update statistics. */
892  perfmon_add_at_offset (thread_p, pstat_Metadata[psid].start_offset, amount);
893 }
894 
895 /*
896  * perfmon_add_stat_to_global () - Accumulate amount only to global statistic.
897  *
898  * return : Void.
899  * psid (in) : Statistic ID.
900  * amount (in) : Amount to add.
901  */
902 STATIC_INLINE void
903 perfmon_add_stat_to_global (PERF_STAT_ID psid, UINT64 amount)
904 {
905  assert (PSTAT_BASE < psid && psid < PSTAT_COUNT);
906 
907  if (!pstat_Global.initialized)
908  {
909  return;
910  }
911 
912  assert (pstat_Metadata[psid].valtype == PSTAT_ACCUMULATE_SINGLE_VALUE);
913 
914  /* Update statistics. */
915  perfmon_add_at_offset_to_global (pstat_Metadata[psid].start_offset, amount);
916 }
917 
918 /*
919  * perfmon_inc_stat () - Increment statistic value by 1.
920  *
921  * return : Void.
922  * thread_p (in) : Thread entry.
923  * psid (in) : Statistic ID.
924  */
925 STATIC_INLINE void
926 perfmon_inc_stat (THREAD_ENTRY * thread_p, PERF_STAT_ID psid)
927 {
928  perfmon_add_stat (thread_p, psid, 1);
929 }
930 
931 /*
932  * perfmon_inc_stat_to_global () - Increment global statistic value by 1.
933  *
934  * return : Void.
935  * thread_p (in) : Thread entry.
936  * psid (in) : Statistic ID.
937  */
938 STATIC_INLINE void
940 {
941  perfmon_add_stat_to_global (psid, 1);
942 }
943 
944 /*
945  * perfmon_add_at_offset () - Add amount to statistic in global/local at offset.
946  *
947  * return : Void.
948  * thread_p (in) : Thread entry.
949  * offset (in) : Offset to statistics value.
950  * amount (in) : Amount to add.
951  */
952 STATIC_INLINE void
953 perfmon_add_at_offset (THREAD_ENTRY * thread_p, int offset, UINT64 amount)
954 {
955 #if defined (SERVER_MODE) || defined (SA_MODE)
956  int tran_index;
957 #endif /* SERVER_MODE || SA_MODE */
958 
959  assert (offset >= 0 && offset < pstat_Global.n_stat_values);
960  assert (pstat_Global.initialized);
961 
962  /* Update global statistic. */
963  ATOMIC_INC_64 (&(pstat_Global.global_stats[offset]), amount);
964 
965 #if defined (SERVER_MODE) || defined (SA_MODE)
966  /* Update local statistic */
967  tran_index = LOG_FIND_THREAD_TRAN_INDEX (thread_p);
968  assert (tran_index >= 0 && tran_index < pstat_Global.n_trans);
969  if (pstat_Global.is_watching[tran_index])
970  {
971  assert (pstat_Global.tran_stats[tran_index] != NULL);
972  pstat_Global.tran_stats[tran_index][offset] += amount;
973  }
974 #endif /* SERVER_MODE || SA_MODE */
975 }
976 
977 /*
978  * perfmon_add_at_offset_to_global () - Add amount to statistic in global
979  *
980  * return : Void.
981  * offset (in) : Offset to statistics value.
982  * amount (in) : Amount to add.
983  */
984 STATIC_INLINE void
985 perfmon_add_at_offset_to_global (int offset, UINT64 amount)
986 {
987  assert (offset >= 0 && offset < pstat_Global.n_stat_values);
988  assert (pstat_Global.initialized);
989 
990  /* Update global statistic. */
991  ATOMIC_INC_64 (&(pstat_Global.global_stats[offset]), amount);
992 }
993 
994 /*
995  * perfmon_set_stat () - Set statistic value.
996  *
997  * return : Void.
998  * thread_p (in) : Thread entry.
999  * psid (in) : Statistic ID.
1000  * statval (in) : New statistic value.
1001  * always_collect (in): Flag that tells that we should always collect statistics
1002  */
1003 STATIC_INLINE void
1004 perfmon_set_stat (THREAD_ENTRY * thread_p, PERF_STAT_ID psid, int statval, bool always_collect)
1005 {
1006  assert (PSTAT_BASE < psid && psid < PSTAT_COUNT);
1007 
1008  if (!perfmon_is_perf_tracking_force (always_collect))
1009  {
1010  /* No need to collect statistics since no one is interested. */
1011  return;
1012  }
1013 
1014  assert (pstat_Metadata[psid].valtype == PSTAT_PEEK_SINGLE_VALUE);
1015 
1016  perfmon_set_at_offset (thread_p, pstat_Metadata[psid].start_offset, statval, always_collect);
1017 }
1018 
1019 /*
1020  * perfmon_set_at_offset () - Set statistic value in global/local at offset.
1021  *
1022  * return : Void.
1023  * thread_p (in) : Thread entry.
1024  * offset (in) : Offset to statistic value.
1025  * statval (in) : New statistic value.
1026  * always_collect (in): Flag that tells that we should always collect statistics
1027  */
1028 STATIC_INLINE void
1029 perfmon_set_at_offset (THREAD_ENTRY * thread_p, int offset, int statval, bool always_collect)
1030 {
1031 #if defined (SERVER_MODE) || defined (SA_MODE)
1032  int tran_index;
1033 #endif /* SERVER_MODE || SA_MODE */
1034 
1035  assert (offset >= 0 && offset < pstat_Global.n_stat_values);
1036  assert (pstat_Global.initialized);
1037 
1038  /* Update global statistic. */
1039  ATOMIC_TAS_64 (&(pstat_Global.global_stats[offset]), statval);
1040 
1041 #if defined (SERVER_MODE) || defined (SA_MODE)
1042  /* Update local statistic */
1043  tran_index = LOG_FIND_THREAD_TRAN_INDEX (thread_p);
1044  assert (tran_index >= 0 && tran_index < pstat_Global.n_trans);
1045  if (always_collect || pstat_Global.is_watching[tran_index])
1046  {
1047  assert (pstat_Global.tran_stats[tran_index] != NULL);
1048  pstat_Global.tran_stats[tran_index][offset] = statval;
1049  }
1050 #endif /* SERVER_MODE || SA_MODE */
1051 }
1052 
1053 /*
1054  * perfmon_set_stat_to_global () - Set statistic value only for global statistics
1055  *
1056  * return : Void.
1057  * psid (in) : Statistic ID.
1058  * statval (in) : New statistic value.
1059  */
1060 STATIC_INLINE void
1061 perfmon_set_stat_to_global (PERF_STAT_ID psid, int statval)
1062 {
1063  assert (PSTAT_BASE < psid && psid < PSTAT_COUNT);
1064 
1065  if (!pstat_Global.initialized)
1066  {
1067  return;
1068  }
1069 
1070  assert (pstat_Metadata[psid].valtype == PSTAT_PEEK_SINGLE_VALUE);
1071 
1072  perfmon_set_at_offset_to_global (pstat_Metadata[psid].start_offset, statval);
1073 }
1074 
1075 /*
1076  * perfmon_set_at_offset_to_global () - Set statistic value in global offset.
1077  *
1078  * return : Void.
1079  * offset (in) : Offset to statistic value.
1080  * statval (in) : New statistic value.
1081  */
1082 STATIC_INLINE void
1083 perfmon_set_at_offset_to_global (int offset, int statval)
1084 {
1085  assert (offset >= 0 && offset < pstat_Global.n_stat_values);
1086  assert (pstat_Global.initialized);
1087 
1088  /* Update global statistic. */
1089  ATOMIC_TAS_64 (&(pstat_Global.global_stats[offset]), statval);
1090 }
1091 
1092 /*
1093  * perfmon_time_stat () - Register statistic timer value. Counter, total time and maximum time are updated.
1094  *
1095  * return : Void.
1096  * thread_p (in) : Thread entry.
1097  * psid (in) : Statistic ID.
1098  * timediff (in) : Time difference to register.
1099  */
1100 STATIC_INLINE void
1101 perfmon_time_stat (THREAD_ENTRY * thread_p, PERF_STAT_ID psid, UINT64 timediff)
1102 {
1103  assert (pstat_Global.initialized);
1104  assert (PSTAT_BASE < psid && psid < PSTAT_COUNT);
1105 
1106  assert (pstat_Metadata[psid].valtype == PSTAT_COUNTER_TIMER_VALUE);
1107 
1108  perfmon_time_at_offset (thread_p, pstat_Metadata[psid].start_offset, timediff);
1109 }
1110 
1111 /*
1112  * perfmon_time_at_offset () - Register timer statistics in global/local at offset.
1113  *
1114  * return : Void.
1115  * thread_p (in) : Thread entry.
1116  * offset (in) : Offset to timer values.
1117  * timediff (in) : Time difference to add to timer.
1118  *
1119  * NOTE: There will be three values modified: counter, total time and max time.
1120  */
1121 STATIC_INLINE void
1122 perfmon_time_at_offset (THREAD_ENTRY * thread_p, int offset, UINT64 timediff)
1123 {
1124  /* Update global statistics */
1125  UINT64 *statvalp = NULL;
1126  UINT64 max_time;
1127 #if defined (SERVER_MODE) || defined (SA_MODE)
1128  int tran_index;
1129 #endif /* SERVER_MODE || SA_MODE */
1130 
1131  assert (offset >= 0 && offset < pstat_Global.n_stat_values);
1132  assert (pstat_Global.initialized);
1133 
1134  /* Update global statistics. */
1135  statvalp = pstat_Global.global_stats + offset;
1136  ATOMIC_INC_64 (PSTAT_COUNTER_TIMER_COUNT_VALUE (statvalp), 1ULL);
1137  ATOMIC_INC_64 (PSTAT_COUNTER_TIMER_TOTAL_TIME_VALUE (statvalp), timediff);
1138  do
1139  {
1140  max_time = ATOMIC_LOAD_64 (PSTAT_COUNTER_TIMER_MAX_TIME_VALUE (statvalp));
1141  if (max_time >= timediff)
1142  {
1143  /* No need to change max_time. */
1144  break;
1145  }
1146  }
1147  while (!ATOMIC_CAS_64 (PSTAT_COUNTER_TIMER_MAX_TIME_VALUE (statvalp), max_time, timediff));
1148  /* Average is not computed here. */
1149 
1150 #if defined (SERVER_MODE) || defined (SA_MODE)
1151  /* Update local statistic */
1152  tran_index = LOG_FIND_THREAD_TRAN_INDEX (thread_p);
1153  assert (tran_index >= 0 && tran_index < pstat_Global.n_trans);
1154  if (pstat_Global.is_watching[tran_index])
1155  {
1156  assert (pstat_Global.tran_stats[tran_index] != NULL);
1157  statvalp = pstat_Global.tran_stats[tran_index] + offset;
1158  (*PSTAT_COUNTER_TIMER_COUNT_VALUE (statvalp)) += 1;
1159  (*PSTAT_COUNTER_TIMER_TOTAL_TIME_VALUE (statvalp)) += timediff;
1160  max_time = *PSTAT_COUNTER_TIMER_MAX_TIME_VALUE (statvalp);
1161  if (max_time < timediff)
1162  {
1163  (*PSTAT_COUNTER_TIMER_MAX_TIME_VALUE (statvalp)) = timediff;
1164  }
1165  }
1166 #endif /* SERVER_MODE || SA_MODE */
1167 }
1168 
1169 /*
1170  * perfmon_time_bulk_stat () - Register statistic timer value. Counter, total time and maximum time are updated.
1171  * Used to count and time multiple units at once (as opposed to perfmon_time_stat which
1172  * increments count by one).
1173  *
1174  * return : Void.
1175  * thread_p (in) : Thread entry.
1176  * psid (in) : Statistic ID.
1177  * timediff (in) : Time difference to register.
1178  * count (in) : Unit count.
1179  */
1180 STATIC_INLINE void
1181 perfmon_time_bulk_stat (THREAD_ENTRY * thread_p, PERF_STAT_ID psid, UINT64 timediff, UINT64 count)
1182 {
1183  assert (pstat_Global.initialized);
1184  assert (PSTAT_BASE < psid && psid < PSTAT_COUNT);
1185 
1186  assert (pstat_Metadata[psid].valtype == PSTAT_COUNTER_TIMER_VALUE);
1187 
1188  perfmon_time_bulk_at_offset (thread_p, pstat_Metadata[psid].start_offset, timediff, count);
1189 }
1190 
1191 /*
1192  * perfmon_time_bulk_at_offset () - Register timer statistics in global/local at offset for multiple units at once.
1193  *
1194  * return : Void.
1195  * thread_p (in) : Thread entry.
1196  * offset (in) : Offset to timer values.
1197  * timediff (in) : Time difference to add to timer.
1198  * count (in) : Unit count timed at once
1199  *
1200  * NOTE: There will be three values modified: counter, total time and max time.
1201  */
1202 STATIC_INLINE void
1203 perfmon_time_bulk_at_offset (THREAD_ENTRY * thread_p, int offset, UINT64 timediff, UINT64 count)
1204 {
1205  /* Update global statistics */
1206  UINT64 *statvalp = NULL;
1207  UINT64 max_time;
1208  UINT64 time_per_unit;
1209 #if defined (SERVER_MODE) || defined (SA_MODE)
1210  int tran_index;
1211 #endif /* SERVER_MODE || SA_MODE */
1212 
1213  assert (offset >= 0 && offset < pstat_Global.n_stat_values);
1214  assert (pstat_Global.initialized);
1215 
1216  if (count == 0)
1217  {
1218  return;
1219  }
1220  time_per_unit = timediff / count;
1221 
1222  /* Update global statistics. */
1223  statvalp = pstat_Global.global_stats + offset;
1224  ATOMIC_INC_64 (PSTAT_COUNTER_TIMER_COUNT_VALUE (statvalp), count);
1225  ATOMIC_INC_64 (PSTAT_COUNTER_TIMER_TOTAL_TIME_VALUE (statvalp), timediff);
1226  do
1227  {
1228  max_time = ATOMIC_LOAD_64 (PSTAT_COUNTER_TIMER_MAX_TIME_VALUE (statvalp));
1229  if (max_time >= time_per_unit)
1230  {
1231  /* No need to change max_time. */
1232  break;
1233  }
1234  }
1235  while (!ATOMIC_CAS_64 (PSTAT_COUNTER_TIMER_MAX_TIME_VALUE (statvalp), max_time, time_per_unit));
1236  /* Average is not computed here. */
1237 
1238 #if defined (SERVER_MODE) || defined (SA_MODE)
1239  /* Update local statistic */
1240  tran_index = LOG_FIND_THREAD_TRAN_INDEX (thread_p);
1241  assert (tran_index >= 0 && tran_index < pstat_Global.n_trans);
1242  if (pstat_Global.is_watching[tran_index])
1243  {
1244  assert (pstat_Global.tran_stats[tran_index] != NULL);
1245  statvalp = pstat_Global.tran_stats[tran_index] + offset;
1246  (*PSTAT_COUNTER_TIMER_COUNT_VALUE (statvalp)) += count;
1247  (*PSTAT_COUNTER_TIMER_TOTAL_TIME_VALUE (statvalp)) += timediff;
1248  max_time = *PSTAT_COUNTER_TIMER_MAX_TIME_VALUE (statvalp);
1249  if (max_time < time_per_unit)
1250  {
1251  (*PSTAT_COUNTER_TIMER_MAX_TIME_VALUE (statvalp)) = time_per_unit;
1252  }
1253  }
1254 #endif /* SERVER_MODE || SA_MODE */
1255 }
1256 
1257 /*
1258  * perfmon_get_activation_flag - Get the activation flag
1259  *
1260  * return: int
1261  */
1262 STATIC_INLINE int
1264 {
1265  return pstat_Global.activation_flag;
1266 }
1267 
1268 /*
1269  * perfmon_is_perf_tracking () - Returns true if there are active threads
1270  *
1271  * return : true or false
1272  */
1273 STATIC_INLINE bool
1275 {
1276  return pstat_Global.initialized && pstat_Global.n_watchers > 0;
1277 }
1278 
1279 /*
1280  * perfmon_is_perf_tracking_and_active () - Returns true if there are active threads
1281  * and the activation_flag of the extended statistic is activated
1282  *
1283  * return : true or false
1284  * activation_flag (in) : activation flag for extended statistic
1285  *
1286  */
1287 STATIC_INLINE bool
1289 {
1290  return perfmon_is_perf_tracking () && (activation_flag & pstat_Global.activation_flag);
1291 }
1292 
1293 
1294 /*
1295  * perfmon_is_perf_tracking_force () - Skips the check for active threads if the always_collect
1296  * flag is set to true
1297  *
1298  * return : true or false
1299  * always_collect (in) : flag that tells that we should always collect statistics
1300  *
1301  */
1302 STATIC_INLINE bool
1303 perfmon_is_perf_tracking_force (bool always_collect)
1304 {
1305  return pstat_Global.initialized && (always_collect || pstat_Global.n_watchers > 0);
1306 }
1307 
1308 #endif /* __cplusplus */
1309 
1310 #if defined(CS_MODE) || defined(SA_MODE)
1311 /* Client execution statistic structure */
1312 typedef struct perfmon_client_stat_info PERFMON_CLIENT_STAT_INFO;
1313 struct perfmon_client_stat_info
1314 {
1315  time_t cpu_start_usr_time;
1316  time_t cpu_start_sys_time;
1317  time_t elapsed_start_time;
1318  UINT64 *base_server_stats;
1319  UINT64 *current_server_stats;
1320  UINT64 *old_global_stats;
1321  UINT64 *current_global_stats;
1322 };
1323 
1324 extern bool perfmon_Iscollecting_stats;
1325 
1326 extern int perfmon_start_stats (bool for_all_trans);
1327 extern int perfmon_stop_stats (void);
1328 extern void perfmon_reset_stats (void);
1329 extern int perfmon_print_stats (FILE * stream);
1330 extern int perfmon_print_global_stats (FILE * stream, bool cumulative, const char *substr);
1331 extern int perfmon_get_stats (void);
1332 extern int perfmon_get_global_stats (void);
1333 #endif /* CS_MODE || SA_MODE */
1334 
1335 STATIC_INLINE void
1336 perfmon_diff_timeval (struct timeval *elapsed, struct timeval *start, struct timeval *end)
1337 {
1338  elapsed->tv_sec = end->tv_sec - start->tv_sec;
1339  elapsed->tv_usec = end->tv_usec - start->tv_usec;
1340 
1341  if (elapsed->tv_usec < 0)
1342  {
1343  elapsed->tv_sec--;
1344  elapsed->tv_usec += 1000000;
1345  }
1346 }
1347 
1348 STATIC_INLINE void
1349 perfmon_add_timeval (struct timeval *total, struct timeval *start, struct timeval *end)
1350 {
1351  if (end->tv_usec - start->tv_usec >= 0)
1352  {
1353  total->tv_usec += end->tv_usec - start->tv_usec;
1354  total->tv_sec += end->tv_sec - start->tv_sec;
1355  }
1356  else
1357  {
1358  total->tv_usec += 1000000 + (end->tv_usec - start->tv_usec);
1359  total->tv_sec += end->tv_sec - start->tv_sec - 1;
1360  }
1361 
1362  total->tv_sec += total->tv_usec / 1000000;
1363  total->tv_usec %= 1000000;
1364 }
1365 
1366 #define TO_MSEC(elapsed) \
1367  ((int)(((elapsed).tv_sec * 1000) + (int) ((elapsed).tv_usec / 1000)))
1368 
1369 #if defined (EnableThreadMonitoring)
1370 #define MONITOR_WAITING_THREAD(elapsed) \
1371  (prm_get_integer_value (PRM_ID_MNT_WAITING_THREAD) > 0 \
1372  && ((elapsed).tv_sec * 1000 + (elapsed).tv_usec / 1000) \
1373  > prm_get_integer_value (PRM_ID_MNT_WAITING_THREAD))
1374 #else
1375 #define MONITOR_WAITING_THREAD(elapsed) (0)
1376 #endif
1377 
1378 #if defined (SERVER_MODE) || defined (SA_MODE)
1379 typedef struct perf_utime_tracker PERF_UTIME_TRACKER;
1380 struct perf_utime_tracker
1381 {
1382  bool is_perf_tracking;
1383  TSC_TICKS start_tick;
1384  TSC_TICKS end_tick;
1385 };
1386 #define PERF_UTIME_TRACKER_INITIALIZER { false, {0}, {0} }
1387 #define PERF_UTIME_TRACKER_START(thread_p, track) \
1388  do \
1389  { \
1390  (track)->is_perf_tracking = perfmon_is_perf_tracking (); \
1391  if ((track)->is_perf_tracking) tsc_getticks (&(track)->start_tick); \
1392  } \
1393  while (false)
1394 /* Time trackers - perfmon_time_stat is called. */
1395 #define PERF_UTIME_TRACKER_TIME(thread_p, track, psid) \
1396  do \
1397  { \
1398  if (!(track)->is_perf_tracking) break; \
1399  tsc_getticks (&(track)->end_tick); \
1400  perfmon_time_stat (thread_p, psid, tsc_elapsed_utime ((track)->end_tick, (track)->start_tick)); \
1401  } \
1402  while (false)
1403 #define PERF_UTIME_TRACKER_TIME_AND_RESTART(thread_p, track, psid) \
1404  do \
1405  { \
1406  if (!(track)->is_perf_tracking) break; \
1407  tsc_getticks (&(track)->end_tick); \
1408  perfmon_time_stat (thread_p, psid, tsc_elapsed_utime ((track)->end_tick, (track)->start_tick)); \
1409  (track)->start_tick = (track)->end_tick; \
1410  } \
1411  while (false)
1412 /* Bulk time trackers - perfmon_time_bulk_stat is called. */
1413 #define PERF_UTIME_TRACKER_BULK_TIME(thread_p, track, psid, count) \
1414  do \
1415  { \
1416  if (!(track)->is_perf_tracking) break; \
1417  tsc_getticks (&(track)->end_tick); \
1418  perfmon_time_bulk_stat (thread_p, psid, tsc_elapsed_utime ((track)->end_tick, (track)->start_tick), count); \
1419  } \
1420  while (false)
1421 #define PERF_UTIME_TRACKER_BULK_TIME_AND_RESTART(thread_p, track, psid, count) \
1422  do \
1423  { \
1424  if (!(track)->is_perf_tracking) break; \
1425  tsc_getticks (&(track)->end_tick); \
1426  perfmon_time_bulk, stat (thread_p, psid, tsc_elapsed_utime ((track)->end_tick, (track)->start_tick), count); \
1427  (track)->start_tick = (track)->end_tick; \
1428  } \
1429  while (false)
1430 
1431 /* Time accumulators only - perfmon_add_stat is called. */
1432 /* todo: PERF_UTIME_TRACKER_ADD_TIME is never used and PERF_UTIME_TRACKER_ADD_TIME_AND_RESTART is similar to
1433  * PERF_UTIME_TRACKER_TIME_AND_RESTART. they were supposed to collect just timers, but now have changed */
1434 #define PERF_UTIME_TRACKER_ADD_TIME(thread_p, track, psid) \
1435  do \
1436  { \
1437  if (!(track)->is_perf_tracking) break; \
1438  tsc_getticks (&(track)->end_tick); \
1439  perfmon_time_stat (thread_p, psid, (int) tsc_elapsed_utime ((track)->end_tick, (track)->start_tick)); \
1440  } \
1441  while (false)
1442 #define PERF_UTIME_TRACKER_ADD_TIME_AND_RESTART(thread_p, track, psid) \
1443  do \
1444  { \
1445  if (!(track)->is_perf_tracking) break; \
1446  tsc_getticks (&(track)->end_tick); \
1447  perfmon_time_stat (thread_p, psid, (int) tsc_elapsed_utime ((track)->end_tick, (track)->start_tick)); \
1448  (track)->start_tick = (track)->end_tick; \
1449  } \
1450  while (false)
1451 #endif /* defined (SERVER_MODE) || defined (SA_MODE) */
1452 
1453 #if defined(SERVER_MODE) || defined (SA_MODE)
1454 /*
1455  * Statistics at file io level
1456  */
1457 extern bool perfmon_server_is_stats_on (THREAD_ENTRY * thread_p);
1458 
1459 extern UINT64 perfmon_get_from_statistic (THREAD_ENTRY * thread_p, const int statistic_id);
1460 
1461 extern void perfmon_lk_waited_time_on_objects (THREAD_ENTRY * thread_p, int lock_mode, UINT64 amount);
1462 
1463 extern UINT64 perfmon_get_stats_and_clear (THREAD_ENTRY * thread_p, const char *stat_name);
1464 
1465 extern void perfmon_pbx_fix (THREAD_ENTRY * thread_p, int page_type, int page_found_mode, int latch_mode,
1466  int cond_type);
1467 extern void perfmon_pbx_promote (THREAD_ENTRY * thread_p, int page_type, int promote_cond, int holder_latch,
1468  int success, UINT64 amount);
1469 extern void perfmon_pbx_unfix (THREAD_ENTRY * thread_p, int page_type, int buf_dirty, int dirtied_by_holder,
1470  int holder_latch);
1471 extern void perfmon_pbx_lock_acquire_time (THREAD_ENTRY * thread_p, int page_type, int page_found_mode, int latch_mode,
1472  int cond_type, UINT64 amount);
1473 extern void perfmon_pbx_hold_acquire_time (THREAD_ENTRY * thread_p, int page_type, int page_found_mode, int latch_mode,
1474  UINT64 amount);
1475 extern void perfmon_pbx_fix_acquire_time (THREAD_ENTRY * thread_p, int page_type, int page_found_mode, int latch_mode,
1476  int cond_type, UINT64 amount);
1477 extern void perfmon_mvcc_snapshot (THREAD_ENTRY * thread_p, int snapshot, int rec_type, int visibility);
1478 extern void perfmon_db_flushed_block_volumes (THREAD_ENTRY * thread_p, int num_volumes);
1479 
1480 #endif /* SERVER_MODE || SA_MODE */
1481 
1482 #endif /* _PERF_MONITOR_H_ */
t_diag_server_type
Definition: perf_monitor.h:802
STATIC_INLINE void perfmon_add_stat_to_global(PERF_STAT_ID psid, UINT64 amount) __attribute__((ALWAYS_INLINE))
UINT64 * global_stats
Definition: perf_monitor.h:661
STATIC_INLINE void perfmon_inc_stat_to_global(PERF_STAT_ID psid) __attribute__((ALWAYS_INLINE))
#define __attribute__(X)
Definition: porting.h:36
PERF_HOLDER_LATCH
Definition: perf_monitor.h:171
PERF_PAGE_MODE
Definition: perf_monitor.h:197
STATIC_INLINE void perfmon_add_timeval(struct timeval *total, struct timeval *start, struct timeval *end) __attribute__((ALWAYS_INLINE))
#define PSTAT_COUNTER_TIMER_TOTAL_TIME_VALUE(startvalp)
Definition: perf_monitor.h:139
PSTAT_DUMP_IN_BUFFER_FUNC f_dump_in_buffer
Definition: perf_monitor.h:720
PSTAT_LOAD_FUNC f_load
Definition: perf_monitor.h:721
bool * is_watching
Definition: perf_monitor.h:666
#define ALWAYS_INLINE
PERF_PROMOTE_CONDITION
Definition: perf_monitor.h:189
STATIC_INLINE void perfmon_add_at_offset_to_global(int offset, UINT64 amount) __attribute__((ALWAYS_INLINE))
PSTAT_METADATA pstat_Metadata[]
STATIC_INLINE void perfmon_time_at_offset(THREAD_ENTRY *thread_p, int offset, UINT64 timediff) __attribute__((ALWAYS_INLINE))
void perfmon_server_dump_stats(const UINT64 *stats, FILE *stream, const char *substr)
STATIC_INLINE void perfmon_set_at_offset(THREAD_ENTRY *thread_p, int offset, int statval, bool check_watchers) __attribute__((ALWAYS_INLINE))
enum t_diag_server_type T_DIAG_SERVER_TYPE
Definition: perf_monitor.h:809
PERF_MODULE_TYPE
Definition: perf_monitor.h:162
void perfmon_copy_values(UINT64 *src, UINT64 *dest)
#define PSTAT_COUNTER_TIMER_MAX_TIME_VALUE(startvalp)
Definition: perf_monitor.h:140
STATIC_INLINE int perfmon_get_activation_flag(void) __attribute__((ALWAYS_INLINE))
int perfmon_calc_diff_stats(UINT64 *stats_diff, UINT64 *new_stats, UINT64 *old_stats)
int(* PSTAT_LOAD_FUNC)(void)
Definition: perf_monitor.h:706
const char * stat_name
Definition: perf_monitor.h:712
void(* PSTAT_DUMP_IN_BUFFER_FUNC)(char **, const UINT64 *stat_vals, int *remaining_size)
Definition: perf_monitor.h:705
STATIC_INLINE void perfmon_set_stat_to_global(PERF_STAT_ID psid, int statval) __attribute__((ALWAYS_INLINE))
pthread_mutex_t watch_lock
Definition: perf_monitor.h:668
void THREAD_ENTRY
PERF_SNAPSHOT_TYPE
Definition: perf_monitor.h:232
void perfmon_server_dump_stats_to_buffer(const UINT64 *stats, char *buffer, int buf_size, const char *substr)
MONITOR_SERVER_CONFIG server
Definition: perf_monitor.h:780
#define MAX_SERVER_NAMELENGTH
Definition: perf_monitor.h:53
#define assert(x)
PSTAT_DUMP_IN_FILE_FUNC f_dump_in_file
Definition: perf_monitor.h:719
#define STATIC_INLINE
PERF_CONDITIONAL_FIX_TYPE
Definition: perf_monitor.h:180
MONITOR_CAS_CONFIG cas
Definition: perf_monitor.h:779
char * perfmon_allocate_packed_values_buffer(void)
int substr(std::string &result, bool &is_matched, const cub_regex_object &reg, const std::string &src, const int position, const int occurrence, const INTL_CODESET codeset)
#define NULL
Definition: freelistheap.h:34
STATIC_INLINE bool perfmon_is_perf_tracking_force(bool always_collect) __attribute__((ALWAYS_INLINE))
PERF_STAT_ID psid
Definition: perf_monitor.h:711
STATIC_INLINE bool perfmon_is_perf_tracking(void) __attribute__((ALWAYS_INLINE))
STATIC_INLINE bool perfmon_is_perf_tracking_and_active(int activation_flag) __attribute__((ALWAYS_INLINE))
static int success()
enum t_diag_shm_mode T_DIAG_SHM_MODE
Definition: perf_monitor.h:800
int count(int &result, const cub_regex_object &reg, const std::string &src, const int position, const INTL_CODESET codeset)
STATIC_INLINE void perfmon_set_at_offset_to_global(int offset, int statval) __attribute__((ALWAYS_INLINE))
STATIC_INLINE void perfmon_diff_timeval(struct timeval *elapsed, struct timeval *start, struct timeval *end) __attribute__((ALWAYS_INLINE))
void(* PSTAT_DUMP_IN_FILE_FUNC)(FILE *, const UINT64 *stat_vals)
Definition: perf_monitor.h:704
PERF_SNAPSHOT_RECORD_TYPE
Definition: perf_monitor.h:242
char * perfmon_unpack_stats(char *buf, UINT64 *stats)
#define MAX_SERVER_THREAD_COUNT
Definition: perf_monitor.h:52
STATIC_INLINE void perfmon_inc_stat(THREAD_ENTRY *thread_p, PERF_STAT_ID psid) __attribute__((ALWAYS_INLINE))
PERF_SNAPSHOT_VISIBILITY
Definition: perf_monitor.h:260
#define LOG_FIND_THREAD_TRAN_INDEX(thrd)
Definition: perf_monitor.h:158
PERFMON_ACTIVATION_FLAG
Definition: perf_monitor.h:57
STATIC_INLINE void perfmon_time_stat(THREAD_ENTRY *thread_p, PERF_STAT_ID psid, UINT64 timediff) __attribute__((ALWAYS_INLINE))
int perfmon_get_number_of_statistic_values(void)
int perfmon_initialize(int num_trans)
UINT64 * perfmon_allocate_values(void)
#define PSTAT_COUNTER_TIMER_COUNT_VALUE(startvalp)
Definition: perf_monitor.h:138
PSTAT_GLOBAL pstat_Global
void perfmon_finalize(void)
STATIC_INLINE void perfmon_set_stat(THREAD_ENTRY *thread_p, PERF_STAT_ID psid, int statval, bool check_watchers) __attribute__((ALWAYS_INLINE))
STATIC_INLINE void perfmon_add_stat(THREAD_ENTRY *thread_p, PERF_STAT_ID psid, UINT64 amount) __attribute__((ALWAYS_INLINE))
PERF_STAT_ID
Definition: perf_monitor.h:268
int log_Tran_index
Definition: log_global.c:43
PSTAT_VALUE_TYPE
Definition: perf_monitor.h:679
INT32 n_watchers
Definition: perf_monitor.h:671
PSTAT_VALUE_TYPE valtype
Definition: perf_monitor.h:713
void perfmon_get_current_times(time_t *cpu_usr_time, time_t *cpu_sys_time, time_t *elapsed_time)
char * perfmon_pack_stats(char *buf, UINT64 *stats)
t_diag_shm_mode
Definition: perf_monitor.h:795
PERF_PAGE_TYPE
Definition: perf_monitor.h:209
UINT64 ** tran_stats
Definition: perf_monitor.h:664
STATIC_INLINE void perfmon_time_bulk_at_offset(THREAD_ENTRY *thread_p, int offset, UINT64 timediff, UINT64 count) __attribute__((ALWAYS_INLINE))
STATIC_INLINE void perfmon_add_at_offset(THREAD_ENTRY *thread_p, int offset, UINT64 amount) __attribute__((ALWAYS_INLINE))
int server_long_query_time
Definition: perf_monitor.h:731