1 /*- 2 * See the file LICENSE for redistribution information. 3 * 4 * Copyright (c) 2010, 2013 Oracle and/or its affiliates. All rights reserved. 5 * 6 * $Id$ 7 */ 8 9 #ifndef _DB_PERFMON_H_ 10 #define _DB_PERFMON_H_ 11 12 /******************************************************* 13 * Oracle Berkeley DB Performance Event Monitoring 14 * 15 * Some events inside of Oracle Berkeley DB can be 'published' 16 * to the operating environment's performance tracing system 17 * as they occur. Current support includes 18 * --enable-dtrace 19 * Solaris 20 * Linux (via SystemTap's dtrace wrappers) 21 * Darwin (Mac OS X) 22 * QNX(?) 23 * 24 ******************************************************/ 25 26 /* 27 * The performance monitoring system can display many of the statistics which 28 * are obtainable through the {DB,DB_ENV}->xxx_stat() functions. By default 29 * they are excluded. They can be enabled with --enable-perfmon-statistics. 30 */ 31 #ifdef HAVE_PERFMON_STATISTICS 32 #define STAT_PERFMON1(env, cat, id, a1) PERFMON1(env, cat, id, (a1)) 33 #define STAT_PERFMON2(env, cat, id, a1, a2) \ 34 PERFMON2(env, cat, id, (a1), (a2)) 35 #define STAT_PERFMON3(env, cat, id, a1, a2, a3) \ 36 PERFMON3(env, cat, id, (a1), (a2), (a3)) 37 #else 38 #define STAT_PERFMON1(env, cat, id, a1) NOP_STATEMENT 39 #define STAT_PERFMON2(env, cat, id, a1, a2) NOP_STATEMENT 40 #define STAT_PERFMON3(env, cat, id, a1, a2, a3) NOP_STATEMENT 41 #endif 42 43 44 #if defined(HAVE_PERFMON) && defined(HAVE_STATISTICS) 45 /* 46 * The DTrace macros which are generated at configure time in db_provider.h can 47 * have full function signatures. These declarations are needed for compilation 48 * when DTrace support is enabled. It is "too early" in the include sequence 49 * to include the header files which define these structs. 50 */ 51 struct _db_page; 52 struct __bh; 53 struct __db_dbt; 54 struct __sh_dbt; 55 struct __db_mutex_t; 56 57 #if defined(HAVE_DTRACE) 58 /* 59 * Solaris 10, Darwin/Mac OS X starting in 10.6 (Snow Leopard), Linux with 60 * the DTrace-compatible version of SystemTap, possibly QNX. 61 */ 62 #include "db_provider.h" 63 64 #define PERFMON0(env, cat, id) bdb_##cat##_##id() 65 #define PERFMON1(env, cat, id, a1) bdb_##cat##_##id(a1) 66 #define PERFMON2(env, cat, id, a1, a2) \ 67 bdb_##cat##_##id((a1), (a2)) 68 #define PERFMON3(env, cat, id, a1, a2, a3) \ 69 do { \ 70 if (PERFMON_ENABLED(env, cat, id)) \ 71 bdb_##cat##_##id((a1), (a2), (a3)); \ 72 } while (0) 73 #define PERFMON4(env, cat, id, a1, a2, a3, a4) \ 74 do { \ 75 if (PERFMON_ENABLED(env, cat, id)) \ 76 bdb_##cat##_##id((a1), (a2), (a3), (a4)); \ 77 } while (0) 78 #define PERFMON5(env, cat, id, a1, a2, a3, a4, a5) \ 79 do { \ 80 if (PERFMON_ENABLED(env, cat, id)) \ 81 bdb_##cat##_##id((a1), (a2), (a3), (a4), (a5)); \ 82 } while (0) 83 #define PERFMON6(env, cat, id, a1, a2, a3, a4, a5, a6) \ 84 do { \ 85 if (PERFMON_ENABLED(env, cat, id)) \ 86 bdb_##cat##_##id((a1), (a2), (a3), (a4), (a5), (a6)); \ 87 } while (0) 88 #define PERFMON_ENABLED(env, cat, id) bdb_##cat##_##id##_enabled() 89 #endif 90 91 #else 92 /* Without HAVE_PERFMON or HAVE_STATISTICS these macros map to null bodies. */ 93 #define PERFMON0(env, cat, id) NOP_STATEMENT 94 #define PERFMON1(env, cat, id, a1) NOP_STATEMENT 95 #define PERFMON2(env, cat, id, a1, a2) NOP_STATEMENT 96 #define PERFMON3(env, cat, id, a1, a2, a3) NOP_STATEMENT 97 #define PERFMON4(env, cat, id, a1, a2, a3, a4) NOP_STATEMENT 98 #define PERFMON5(env, cat, id, a1, a2, a3, a4, a5) NOP_STATEMENT 99 #define PERFMON6(env, cat, id, a1, a2, a3, a4, a5, a6) NOP_STATEMENT 100 #define PERFMON_ENABLED(env, cat, id) FALSE 101 #endif 102 103 #endif 104