view src/dbinc/perfmon.h @ 0:a1985f14b030

Initial load
author chegar
date Fri, 11 May 2012 10:42:02 +0100
parents
children
line wrap: on
line source

/*-
 * See the file LICENSE for redistribution information.
 *
 * Copyright (c) 2010, 2012 Oracle and/or its affiliates.  All rights reserved.
 *
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This code is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 only, as
 * published by the Free Software Foundation.  Oracle designates this
 * particular file as subject to the "Classpath" exception as provided
 * by Oracle in the LICENSE file that accompanied this code.
 *
 * This code is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * version 2 for more details (a copy is included in the LICENSE file that
 * accompanied this code).
 *
 * You should have received a copy of the GNU General Public License version
 * 2 along with this work; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 * or visit www.oracle.com if you need additional information or have any
 * questions.
 *
 * $Id$
 */

#ifndef _DB_PERFMON_H_
#define	_DB_PERFMON_H_

/*******************************************************
 * Oracle Berkeley DB Performance Event Monitoring
 *
 * Some events inside of Oracle Berkeley DB can be 'published'
 * to the operating environment's performance tracing system
 * as they occur. Current support includes
 *	--enable-dtrace
 *		Solaris
 *		Linux (via SystemTap's dtrace wrappers)
 *		Darwin (Mac OS X)
 *		QNX(?)  
 *
 ******************************************************/

/*
 * The performance monitoring system can display many of the statistics which
 * are obtainable through the {DB,DB_ENV}->xxx_stat() functions. By default
 * they are excluded. They can be enabled with --enable-perfmon-statistics.
 */
#ifdef HAVE_PERFMON_STATISTICS
#define STAT_PERFMON1(env, cat, id, a1)		PERFMON1(env, cat, id, (a1))
#define STAT_PERFMON2(env, cat, id, a1, a2) 	\
    PERFMON2(env, cat, id, (a1), (a2))
#define STAT_PERFMON3(env, cat, id, a1, a2, a3)	\
    PERFMON3(env, cat, id, (a1), (a2), (a3))
#else
#define STAT_PERFMON1(env, cat, id, a1)		NOP_STATEMENT
#define STAT_PERFMON2(env, cat, id, a1, a2)	NOP_STATEMENT
#define STAT_PERFMON3(env, cat, id, a1, a2, a3)	NOP_STATEMENT
#endif


#if defined(HAVE_PERFMON) && defined(HAVE_STATISTICS)
/*
 * The DTrace macros which are generated at configure time in db_provider.h can
 * have full function signatures. These declarations are needed for compilation
 * when DTrace support is enabled. It is "too early" in the include sequence
 * to include the header files which define these structs.
 */
struct _db_page;
struct __bh;
struct __db_dbt;
struct __sh_dbt;
struct __db_mutex_t;

#if defined(HAVE_DTRACE)
/*
 * Solaris 10, Darwin/Mac OS X starting in 10.6 (Snow Leopard), Linux with
 * the DTrace-compatible version of SystemTap, possibly QNX.
 */
#include "db_provider.h"

#define PERFMON0(env, cat, id)		bdb_##cat##_##id()
#define PERFMON1(env, cat, id, a1)	bdb_##cat##_##id(a1)
#define PERFMON2(env, cat, id, a1, a2)					\
    bdb_##cat##_##id((a1), (a2))
#define PERFMON3(env, cat, id, a1, a2, a3)				\
    do {								\
    	if (PERFMON_ENABLED(env, cat, id))				\
	    bdb_##cat##_##id((a1), (a2), (a3));			\
    } while (0)
#define PERFMON4(env, cat, id, a1, a2, a3, a4)				\
    do {								\
    	if (PERFMON_ENABLED(env, cat, id))				\
	    bdb_##cat##_##id((a1), (a2), (a3), (a4));			\
    } while (0)
#define PERFMON5(env, cat, id, a1, a2, a3, a4, a5)			\
    do {								\
    	if (PERFMON_ENABLED(env, cat, id))				\
	    bdb_##cat##_##id((a1), (a2), (a3), (a4), (a5));		\
    } while (0)
#define PERFMON6(env, cat, id, a1, a2, a3, a4, a5, a6)			\
    do {								\
    	if (PERFMON_ENABLED(env, cat, id))				\
	    bdb_##cat##_##id((a1), (a2), (a3), (a4), (a5), (a6));	\
    } while (0)
#define PERFMON_ENABLED(env, cat, id)	 bdb_##cat##_##id##_enabled()
#endif

#else
/* Without HAVE_PERFMON or HAVE_STATISTICS these macros map to null bodies. */
#define PERFMON0(env, cat, id)				NOP_STATEMENT
#define PERFMON1(env, cat, id, a1)			NOP_STATEMENT
#define PERFMON2(env, cat, id, a1, a2)			NOP_STATEMENT
#define PERFMON3(env, cat, id, a1, a2, a3)		NOP_STATEMENT
#define PERFMON4(env, cat, id, a1, a2, a3, a4)		NOP_STATEMENT
#define PERFMON5(env, cat, id, a1, a2, a3, a4, a5)	NOP_STATEMENT
#define PERFMON6(env, cat, id, a1, a2, a3, a4, a5, a6)	NOP_STATEMENT
#define PERFMON_ENABLED(env, cat, id)	 		FALSE
#endif

#endif