MySQL  8.0.20
Source Code Documentation
pfs_stat.h
Go to the documentation of this file.
1 /* Copyright (c) 2008, 2020, Oracle and/or its affiliates. All rights reserved.
2 
3  This program is free software; you can redistribute it and/or modify
4  it under the terms of the GNU General Public License, version 2.0,
5  as published by the Free Software Foundation.
6 
7  This program is also distributed with certain software (including
8  but not limited to OpenSSL) that is licensed under separate terms,
9  as designated in a particular file or component or in included license
10  documentation. The authors of MySQL hereby grant you an additional
11  permission to link the program and your derivative works with the
12  separately licensed software that they have included with MySQL.
13 
14  This program is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License, version 2.0, for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with this program; if not, write to the Free Software
21  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
22 
23 #ifndef PFS_STAT_H
24 #define PFS_STAT_H
25 
26 #include <algorithm>
27 #include <atomic>
28 
29 #include "my_dbug.h"
30 #include "my_sys.h"
31 #include "my_systime.h"
32 #include "sql/sql_const.h"
35 /* memcpy */
36 #include "string.h"
37 
39 
40 /**
41  @file storage/perfschema/pfs_stat.h
42  Statistics (declarations).
43 */
44 
45 /**
46  @addtogroup performance_schema_buffers
47  @{
48 */
49 
50 /** Single statistic. */
52  /** Count of values. */
54  /** Sum of values. */
56  /** Minimum value. */
58  /** Maximum value. */
60 
62  m_count = 0;
63  m_sum = 0;
64  m_min = ULLONG_MAX;
65  m_max = 0;
66  }
67 
68  inline void reset(void) {
69  m_count = 0;
70  m_sum = 0;
71  m_min = ULLONG_MAX;
72  m_max = 0;
73  }
74 
75  inline bool has_timed_stats() const { return (m_min <= m_max); }
76 
77  inline void aggregate(const PFS_single_stat *stat) {
78  if (stat->m_count != 0) {
79  m_count += stat->m_count;
80  m_sum += stat->m_sum;
81  if (unlikely(m_min > stat->m_min)) {
82  m_min = stat->m_min;
83  }
84  if (unlikely(m_max < stat->m_max)) {
85  m_max = stat->m_max;
86  }
87  }
88  }
89 
90  inline void aggregate_no_check(const PFS_single_stat *stat) {
91  m_count += stat->m_count;
92  m_sum += stat->m_sum;
93  if (unlikely(m_min > stat->m_min)) {
94  m_min = stat->m_min;
95  }
96  if (unlikely(m_max < stat->m_max)) {
97  m_max = stat->m_max;
98  }
99  }
100 
101  inline void aggregate_counted() { m_count++; }
102 
103  inline void aggregate_counted(ulonglong count) { m_count += count; }
104 
106  m_count++;
107  m_sum += value;
108  if (unlikely(m_min > value)) {
109  m_min = value;
110  }
111  if (unlikely(m_max < value)) {
112  m_max = value;
113  }
114  }
115 
117  m_count += count;
118  m_sum += value;
119  if (unlikely(m_min > value)) {
120  m_min = value;
121  }
122  if (unlikely(m_max < value)) {
123  m_max = value;
124  }
125  }
126 };
127 
128 /** Combined statistic. */
130  /** Byte count statistics */
132 
133  /** Aggregate wait stats, event count and byte count */
134  inline void aggregate(const PFS_byte_stat *stat) {
135  if (stat->m_count != 0) {
137  m_bytes += stat->m_bytes;
138  }
139  }
140 
141  /** Aggregate wait stats, event count and byte count */
142  inline void aggregate_no_check(const PFS_byte_stat *stat) {
144  m_bytes += stat->m_bytes;
145  }
146 
147  /** Aggregate individual wait time, event count and byte count */
148  inline void aggregate(ulonglong wait, ulonglong bytes) {
149  aggregate_value(wait);
150  m_bytes += bytes;
151  }
152 
153  /** Aggregate wait stats and event count */
154  inline void aggregate_waits(const PFS_byte_stat *stat) {
156  }
157 
158  /** Aggregate event count and byte count */
160 
161  /** Aggregate event count and byte count */
162  inline void aggregate_counted(ulonglong bytes) {
164  m_bytes += bytes;
165  }
166 
168 
169  inline void reset(void) {
171  m_bytes = 0;
172  }
173 };
174 
175 /** Statistics for mutex usage. */
177  /** Wait statistics. */
179 #ifdef PFS_LATER
180  /**
181  Lock statistics.
182  This statistic is not exposed in user visible tables yet.
183  */
184  PFS_single_stat m_lock_stat;
185 #endif
186 
187  inline void aggregate(const PFS_mutex_stat *stat) {
188  m_wait_stat.aggregate(&stat->m_wait_stat);
189 #ifdef PFS_LATER
190  m_lock_stat.aggregate(&stat->m_lock_stat);
191 #endif
192  }
193 
194  inline void reset(void) {
195  m_wait_stat.reset();
196 #ifdef PFS_LATER
197  m_lock_stat.reset();
198 #endif
199  }
200 };
201 
202 /** Statistics for rwlock usage. */
204  /** Wait statistics. */
206 #ifdef PFS_LATER
207  /**
208  RWLock read lock usage statistics.
209  This statistic is not exposed in user visible tables yet.
210  */
211  PFS_single_stat m_read_lock_stat;
212  /**
213  RWLock write lock usage statistics.
214  This statistic is not exposed in user visible tables yet.
215  */
216  PFS_single_stat m_write_lock_stat;
217 #endif
218 
219  inline void aggregate(const PFS_rwlock_stat *stat) {
220  m_wait_stat.aggregate(&stat->m_wait_stat);
221 #ifdef PFS_LATER
222  m_read_lock_stat.aggregate(&stat->m_read_lock_stat);
223  m_write_lock_stat.aggregate(&stat->m_write_lock_stat);
224 #endif
225  }
226 
227  inline void reset(void) {
228  m_wait_stat.reset();
229 #ifdef PFS_LATER
230  m_read_lock_stat.reset();
231  m_write_lock_stat.reset();
232 #endif
233  }
234 };
235 
236 /** Statistics for conditions usage. */
238  /** Wait statistics. */
240 #ifdef PFS_LATER
241  /**
242  Number of times a condition was signalled.
243  This statistic is not exposed in user visible tables yet.
244  */
245  ulonglong m_signal_count;
246  /**
247  Number of times a condition was broadcast.
248  This statistic is not exposed in user visible tables yet.
249  */
250  ulonglong m_broadcast_count;
251 #endif
252 
253  inline void aggregate(const PFS_cond_stat *stat) {
254  m_wait_stat.aggregate(&stat->m_wait_stat);
255 #ifdef PFS_LATER
256  m_signal_count += stat->m_signal_count;
257  m_broadcast_count += stat->m_broadcast_count;
258 #endif
259  }
260 
261  inline void reset(void) {
262  m_wait_stat.reset();
263 #ifdef PFS_LATER
264  m_signal_count = 0;
265  m_broadcast_count = 0;
266 #endif
267  }
268 };
269 
270 /** Statistics for FILE I/O. Used for both waits and byte counts. */
272  /** READ statistics */
274  /** WRITE statistics */
276  /** Miscellaneous statistics */
278 
279  inline void reset(void) {
280  m_read.reset();
281  m_write.reset();
282  m_misc.reset();
283  }
284 
285  inline void aggregate(const PFS_file_io_stat *stat) {
286  m_read.aggregate(&stat->m_read);
287  m_write.aggregate(&stat->m_write);
288  m_misc.aggregate(&stat->m_misc);
289  }
290 
291  /* Sum waits and byte counts */
292  inline void sum(PFS_byte_stat *stat) {
293  stat->aggregate(&m_read);
294  stat->aggregate(&m_write);
295  stat->aggregate(&m_misc);
296  }
297 
298  /* Sum waits only */
299  inline void sum_waits(PFS_single_stat *stat) {
300  stat->aggregate(&m_read);
301  stat->aggregate(&m_write);
302  stat->aggregate(&m_misc);
303  }
304 };
305 
306 /** Statistics for FILE usage. */
308  /** Number of current open handles. */
310  /** File I/O statistics. */
312 
313  inline void aggregate(const PFS_file_stat *stat) {
314  m_io_stat.aggregate(&stat->m_io_stat);
315  }
316 
317  /** Reset file statistics. */
318  inline void reset(void) { m_io_stat.reset(); }
319 };
320 
321 /** Statistics for stage usage. */
324 
325  inline void reset(void) { m_timer1_stat.reset(); }
326 
327  inline void aggregate_counted() { m_timer1_stat.aggregate_counted(); }
328 
330  m_timer1_stat.aggregate_value(value);
331  }
332 
333  inline void aggregate(const PFS_stage_stat *stat) {
334  m_timer1_stat.aggregate(&stat->m_timer1_stat);
335  }
336 };
337 
338 /** Statistics for stored program usage. */
339 struct PFS_sp_stat {
341 
342  inline void reset(void) { m_timer1_stat.reset(); }
343 
344  inline void aggregate_counted() { m_timer1_stat.aggregate_counted(); }
345 
347  m_timer1_stat.aggregate_value(value);
348  }
349 
350  inline void aggregate(const PFS_stage_stat *stat) {
351  m_timer1_stat.aggregate(&stat->m_timer1_stat);
352  }
353 };
354 
355 /** Statistics for prepared statement usage. */
358 
359  inline void reset(void) { m_timer1_stat.reset(); }
360 
361  inline void aggregate_counted() { m_timer1_stat.aggregate_counted(); }
362 
364  m_timer1_stat.aggregate_value(value);
365  }
366 
367  inline void aggregate(PFS_stage_stat *stat) {
368  m_timer1_stat.aggregate(&stat->m_timer1_stat);
369  }
370 };
371 
372 /**
373  Statistics for statement usage.
374 */
377  ulonglong m_error_count{0};
378  ulonglong m_warning_count{0};
379  ulonglong m_rows_affected{0};
380  ulonglong m_lock_time{0};
381  ulonglong m_rows_sent{0};
382  ulonglong m_rows_examined{0};
383  ulonglong m_created_tmp_disk_tables{0};
384  ulonglong m_created_tmp_tables{0};
385  ulonglong m_select_full_join{0};
386  ulonglong m_select_full_range_join{0};
387  ulonglong m_select_range{0};
388  ulonglong m_select_range_check{0};
389  ulonglong m_select_scan{0};
390  ulonglong m_sort_merge_passes{0};
391  ulonglong m_sort_range{0};
392  ulonglong m_sort_rows{0};
393  ulonglong m_sort_scan{0};
394  ulonglong m_no_index_used{0};
395  ulonglong m_no_good_index_used{0};
396 
397  void reset() { new (this) PFS_statement_stat(); }
398 
399  void aggregate_counted() { m_timer1_stat.aggregate_counted(); }
400 
402  m_timer1_stat.aggregate_value(value);
403  }
404 
405  void aggregate(const PFS_statement_stat *stat) {
406  if (stat->m_timer1_stat.m_count != 0) {
407  m_timer1_stat.aggregate_no_check(&stat->m_timer1_stat);
408 
409  m_error_count += stat->m_error_count;
410  m_warning_count += stat->m_warning_count;
411  m_rows_affected += stat->m_rows_affected;
412  m_lock_time += stat->m_lock_time;
413  m_rows_sent += stat->m_rows_sent;
414  m_rows_examined += stat->m_rows_examined;
415  m_created_tmp_disk_tables += stat->m_created_tmp_disk_tables;
416  m_created_tmp_tables += stat->m_created_tmp_tables;
417  m_select_full_join += stat->m_select_full_join;
418  m_select_full_range_join += stat->m_select_full_range_join;
419  m_select_range += stat->m_select_range;
420  m_select_range_check += stat->m_select_range_check;
421  m_select_scan += stat->m_select_scan;
422  m_sort_merge_passes += stat->m_sort_merge_passes;
423  m_sort_range += stat->m_sort_range;
424  m_sort_rows += stat->m_sort_rows;
425  m_sort_scan += stat->m_sort_scan;
426  m_no_index_used += stat->m_no_index_used;
427  m_no_good_index_used += stat->m_no_good_index_used;
428  }
429  }
430 };
431 
432 /** Statistics for transaction usage. */
436 
440 
442  m_savepoint_count = 0;
443  m_rollback_to_savepoint_count = 0;
444  m_release_savepoint_count = 0;
445  }
446 
447  ulonglong count(void) {
448  return (m_read_write_stat.m_count + m_read_only_stat.m_count);
449  }
450 
451  inline void reset(void) {
452  m_read_write_stat.reset();
453  m_read_only_stat.reset();
454  m_savepoint_count = 0;
455  m_rollback_to_savepoint_count = 0;
456  m_release_savepoint_count = 0;
457  }
458 
459  inline void aggregate(const PFS_transaction_stat *stat) {
460  m_read_write_stat.aggregate(&stat->m_read_write_stat);
461  m_read_only_stat.aggregate(&stat->m_read_only_stat);
462  m_savepoint_count += stat->m_savepoint_count;
463  m_rollback_to_savepoint_count += stat->m_rollback_to_savepoint_count;
464  m_release_savepoint_count += stat->m_release_savepoint_count;
465  }
466 };
467 
468 /** Statistics for a server error. */
472  /** First and last seen timestamps.*/
475 
477  m_count = 0;
478  m_handled_count = 0;
479  m_first_seen = 0;
480  m_last_seen = 0;
481  }
482 
483  ulonglong count(void) { return m_count; }
484 
485  inline void reset() {
486  m_count = 0;
487  m_handled_count = 0;
488  m_first_seen = 0;
489  m_last_seen = 0;
490  }
491 
492  inline void aggregate_count(int error_operation) {
493  m_last_seen = my_micro_time();
494  if (m_first_seen == 0) {
495  m_first_seen = m_last_seen;
496  }
497 
498  switch (error_operation) {
500  m_count++;
501  break;
503  m_handled_count++;
504  m_count--;
505  break;
506  default:
507  /* It must not be reached. */
508  DBUG_ASSERT(0);
509  break;
510  }
511  }
512 
513  inline void aggregate(const PFS_error_single_stat *stat) {
514  if (stat->m_count == 0 && stat->m_handled_count == 0) {
515  return;
516  }
517 
518  m_count += stat->m_count;
519  m_handled_count += stat->m_handled_count;
520 
521  if (m_first_seen == 0 || stat->m_first_seen < m_first_seen) {
522  m_first_seen = stat->m_first_seen;
523  }
524  if (stat->m_last_seen > m_last_seen) {
525  m_last_seen = stat->m_last_seen;
526  }
527  }
528 };
529 
530 /** Statistics for all server errors. */
532  /** The number of errors, including +1 for the NULL row. */
533  size_t m_max_errors;
535 
536  PFS_error_stat() : m_max_errors(0), m_stat(nullptr) {}
537 
538  const PFS_error_single_stat *get_stat(uint error_index) const {
539  return &m_stat[error_index];
540  }
541 
542  ulonglong count(void) {
543  ulonglong total = 0;
544  for (uint i = 0; i < m_max_errors; i++) {
545  total += m_stat[i].count();
546  }
547  return total;
548  }
549 
550  ulonglong count(uint error_index) { return m_stat[error_index].count(); }
551 
552  inline void init(PFS_builtin_memory_class *memory_class, size_t max_errors) {
553  if (max_errors == 0) {
554  return;
555  }
556 
557  m_max_errors = max_errors;
558  /* Allocate memory for errors' stats. The NULL row is already included. */
559  m_stat = PFS_MALLOC_ARRAY(memory_class, m_max_errors,
560  sizeof(PFS_error_single_stat),
562  reset();
563  }
564 
565  inline void cleanup(PFS_builtin_memory_class *memory_class) {
566  if (m_stat == nullptr) {
567  return;
568  }
569 
570  PFS_FREE_ARRAY(memory_class, m_max_errors, sizeof(PFS_error_single_stat),
571  m_stat);
572  m_stat = nullptr;
573  }
574 
575  inline void reset() {
576  if (m_stat == nullptr) {
577  return;
578  }
579 
580  for (uint i = 0; i < m_max_errors; i++) {
581  m_stat[i].reset();
582  }
583  }
584 
585  inline void aggregate_count(int error_index, int error_operation) {
586  if (m_stat == nullptr) {
587  return;
588  }
589 
590  PFS_error_single_stat *stat = &m_stat[error_index];
591  stat->aggregate_count(error_operation);
592  }
593 
594  inline void aggregate(const PFS_error_single_stat *stat, uint error_index) {
595  if (m_stat == nullptr) {
596  return;
597  }
598 
599  DBUG_ASSERT(error_index < m_max_errors);
600  m_stat[error_index].aggregate(stat);
601  }
602 
603  inline void aggregate(const PFS_error_stat *stat) {
604  if (m_stat == nullptr) {
605  return;
606  }
607 
608  /*
609  Sizes can be different, for example when aggregating
610  per session statistics into global statistics.
611  */
612  size_t common_max = std::min(m_max_errors, stat->m_max_errors);
613  for (uint i = 0; i < common_max; i++) {
614  m_stat[i].aggregate(&stat->m_stat[i]);
615  }
616  }
617 };
618 
619 /** Single table I/O statistic. */
622  /** FETCH statistics */
624  /** INSERT statistics */
626  /** UPDATE statistics */
628  /** DELETE statistics */
630 
631  PFS_table_io_stat() { m_has_data = false; }
632 
633  inline void reset(void) {
634  m_has_data = false;
635  m_fetch.reset();
636  m_insert.reset();
637  m_update.reset();
638  m_delete.reset();
639  }
640 
641  inline void aggregate(const PFS_table_io_stat *stat) {
642  if (stat->m_has_data) {
643  m_has_data = true;
644  m_fetch.aggregate(&stat->m_fetch);
645  m_insert.aggregate(&stat->m_insert);
646  m_update.aggregate(&stat->m_update);
647  m_delete.aggregate(&stat->m_delete);
648  }
649  }
650 
651  inline void sum(PFS_single_stat *result) {
652  if (m_has_data) {
653  result->aggregate(&m_fetch);
654  result->aggregate(&m_insert);
655  result->aggregate(&m_update);
656  result->aggregate(&m_delete);
657  }
658  }
659 };
660 
662  /* Locks from enum thr_lock */
671 
672  /* Locks for handler::ha_external_lock() */
675 
677 };
678 
679 #define COUNT_PFS_TL_LOCK_TYPE 10
680 
681 /** Statistics for table locks. */
684 
685  inline void reset(void) {
686  PFS_single_stat *pfs = &m_stat[0];
687  PFS_single_stat *pfs_last = &m_stat[COUNT_PFS_TL_LOCK_TYPE];
688  for (; pfs < pfs_last; pfs++) {
689  pfs->reset();
690  }
691  }
692 
693  inline void aggregate(const PFS_table_lock_stat *stat) {
694  PFS_single_stat *pfs = &m_stat[0];
695  PFS_single_stat *pfs_last = &m_stat[COUNT_PFS_TL_LOCK_TYPE];
696  const PFS_single_stat *pfs_from = &stat->m_stat[0];
697  for (; pfs < pfs_last; pfs++, pfs_from++) {
698  pfs->aggregate(pfs_from);
699  }
700  }
701 
702  inline void sum(PFS_single_stat *result) {
703  PFS_single_stat *pfs = &m_stat[0];
704  PFS_single_stat *pfs_last = &m_stat[COUNT_PFS_TL_LOCK_TYPE];
705  for (; pfs < pfs_last; pfs++) {
706  result->aggregate(pfs);
707  }
708  }
709 };
710 
711 /** Statistics for TABLE usage. */
713  /**
714  Statistics, per index.
715  Each index stat is in [0, MAX_INDEXES-1],
716  stats when using no index are in [MAX_INDEXES].
717  */
718  PFS_table_io_stat m_index_stat[MAX_INDEXES + 1];
719 
720  /**
721  Statistics, per lock type.
722  */
724 
725  /** Reset table I/O statistic. */
726  inline void reset_io(void) {
727  PFS_table_io_stat *stat = &m_index_stat[0];
728  PFS_table_io_stat *stat_last = &m_index_stat[MAX_INDEXES + 1];
729  for (; stat < stat_last; stat++) {
730  stat->reset();
731  }
732  }
733 
734  /** Reset table lock statistic. */
735  inline void reset_lock(void) { m_lock_stat.reset(); }
736 
737  /** Reset table statistic. */
738  inline void reset(void) {
739  reset_io();
740  reset_lock();
741  }
742 
743  inline void fast_reset_io(void) {
744  memcpy(&m_index_stat, &g_reset_template.m_index_stat, sizeof(m_index_stat));
745  }
746 
747  inline void fast_reset_lock(void) {
748  memcpy(&m_lock_stat, &g_reset_template.m_lock_stat, sizeof(m_lock_stat));
749  }
750 
751  inline void fast_reset(void) {
752  memcpy(this, &g_reset_template, sizeof(*this));
753  }
754 
755  inline void aggregate_io(const PFS_table_stat *stat, uint key_count) {
756  PFS_table_io_stat *to_stat;
757  PFS_table_io_stat *to_stat_last;
758  const PFS_table_io_stat *from_stat;
759 
760  DBUG_ASSERT(key_count <= MAX_INDEXES);
761 
762  /* Aggregate stats for each index, if any */
763  to_stat = &m_index_stat[0];
764  to_stat_last = to_stat + key_count;
765  from_stat = &stat->m_index_stat[0];
766  for (; to_stat < to_stat_last; from_stat++, to_stat++) {
767  to_stat->aggregate(from_stat);
768  }
769 
770  /* Aggregate stats for the table */
771  to_stat = &m_index_stat[MAX_INDEXES];
772  from_stat = &stat->m_index_stat[MAX_INDEXES];
773  to_stat->aggregate(from_stat);
774  }
775 
776  inline void aggregate_lock(const PFS_table_stat *stat) {
777  m_lock_stat.aggregate(&stat->m_lock_stat);
778  }
779 
780  inline void aggregate(const PFS_table_stat *stat, uint key_count) {
781  aggregate_io(stat, key_count);
782  aggregate_lock(stat);
783  }
784 
785  inline void sum_io(PFS_single_stat *result, uint key_count) {
786  PFS_table_io_stat *stat;
787  PFS_table_io_stat *stat_last;
788 
789  DBUG_ASSERT(key_count <= MAX_INDEXES);
790 
791  /* Sum stats for each index, if any */
792  stat = &m_index_stat[0];
793  stat_last = stat + key_count;
794  for (; stat < stat_last; stat++) {
795  stat->sum(result);
796  }
797 
798  /* Sum stats for the table */
799  m_index_stat[MAX_INDEXES].sum(result);
800  }
801 
802  inline void sum_lock(PFS_single_stat *result) { m_lock_stat.sum(result); }
803 
804  inline void sum(PFS_single_stat *result, uint key_count) {
805  sum_io(result, key_count);
806  sum_lock(result);
807  }
808 
810 };
811 
812 /** Statistics for SOCKET I/O. Used for both waits and byte counts. */
814  /** READ statistics */
816  /** WRITE statistics */
818  /** Miscellaneous statistics */
820 
821  inline void reset(void) {
822  m_read.reset();
823  m_write.reset();
824  m_misc.reset();
825  }
826 
827  inline void aggregate(const PFS_socket_io_stat *stat) {
828  m_read.aggregate(&stat->m_read);
829  m_write.aggregate(&stat->m_write);
830  m_misc.aggregate(&stat->m_misc);
831  }
832 
833  /* Sum waits and byte counts */
834  inline void sum(PFS_byte_stat *stat) {
835  stat->aggregate(&m_read);
836  stat->aggregate(&m_write);
837  stat->aggregate(&m_misc);
838  }
839 
840  /* Sum waits only */
841  inline void sum_waits(PFS_single_stat *stat) {
842  stat->aggregate(&m_read);
843  stat->aggregate(&m_write);
844  stat->aggregate(&m_misc);
845  }
846 };
847 
848 /** Statistics for SOCKET usage. */
850  /** Socket timing and byte count statistics per operation */
852 
853  /** Reset socket statistics. */
854  inline void reset(void) { m_io_stat.reset(); }
855 };
856 
862 
863  void reset() {
864  m_alloc_count_delta = 0;
865  m_free_count_delta = 0;
866  m_alloc_size_delta = 0;
867  m_free_size_delta = 0;
868  }
869 };
870 
871 template <typename F, typename T>
872 void memory_partial_aggregate(F *from, T *stat) {
873  if (!from->m_used) {
874  return;
875  }
876 
877  size_t base;
878 
879  stat->m_used = true;
880 
881  base = std::min<size_t>(from->m_alloc_count, from->m_free_count);
882  if (base != 0) {
883  stat->m_alloc_count += base;
884  stat->m_free_count += base;
885  from->m_alloc_count -= base;
886  from->m_free_count -= base;
887  }
888 
889  base = std::min<size_t>(from->m_alloc_size, from->m_free_size);
890  if (base != 0) {
891  stat->m_alloc_size += base;
892  stat->m_free_size += base;
893  from->m_alloc_size -= base;
894  from->m_free_size -= base;
895  }
896 
897  size_t tmp;
898 
899  tmp = from->m_alloc_count_capacity;
900  if (tmp != 0) {
901  stat->m_alloc_count_capacity += tmp;
902  from->m_alloc_count_capacity = 0;
903  }
904 
905  tmp = from->m_free_count_capacity;
906  if (tmp != 0) {
907  stat->m_free_count_capacity += tmp;
908  from->m_free_count_capacity = 0;
909  }
910 
911  tmp = from->m_alloc_size_capacity;
912  if (tmp != 0) {
913  stat->m_alloc_size_capacity += tmp;
914  from->m_alloc_size_capacity = 0;
915  }
916 
917  tmp = from->m_free_size_capacity;
918  if (tmp != 0) {
919  stat->m_free_size_capacity += tmp;
920  from->m_free_size_capacity = 0;
921  }
922 }
923 
924 template <typename F, typename T>
925 void memory_partial_aggregate(F *from, T *stat1, T *stat2) {
926  if (!from->m_used) {
927  return;
928  }
929 
930  size_t base;
931 
932  stat1->m_used = true;
933  stat2->m_used = true;
934 
935  base = std::min<size_t>(from->m_alloc_count, from->m_free_count);
936  if (base != 0) {
937  stat1->m_alloc_count += base;
938  stat2->m_alloc_count += base;
939  stat1->m_free_count += base;
940  stat2->m_free_count += base;
941  from->m_alloc_count -= base;
942  from->m_free_count -= base;
943  }
944 
945  base = std::min<size_t>(from->m_alloc_size, from->m_free_size);
946  if (base != 0) {
947  stat1->m_alloc_size += base;
948  stat2->m_alloc_size += base;
949  stat1->m_free_size += base;
950  stat2->m_free_size += base;
951  from->m_alloc_size -= base;
952  from->m_free_size -= base;
953  }
954 
955  size_t tmp;
956 
957  tmp = from->m_alloc_count_capacity;
958  if (tmp != 0) {
959  stat1->m_alloc_count_capacity += tmp;
960  stat2->m_alloc_count_capacity += tmp;
961  from->m_alloc_count_capacity = 0;
962  }
963 
964  tmp = from->m_free_count_capacity;
965  if (tmp != 0) {
966  stat1->m_free_count_capacity += tmp;
967  stat2->m_free_count_capacity += tmp;
968  from->m_free_count_capacity = 0;
969  }
970 
971  tmp = from->m_alloc_size_capacity;
972  if (tmp != 0) {
973  stat1->m_alloc_size_capacity += tmp;
974  stat2->m_alloc_size_capacity += tmp;
975  from->m_alloc_size_capacity = 0;
976  }
977 
978  tmp = from->m_free_size_capacity;
979  if (tmp != 0) {
980  stat1->m_free_size_capacity += tmp;
981  stat2->m_free_size_capacity += tmp;
982  from->m_free_size_capacity = 0;
983  }
984 }
985 
986 // Missing overload for Studio 12.6 Sun C++ 5.15
987 #if defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x5150)
988 inline size_t &operator+=(size_t &target, const std::atomic<size_t> &val) {
989  target += val.load();
990  return target;
991 }
992 #endif
993 
994 template <typename F, typename T>
995 void memory_full_aggregate(const F *from, T *stat) {
996  if (!from->m_used) {
997  return;
998  }
999 
1000  stat->m_used = true;
1001 
1002  stat->m_alloc_count += from->m_alloc_count;
1003  stat->m_free_count += from->m_free_count;
1004  stat->m_alloc_size += from->m_alloc_size;
1005  stat->m_free_size += from->m_free_size;
1006 
1007  stat->m_alloc_count_capacity += from->m_alloc_count_capacity;
1008  stat->m_free_count_capacity += from->m_free_count_capacity;
1009  stat->m_alloc_size_capacity += from->m_alloc_size_capacity;
1010  stat->m_free_size_capacity += from->m_free_size_capacity;
1011 }
1012 
1013 template <typename F, typename T>
1014 void memory_full_aggregate(const F *from, T *stat1, T *stat2) {
1015  if (!from->m_used) {
1016  return;
1017  }
1018 
1019  stat1->m_used = true;
1020  stat2->m_used = true;
1021 
1022  size_t tmp;
1023 
1024  tmp = from->m_alloc_count;
1025  stat1->m_alloc_count += tmp;
1026  stat2->m_alloc_count += tmp;
1027 
1028  tmp = from->m_free_count;
1029  stat1->m_free_count += tmp;
1030  stat2->m_free_count += tmp;
1031 
1032  tmp = from->m_alloc_size;
1033  stat1->m_alloc_size += tmp;
1034  stat2->m_alloc_size += tmp;
1035 
1036  tmp = from->m_free_size;
1037  stat1->m_free_size += tmp;
1038  stat2->m_free_size += tmp;
1039 
1040  tmp = from->m_alloc_count_capacity;
1041  stat1->m_alloc_count_capacity += tmp;
1042  stat2->m_alloc_count_capacity += tmp;
1043 
1044  tmp = from->m_free_count_capacity;
1045  stat1->m_free_count_capacity += tmp;
1046  stat2->m_free_count_capacity += tmp;
1047 
1048  tmp = from->m_alloc_size_capacity;
1049  stat1->m_alloc_size_capacity += tmp;
1050  stat2->m_alloc_size_capacity += tmp;
1051 
1052  tmp = from->m_free_size_capacity;
1053  stat1->m_free_size_capacity += tmp;
1054  stat2->m_free_size_capacity += tmp;
1055 }
1056 
1058  std::atomic<bool> m_used;
1059  std::atomic<size_t> m_alloc_count;
1060  std::atomic<size_t> m_free_count;
1061  std::atomic<size_t> m_alloc_size;
1062  std::atomic<size_t> m_free_size;
1063 
1064  std::atomic<size_t> m_alloc_count_capacity;
1065  std::atomic<size_t> m_free_count_capacity;
1066  std::atomic<size_t> m_alloc_size_capacity;
1067  std::atomic<size_t> m_free_size_capacity;
1068 
1069  inline void reset(void) {
1070  m_used = false;
1071  m_alloc_count = 0;
1072  m_free_count = 0;
1073  m_alloc_size = 0;
1074  m_free_size = 0;
1075 
1076  m_alloc_count_capacity = 0;
1077  m_free_count_capacity = 0;
1078  m_alloc_size_capacity = 0;
1079  m_free_size_capacity = 0;
1080  }
1081 
1082  inline void rebase(void) {
1083  if (!m_used) {
1084  return;
1085  }
1086 
1087  size_t base;
1088 
1089  base = std::min<size_t>(m_alloc_count, m_free_count);
1090  m_alloc_count -= base;
1091  m_free_count -= base;
1092 
1093  base = std::min<size_t>(m_alloc_size, m_free_size);
1094  m_alloc_size -= base;
1095  m_free_size -= base;
1096 
1097  m_alloc_count_capacity = 0;
1098  m_free_count_capacity = 0;
1099  m_alloc_size_capacity = 0;
1100  m_free_size_capacity = 0;
1101  }
1102 
1103  void count_builtin_alloc(size_t size) {
1104  m_used = true;
1105 
1106  m_alloc_count++;
1107  m_free_count_capacity++;
1108  m_alloc_size += size;
1109  m_free_size_capacity += size;
1110 
1111  size_t old_value;
1112 
1113  /* Optimistic */
1114  old_value = m_alloc_count_capacity.fetch_sub(1);
1115 
1116  /* Adjustment */
1117  if (old_value <= 0) {
1118  m_alloc_count_capacity++;
1119  }
1120 
1121  /* Optimistic */
1122  old_value = m_alloc_size_capacity.fetch_sub(size);
1123 
1124  /* Adjustment */
1125  if (old_value < size) {
1126  m_alloc_size_capacity = 0;
1127  }
1128 
1129  return;
1130  }
1131 
1132  void count_builtin_free(size_t size) {
1133  m_used = true;
1134 
1135  m_free_count++;
1136  m_alloc_count_capacity++;
1137  m_free_size += size;
1138  m_alloc_size_capacity += size;
1139 
1140  size_t old_value;
1141 
1142  /* Optimistic */
1143  old_value = m_free_count_capacity.fetch_sub(1);
1144 
1145  /* Adjustment */
1146  if (old_value <= 0) {
1147  m_free_count_capacity++;
1148  }
1149 
1150  /* Optimistic */
1151  old_value = m_free_size_capacity.fetch_sub(size);
1152 
1153  /* Adjustment */
1154  if (old_value < size) {
1155  m_free_size_capacity = 0;
1156  }
1157 
1158  return;
1159  }
1160 
1161  inline void count_global_alloc(size_t size) { count_builtin_alloc(size); }
1162 
1163  inline void count_global_realloc(size_t old_size, size_t new_size) {
1164  if (old_size == new_size) {
1165  return;
1166  }
1167 
1168  size_t size_delta;
1169  size_t old_value;
1170 
1171  if (new_size > old_size) {
1172  /* Growing */
1173  size_delta = new_size - old_size;
1174  m_free_size_capacity += size_delta;
1175 
1176  /* Optimistic */
1177  old_value = m_alloc_size_capacity.fetch_sub(size_delta);
1178 
1179  /* Adjustment */
1180  if (old_value < size_delta) {
1181  m_alloc_size_capacity = 0;
1182  }
1183  } else {
1184  /* Shrinking */
1185  size_delta = old_size - new_size;
1186  m_alloc_size_capacity += size_delta;
1187 
1188  /* Optimistic */
1189  old_value = m_free_size_capacity.fetch_sub(size_delta);
1190 
1191  /* Adjustment */
1192  if (old_value < size_delta) {
1193  m_free_size_capacity = 0;
1194  }
1195  }
1196  }
1197 
1198  inline void count_global_free(size_t size) { count_builtin_free(size); }
1199 
1200  inline PFS_memory_stat_delta *count_alloc(size_t size,
1201  PFS_memory_stat_delta *delta) {
1202  m_used = true;
1203 
1204  m_alloc_count++;
1205  m_free_count_capacity++;
1206  m_alloc_size += size;
1207  m_free_size_capacity += size;
1208 
1209  if ((m_alloc_count_capacity >= 1) && (m_alloc_size_capacity >= size)) {
1210  m_alloc_count_capacity--;
1211  m_alloc_size_capacity -= size;
1212  return nullptr;
1213  }
1214 
1215  delta->reset();
1216 
1217  if (m_alloc_count_capacity >= 1) {
1218  m_alloc_count_capacity--;
1219  } else {
1220  delta->m_alloc_count_delta = 1;
1221  }
1222 
1223  if (m_alloc_size_capacity >= size) {
1224  m_alloc_size_capacity -= size;
1225  } else {
1226  delta->m_alloc_size_delta = size - m_alloc_size_capacity;
1227  m_alloc_size_capacity = 0;
1228  }
1229 
1230  return delta;
1231  }
1232 
1233  inline PFS_memory_stat_delta *count_realloc(size_t old_size, size_t new_size,
1234  PFS_memory_stat_delta *delta) {
1235  m_used = true;
1236 
1237  size_t size_delta = new_size - old_size;
1238  m_alloc_count++;
1239  m_alloc_size += new_size;
1240  m_free_count++;
1241  m_free_size += old_size;
1242 
1243  if (new_size == old_size) {
1244  return nullptr;
1245  }
1246 
1247  if (new_size > old_size) {
1248  /* Growing */
1249  size_delta = new_size - old_size;
1250  m_free_size_capacity += size_delta;
1251 
1252  if (m_alloc_size_capacity >= size_delta) {
1253  m_alloc_size_capacity -= size_delta;
1254  return nullptr;
1255  }
1256 
1257  delta->reset();
1258  delta->m_alloc_size_delta = size_delta - m_alloc_size_capacity;
1259  m_alloc_size_capacity = 0;
1260  } else {
1261  /* Shrinking */
1262  size_delta = old_size - new_size;
1263  m_alloc_size_capacity += size_delta;
1264 
1265  if (m_free_size_capacity >= size_delta) {
1266  m_free_size_capacity -= size_delta;
1267  return nullptr;
1268  }
1269 
1270  delta->reset();
1271  delta->m_free_size_delta = size_delta - m_free_size_capacity;
1272  m_free_size_capacity = 0;
1273  }
1274 
1275  return delta;
1276  }
1277 
1278  inline PFS_memory_stat_delta *count_free(size_t size,
1279  PFS_memory_stat_delta *delta) {
1280  m_used = true;
1281 
1282  m_free_count++;
1283  m_alloc_count_capacity++;
1284  m_free_size += size;
1285  m_alloc_size_capacity += size;
1286 
1287  if ((m_free_count_capacity >= 1) && (m_free_size_capacity >= size)) {
1288  m_free_count_capacity--;
1289  m_free_size_capacity -= size;
1290  return nullptr;
1291  }
1292 
1293  delta->reset();
1294 
1295  if (m_free_count_capacity >= 1) {
1296  m_free_count_capacity--;
1297  } else {
1298  delta->m_free_count_delta = 1;
1299  }
1300 
1301  if (m_free_size_capacity >= size) {
1302  m_free_size_capacity -= size;
1303  } else {
1304  delta->m_free_size_delta = size - m_free_size_capacity;
1305  m_free_size_capacity = 0;
1306  }
1307 
1308  return delta;
1309  }
1310 
1312  const PFS_memory_stat_delta *delta, PFS_memory_stat_delta *delta_buffer) {
1313  size_t val;
1314  size_t remaining_alloc_count;
1315  size_t remaining_alloc_size;
1316  size_t remaining_free_count;
1317  size_t remaining_free_size;
1318  bool has_remaining = false;
1319 
1320  m_used = true;
1321 
1322  val = delta->m_alloc_count_delta;
1323  if (val <= m_alloc_count_capacity) {
1324  m_alloc_count_capacity -= val;
1325  remaining_alloc_count = 0;
1326  } else {
1327  remaining_alloc_count = val - m_alloc_count_capacity;
1328  m_alloc_count_capacity = 0;
1329  has_remaining = true;
1330  }
1331 
1332  val = delta->m_alloc_size_delta;
1333  if (val <= m_alloc_size_capacity) {
1334  m_alloc_size_capacity -= val;
1335  remaining_alloc_size = 0;
1336  } else {
1337  remaining_alloc_size = val - m_alloc_size_capacity;
1338  m_alloc_size_capacity = 0;
1339  has_remaining = true;
1340  }
1341 
1342  val = delta->m_free_count_delta;
1343  if (val <= m_free_count_capacity) {
1344  m_free_count_capacity -= val;
1345  remaining_free_count = 0;
1346  } else {
1347  remaining_free_count = val - m_free_count_capacity;
1348  m_free_count_capacity = 0;
1349  has_remaining = true;
1350  }
1351 
1352  val = delta->m_free_size_delta;
1353  if (val <= m_free_size_capacity) {
1354  m_free_size_capacity -= val;
1355  remaining_free_size = 0;
1356  } else {
1357  remaining_free_size = val - m_free_size_capacity;
1358  m_free_size_capacity = 0;
1359  has_remaining = true;
1360  }
1361 
1362  if (!has_remaining) {
1363  return nullptr;
1364  }
1365 
1366  delta_buffer->m_alloc_count_delta = remaining_alloc_count;
1367  delta_buffer->m_alloc_size_delta = remaining_alloc_size;
1368  delta_buffer->m_free_count_delta = remaining_free_count;
1369  delta_buffer->m_free_size_delta = remaining_free_size;
1370  return delta_buffer;
1371  }
1372 };
1373 
1374 /**
1375  Memory statistics.
1376  Conceptually, the following statistics are maintained:
1377  - CURRENT_COUNT_USED,
1378  - LOW_COUNT_USED,
1379  - HIGH_COUNT_USED
1380  - CURRENT_SIZE_USED,
1381  - LOW_SIZE_USED,
1382  - HIGH_SIZE_USED
1383  Now, the implementation keeps different counters,
1384  which are easier (less overhead) to maintain while
1385  collecting statistics.
1386  Invariants are as follows:
1387  CURRENT_COUNT_USED = @c m_alloc_count - @c m_free_count
1388  LOW_COUNT_USED + @c m_free_count_capacity = CURRENT_COUNT_USED
1389  CURRENT_COUNT_USED + @c m_alloc_count_capacity = HIGH_COUNT_USED
1390  CURRENT_SIZE_USED = @c m_alloc_size - @c m_free_size
1391  LOW_SIZE_USED + @c m_free_size_capacity = CURRENT_SIZE_USED
1392  CURRENT_SIZE_USED + @c m_alloc_size_capacity = HIGH_SIZE_USED
1393 */
1395  bool m_used;
1399  size_t m_free_size;
1400 
1405 
1406  inline void reset(void) {
1407  m_used = false;
1408  m_alloc_count = 0;
1409  m_free_count = 0;
1410  m_alloc_size = 0;
1411  m_free_size = 0;
1412 
1413  m_alloc_count_capacity = 0;
1414  m_free_count_capacity = 0;
1415  m_alloc_size_capacity = 0;
1416  m_free_size_capacity = 0;
1417  }
1418 
1419  inline void rebase(void) {
1420  if (!m_used) {
1421  return;
1422  }
1423 
1424  size_t base;
1425 
1426  base = std::min<size_t>(m_alloc_count, m_free_count);
1427  m_alloc_count -= base;
1428  m_free_count -= base;
1429 
1430  base = std::min<size_t>(m_alloc_size, m_free_size);
1431  m_alloc_size -= base;
1432  m_free_size -= base;
1433 
1434  m_alloc_count_capacity = 0;
1435  m_free_count_capacity = 0;
1436  m_alloc_size_capacity = 0;
1437  m_free_size_capacity = 0;
1438  }
1439 
1440  inline PFS_memory_stat_delta *count_alloc(size_t size,
1441  PFS_memory_stat_delta *delta) {
1442  m_used = true;
1443 
1444  m_alloc_count++;
1445  m_free_count_capacity++;
1446  m_alloc_size += size;
1447  m_free_size_capacity += size;
1448 
1449  if ((m_alloc_count_capacity >= 1) && (m_alloc_size_capacity >= size)) {
1450  m_alloc_count_capacity--;
1451  m_alloc_size_capacity -= size;
1452  return nullptr;
1453  }
1454 
1455  delta->reset();
1456 
1457  if (m_alloc_count_capacity >= 1) {
1458  m_alloc_count_capacity--;
1459  } else {
1460  delta->m_alloc_count_delta = 1;
1461  }
1462 
1463  if (m_alloc_size_capacity >= size) {
1464  m_alloc_size_capacity -= size;
1465  } else {
1466  delta->m_alloc_size_delta = size - m_alloc_size_capacity;
1467  m_alloc_size_capacity = 0;
1468  }
1469 
1470  return delta;
1471  }
1472 
1473  inline PFS_memory_stat_delta *count_realloc(size_t old_size, size_t new_size,
1474  PFS_memory_stat_delta *delta) {
1475  m_used = true;
1476 
1477  size_t size_delta = new_size - old_size;
1478  m_alloc_count++;
1479  m_alloc_size += new_size;
1480  m_free_count++;
1481  m_free_size += old_size;
1482 
1483  if (new_size == old_size) {
1484  return nullptr;
1485  }
1486 
1487  if (new_size > old_size) {
1488  /* Growing */
1489  size_delta = new_size - old_size;
1490  m_free_size_capacity += size_delta;
1491 
1492  if (m_alloc_size_capacity >= size_delta) {
1493  m_alloc_size_capacity -= size_delta;
1494  return nullptr;
1495  }
1496 
1497  delta->reset();
1498  delta->m_alloc_size_delta = size_delta - m_alloc_size_capacity;
1499  m_alloc_size_capacity = 0;
1500  } else {
1501  /* Shrinking */
1502  size_delta = old_size - new_size;
1503  m_alloc_size_capacity += size_delta;
1504 
1505  if (m_free_size_capacity >= size_delta) {
1506  m_free_size_capacity -= size_delta;
1507  return nullptr;
1508  }
1509 
1510  delta->reset();
1511  delta->m_free_size_delta = size_delta - m_free_size_capacity;
1512  m_free_size_capacity = 0;
1513  }
1514 
1515  return delta;
1516  }
1517 
1518  inline PFS_memory_stat_delta *count_free(size_t size,
1519  PFS_memory_stat_delta *delta) {
1520  m_used = true;
1521 
1522  m_free_count++;
1523  m_alloc_count_capacity++;
1524  m_free_size += size;
1525  m_alloc_size_capacity += size;
1526 
1527  if ((m_free_count_capacity >= 1) && (m_free_size_capacity >= size)) {
1528  m_free_count_capacity--;
1529  m_free_size_capacity -= size;
1530  return nullptr;
1531  }
1532 
1533  delta->reset();
1534 
1535  if (m_free_count_capacity >= 1) {
1536  m_free_count_capacity--;
1537  } else {
1538  delta->m_free_count_delta = 1;
1539  }
1540 
1541  if (m_free_size_capacity >= size) {
1542  m_free_size_capacity -= size;
1543  } else {
1544  delta->m_free_size_delta = size - m_free_size_capacity;
1545  m_free_size_capacity = 0;
1546  }
1547 
1548  return delta;
1549  }
1550 };
1551 
1552 #define PFS_MEMORY_STAT_INITIALIZER \
1553  { false, 0, 0, 0, 0, 0, 0, 0, 0 }
1554 
1555 /** Connections statistics. */
1557  PFS_connection_stat() : m_current_connections(0), m_total_connections(0) {}
1558 
1561 
1562  inline void aggregate_active(ulonglong active) {
1563  m_current_connections += active;
1564  m_total_connections += active;
1565  }
1566 
1567  inline void aggregate_disconnected(ulonglong disconnected) {
1568  m_total_connections += disconnected;
1569  }
1570 };
1571 
1572 /** @} */
1573 #endif
ulonglong m_select_full_range_join
Definition: pfs_stat.h:386
server error instrument data structures (declarations).
void reset(void)
Definition: pfs_stat.h:342
ulonglong m_rows_examined
Definition: pfs_stat.h:382
std::atomic< size_t > m_free_count
Definition: pfs_stat.h:1060
PFS_table_lock_stat m_lock_stat
Statistics, per lock type.
Definition: pfs_stat.h:723
Statistics for rwlock usage.
Definition: pfs_stat.h:203
PFS_byte_stat m_write
WRITE statistics.
Definition: pfs_stat.h:817
Definition: result.h:33
ulong m_open_count
Number of current open handles.
Definition: pfs_stat.h:309
unsigned long long int ulonglong
Definition: my_inttypes.h:55
PFS_memory_stat_delta * count_realloc(size_t old_size, size_t new_size, PFS_memory_stat_delta *delta)
Definition: pfs_stat.h:1473
void aggregate_counted()
Definition: pfs_stat.h:361
PFS_TL_LOCK_TYPE
Definition: pfs_stat.h:661
std::atomic< size_t > m_alloc_size_capacity
Definition: pfs_stat.h:1066
PFS_single_stat m_wait_stat
Wait statistics.
Definition: pfs_stat.h:178
void aggregate_counted(ulonglong bytes)
Aggregate event count and byte count.
Definition: pfs_stat.h:162
ulonglong count(void)
Definition: pfs_stat.h:542
PFS_single_stat m_read_write_stat
Definition: pfs_stat.h:434
size_t m_free_size_capacity
Definition: pfs_stat.h:1404
const PFS_error_single_stat * get_stat(uint error_index) const
Definition: pfs_stat.h:538
Statistics for statement usage.
Definition: pfs_stat.h:375
void aggregate(const PFS_cond_stat *stat)
Definition: pfs_stat.h:253
PFS_byte_stat m_read
READ statistics.
Definition: pfs_stat.h:273
void count_global_alloc(size_t size)
Definition: pfs_stat.h:1161
Statistics for mutex usage.
Definition: pfs_stat.h:176
size_t m_free_count_delta
Definition: pfs_stat.h:859
void aggregate_lock(const PFS_table_stat *stat)
Definition: pfs_stat.h:776
Defines for getting and processing the current system type programmatically.
void aggregate(const PFS_table_lock_stat *stat)
Definition: pfs_stat.h:693
ssize_t count
Definition: memcached.c:386
void sum_io(PFS_single_stat *result, uint key_count)
Definition: pfs_stat.h:785
File containing constants that can be used throughout the server.
ulonglong count(void)
Definition: pfs_stat.h:447
void reset(void)
Definition: pfs_stat.h:261
Statistics for table locks.
Definition: pfs_stat.h:682
PFS_single_stat m_insert
INSERT statistics.
Definition: pfs_stat.h:625
void aggregate_counted()
Definition: pfs_stat.h:327
PFS_single_stat m_fetch
FETCH statistics.
Definition: pfs_stat.h:623
PFS_error_stat()
Definition: pfs_stat.h:536
void reset(void)
Reset table statistic.
Definition: pfs_stat.h:738
void count_global_realloc(size_t old_size, size_t new_size)
Definition: pfs_stat.h:1163
void aggregate_value(ulonglong value)
Definition: pfs_stat.h:105
ulonglong m_release_savepoint_count
Definition: pfs_stat.h:439
void aggregate(const PFS_transaction_stat *stat)
Definition: pfs_stat.h:459
Definition: pfs_stat.h:665
PFS_table_io_stat()
Definition: pfs_stat.h:631
Statistics for FILE usage.
Definition: pfs_stat.h:307
PFS_error_single_stat * m_stat
Definition: pfs_stat.h:534
Definition: pfs_stat.h:1057
void reset(void)
Definition: pfs_stat.h:279
std::atomic< size_t > m_free_size
Definition: pfs_stat.h:1062
void aggregate(const PFS_stage_stat *stat)
Definition: pfs_stat.h:333
Definition: pfs_stat.h:667
std::atomic< bool > m_used
Definition: pfs_stat.h:1058
void aggregate_count(int error_operation)
Definition: pfs_stat.h:492
ulonglong m_no_index_used
Definition: pfs_stat.h:394
void reset(void)
Definition: pfs_stat.h:325
void reset()
Definition: pfs_stat.h:863
void count_global_free(size_t size)
Definition: pfs_stat.h:1198
ulonglong m_select_range_check
Definition: pfs_stat.h:388
void memory_partial_aggregate(F *from, T *stat)
Definition: pfs_stat.h:872
void reset(void)
Definition: pfs_stat.h:227
static struct PFS_table_stat g_reset_template
Definition: pfs_stat.h:809
Single table I/O statistic.
Definition: pfs_stat.h:620
Connections statistics.
Definition: pfs_stat.h:1556
void aggregate_many_value(ulonglong value, ulonglong count)
Definition: pfs_stat.h:116
void sum(PFS_single_stat *result)
Definition: pfs_stat.h:651
void reset(void)
Definition: pfs_stat.h:359
Definition: pfs_stat.h:673
void reset()
Definition: pfs_stat.h:485
void reset(void)
Definition: pfs_stat.h:821
Statistics for SOCKET usage.
Definition: pfs_stat.h:849
size_t m_free_count
Definition: pfs_stat.h:1397
Miscellaneous global dependencies (declarations).
Statistics for a server error.
Definition: pfs_stat.h:469
void aggregate(const PFS_error_single_stat *stat, uint error_index)
Definition: pfs_stat.h:594
void reset(void)
Definition: pfs_stat.h:685
PFS_memory_stat_delta * count_free(size_t size, PFS_memory_stat_delta *delta)
Definition: pfs_stat.h:1278
PFS_byte_stat m_write
WRITE statistics.
Definition: pfs_stat.h:275
void aggregate_active(ulonglong active)
Definition: pfs_stat.h:1562
PFS_byte_stat m_misc
Miscellaneous statistics.
Definition: pfs_stat.h:277
void reset_io(void)
Reset table I/O statistic.
Definition: pfs_stat.h:726
void aggregate(PFS_stage_stat *stat)
Definition: pfs_stat.h:367
ulonglong m_select_scan
Definition: pfs_stat.h:389
#define PFS_MALLOC_ARRAY(k, n, s, T, f)
Helper, to allocate an array of structures.
Definition: pfs_global.h:120
size_t m_alloc_count
Definition: pfs_stat.h:1396
ulonglong m_no_good_index_used
Definition: pfs_stat.h:395
void reset(void)
Definition: pfs_stat.h:1069
void sum_waits(PFS_single_stat *stat)
Definition: pfs_stat.h:299
void aggregate_value(ulonglong value)
Definition: pfs_stat.h:401
Statistics for all server errors.
Definition: pfs_stat.h:531
void aggregate_waits(const PFS_byte_stat *stat)
Aggregate wait stats and event count.
Definition: pfs_stat.h:154
std::atomic< size_t > m_free_size_capacity
Definition: pfs_stat.h:1067
ulonglong m_sort_range
Definition: pfs_stat.h:391
Definition: psi_error_bits.h:37
PFS_byte_stat()
Definition: pfs_stat.h:167
size_t m_alloc_size
Definition: pfs_stat.h:1398
PFS_socket_io_stat m_io_stat
Socket timing and byte count statistics per operation.
Definition: pfs_stat.h:851
PFS_table_io_stat m_index_stat[MAX_INDEXES+1]
Statistics, per index.
Definition: pfs_stat.h:718
Definition: pfs_stat.h:664
bool m_has_data
Definition: pfs_stat.h:621
ulonglong m_count
Definition: pfs_stat.h:470
ulonglong m_bytes
Byte count statistics.
Definition: pfs_stat.h:131
#define DBUG_ASSERT(A)
Definition: my_dbug.h:199
PFS_single_stat m_update
UPDATE statistics.
Definition: pfs_stat.h:627
ulonglong m_rows_sent
Definition: pfs_stat.h:381
void sum(PFS_byte_stat *stat)
Definition: pfs_stat.h:834
Statistics for stored program usage.
Definition: pfs_stat.h:339
size_t m_alloc_count_capacity
Definition: pfs_stat.h:1401
PFS_single_stat m_timer1_stat
Definition: pfs_stat.h:323
size_t m_free_size_delta
Definition: pfs_stat.h:861
ulonglong m_created_tmp_tables
Definition: pfs_stat.h:384
Single statistic.
Definition: pfs_stat.h:51
void aggregate_counted(ulonglong count)
Definition: pfs_stat.h:103
void reset(void)
Reset file statistics.
Definition: pfs_stat.h:318
ulonglong m_sort_scan
Definition: pfs_stat.h:393
#define MYF(v)
Type total(const Shards< COUNT > &shards) noexcept
Get the total value of all shards.
Definition: ut0counter.h:315
ulonglong m_count
Count of values.
Definition: pfs_stat.h:53
void aggregate_disconnected(ulonglong disconnected)
Definition: pfs_stat.h:1567
Statistics for TABLE usage.
Definition: pfs_stat.h:712
PFS_connection_stat()
Definition: pfs_stat.h:1557
ulonglong m_error_count
Definition: pfs_stat.h:377
void reset()
Definition: pfs_stat.h:575
ulonglong m_sort_rows
Definition: pfs_stat.h:392
Definition: pfs_builtin_memory.h:38
Definition: pfs_stat.h:674
void rebase(void)
Definition: pfs_stat.h:1419
PFS_memory_stat_delta * count_alloc(size_t size, PFS_memory_stat_delta *delta)
Definition: pfs_stat.h:1200
void aggregate(const PFS_rwlock_stat *stat)
Definition: pfs_stat.h:219
void aggregate_value(ulonglong value)
Definition: pfs_stat.h:329
void reset(void)
Definition: pfs_stat.h:633
void fast_reset(void)
Definition: pfs_stat.h:751
size_t m_alloc_count_delta
Definition: pfs_stat.h:858
ulonglong count(void)
Definition: pfs_stat.h:483
void reset(void)
Definition: pfs_stat.h:194
void sum_lock(PFS_single_stat *result)
Definition: pfs_stat.h:802
bool unlikely(bool expr)
Definition: my_compiler.h:55
void aggregate(const PFS_table_io_stat *stat)
Definition: pfs_stat.h:641
PFS_memory_stat_delta * apply_delta(const PFS_memory_stat_delta *delta, PFS_memory_stat_delta *delta_buffer)
Definition: pfs_stat.h:1311
Definition: pfs_stat.h:669
void sum_waits(PFS_single_stat *stat)
Definition: pfs_stat.h:841
void reset()
Definition: pfs_stat.h:397
Statistics for SOCKET I/O.
Definition: pfs_stat.h:813
ulonglong m_select_full_join
Definition: pfs_stat.h:385
Statistics for FILE I/O.
Definition: pfs_stat.h:271
void fast_reset_lock(void)
Definition: pfs_stat.h:747
unsigned int uint
Definition: uca-dump.cc:29
T old_value
Definition: server.cc:202
void reset_lock(void)
Reset table lock statistic.
Definition: pfs_stat.h:735
PFS_single_stat()
Definition: pfs_stat.h:61
Statistics for prepared statement usage.
Definition: pfs_stat.h:356
bool has_timed_stats() const
Definition: pfs_stat.h:75
ulonglong m_total_connections
Definition: pfs_stat.h:1560
size_t m_free_size
Definition: pfs_stat.h:1399
void sum(PFS_single_stat *result)
Definition: pfs_stat.h:702
void aggregate_no_check(const PFS_byte_stat *stat)
Aggregate wait stats, event count and byte count.
Definition: pfs_stat.h:142
void rebase(void)
Definition: pfs_stat.h:1082
void aggregate_counted()
Definition: pfs_stat.h:399
ulonglong m_created_tmp_disk_tables
Definition: pfs_stat.h:383
size_t m_free_count_capacity
Definition: pfs_stat.h:1402
#define COUNT_PFS_TL_LOCK_TYPE
Definition: pfs_stat.h:679
Statistics for conditions usage.
Definition: pfs_stat.h:237
Common header for many mysys elements.
Definition: pfs_stat.h:666
ulonglong m_max
Maximum value.
Definition: pfs_stat.h:59
void aggregate(const PFS_error_stat *stat)
Definition: pfs_stat.h:603
void count_builtin_free(size_t size)
Definition: pfs_stat.h:1132
void aggregate(const PFS_single_stat *stat)
Definition: pfs_stat.h:77
void sum(PFS_single_stat *result, uint key_count)
Definition: pfs_stat.h:804
Definition: psi_error_bits.h:36
Definition: pfs_stat.h:663
void aggregate(const PFS_file_io_stat *stat)
Definition: pfs_stat.h:285
unsigned long long int my_micro_time()
Return time in microseconds.
Definition: my_systime.h:185
#define MAX_INDEXES
Definition: config.h:201
void aggregate(const PFS_mutex_stat *stat)
Definition: pfs_stat.h:187
ulonglong m_lock_time
Definition: pfs_stat.h:380
std::atomic< size_t > m_alloc_count_capacity
Definition: pfs_stat.h:1064
void aggregate_value(ulonglong value)
Definition: pfs_stat.h:346
Memory statistics.
Definition: pfs_stat.h:1394
ulonglong m_last_seen
Definition: pfs_stat.h:474
ulonglong m_sum
Sum of values.
Definition: pfs_stat.h:55
void memory_full_aggregate(const F *from, T *stat)
Definition: pfs_stat.h:995
void count_builtin_alloc(size_t size)
Definition: pfs_stat.h:1103
Statistics for stage usage.
Definition: pfs_stat.h:322
PFS_single_stat m_stat[COUNT_PFS_TL_LOCK_TYPE]
Definition: pfs_stat.h:683
ulonglong m_current_connections
Definition: pfs_stat.h:1559
void aggregate(const PFS_stage_stat *stat)
Definition: pfs_stat.h:350
std::atomic< size_t > m_alloc_count
Definition: pfs_stat.h:1059
void fast_reset_io(void)
Definition: pfs_stat.h:743
void sum(PFS_byte_stat *stat)
Definition: pfs_stat.h:292
PFS_single_stat m_delete
DELETE statistics.
Definition: pfs_stat.h:629
void aggregate_counted()
Aggregate event count and byte count.
Definition: pfs_stat.h:159
PFS_single_stat m_timer1_stat
Definition: pfs_stat.h:376
PFS_transaction_stat()
Definition: pfs_stat.h:441
ulonglong m_rollback_to_savepoint_count
Definition: pfs_stat.h:438
void aggregate_no_check(const PFS_single_stat *stat)
Definition: pfs_stat.h:90
void cleanup(PFS_builtin_memory_class *memory_class)
Definition: pfs_stat.h:565
PFS_byte_stat m_misc
Miscellaneous statistics.
Definition: pfs_stat.h:819
ulonglong m_min
Minimum value.
Definition: pfs_stat.h:57
#define MY_ZEROFILL
Definition: my_memory.cc:43
void aggregate_io(const PFS_table_stat *stat, uint key_count)
Definition: pfs_stat.h:755
PFS_single_stat m_timer1_stat
Definition: pfs_stat.h:340
void aggregate(const PFS_file_stat *stat)
Definition: pfs_stat.h:313
void aggregate_value(ulonglong value)
Definition: pfs_stat.h:363
ulonglong m_select_range
Definition: pfs_stat.h:387
void aggregate_counted()
Definition: pfs_stat.h:344
ulonglong m_warning_count
Definition: pfs_stat.h:378
PFS_single_stat m_timer1_stat
Definition: pfs_stat.h:357
void reset(void)
Reset socket statistics.
Definition: pfs_stat.h:854
ulonglong m_first_seen
First and last seen timestamps.
Definition: pfs_stat.h:473
PFS_file_io_stat m_io_stat
File I/O statistics.
Definition: pfs_stat.h:311
Statistics for transaction usage.
Definition: pfs_stat.h:433
void aggregate(const PFS_socket_io_stat *stat)
Definition: pfs_stat.h:827
void reset(void)
Definition: pfs_stat.h:68
Definition: pfs_stat.h:676
std::atomic< size_t > m_alloc_size
Definition: pfs_stat.h:1061
void aggregate(const PFS_error_single_stat *stat)
Definition: pfs_stat.h:513
const string value("\alue\)
Definition: pfs_stat.h:668
void reset(void)
Definition: pfs_stat.h:1406
ulonglong m_sort_merge_passes
Definition: pfs_stat.h:390
Definition: pfs_stat.h:857
void aggregate(ulonglong wait, ulonglong bytes)
Aggregate individual wait time, event count and byte count.
Definition: pfs_stat.h:148
PFS_error_single_stat()
Definition: pfs_stat.h:476
void reset(void)
Definition: pfs_stat.h:451
ulonglong m_rows_affected
Definition: pfs_stat.h:379
#define PFS_FREE_ARRAY(k, n, s, p)
Helper, to free an array of structures.
Definition: pfs_global.h:137
PFS_memory_stat_delta * count_alloc(size_t size, PFS_memory_stat_delta *delta)
Definition: pfs_stat.h:1440
void aggregate(const PFS_byte_stat *stat)
Aggregate wait stats, event count and byte count.
Definition: pfs_stat.h:134
size_t m_alloc_size_delta
Definition: pfs_stat.h:860
PFS_memory_stat_delta * count_free(size_t size, PFS_memory_stat_delta *delta)
Definition: pfs_stat.h:1518
std::atomic< size_t > m_free_count_capacity
Definition: pfs_stat.h:1065
PFS_single_stat m_wait_stat
Wait statistics.
Definition: pfs_stat.h:239
void reset(void)
Definition: pfs_stat.h:169
PFS_single_stat m_wait_stat
Wait statistics.
Definition: pfs_stat.h:205
void aggregate_count(int error_index, int error_operation)
Definition: pfs_stat.h:585
Combined statistic.
Definition: pfs_stat.h:129
size_t m_alloc_size_capacity
Definition: pfs_stat.h:1403
size_t m_max_errors
The number of errors, including +1 for the NULL row.
Definition: pfs_stat.h:533
Definition: pfs_stat.h:670
ulonglong m_handled_count
Definition: pfs_stat.h:471
PFS_single_stat m_read_only_stat
Definition: pfs_stat.h:435
void init(PFS_builtin_memory_class *memory_class, size_t max_errors)
Definition: pfs_stat.h:552
void aggregate_counted()
Definition: pfs_stat.h:101
ulonglong count(uint error_index)
Definition: pfs_stat.h:550
PFS_byte_stat m_read
READ statistics.
Definition: pfs_stat.h:815
Dialog Client Authentication nullptr
Definition: dialog.cc:353
void aggregate(const PFS_table_stat *stat, uint key_count)
Definition: pfs_stat.h:780
PFS_memory_stat_delta * count_realloc(size_t old_size, size_t new_size, PFS_memory_stat_delta *delta)
Definition: pfs_stat.h:1233
ulonglong m_savepoint_count
Definition: pfs_stat.h:437
void aggregate(const PFS_statement_stat *stat)
Definition: pfs_stat.h:405
bool m_used
Definition: pfs_stat.h:1395