summaryrefslogtreecommitdiff
path: root/dist
diff options
context:
space:
mode:
authorKeith Bostic <keith@wiredtiger.com>2010-04-07 01:39:31 +1000
committerKeith Bostic <keith@wiredtiger.com>2010-04-07 01:39:31 +1000
commit8c6b3f9b51df84a97427d3cf714b190781b03f0c (patch)
tree494587129959787ba6622eebccc574366ba950fa /dist
parentf4e3e23ba17a473655b5ed695bd39c2394de4566 (diff)
downloadmongo-8c6b3f9b51df84a97427d3cf714b190781b03f0c.tar.gz
Add statistics for every method call so we can track them.
--HG-- branch : keith
Diffstat (limited to 'dist')
-rw-r--r--dist/api.py27
-rw-r--r--dist/stat.py32
2 files changed, 44 insertions, 15 deletions
diff --git a/dist/api.py b/dist/api.py
index d02a46ce6d9..e2be653b236 100644
--- a/dist/api.py
+++ b/dist/api.py
@@ -171,12 +171,13 @@ def func_method_getset(a, f):
# return value.
if handle != 'env':
f.write('\tENV *env = ' + handle + '->env;\n')
+ f.write('\tIENV *ienv = env->ienv;\n')
if handcode:
f.write('\tint ret;\n')
if handle != 'env' or handcode:
f.write('\n')
- # If we have a "flags" argument to a setter fucntion, check it
+ # If we have a "flags" argument to a setter function, check it
# before we continue.
if config.count('setter'):
for l in args:
@@ -198,10 +199,15 @@ def func_method_getset(a, f):
for l in args:
s += ', ' + l.split('/')[0]
s += ')'
- f.write(s + '));\n\n')
+ f.write(s + '));\n')
# getter/setter implies ienvlock: lock the data structure.
- f.write('\t__wt_lock(env, env->ienv->mtx);\n')
+ f.write('\t__wt_lock(env, ienv->mtx);\n')
+
+ # Count the call.
+ s = a.handle + '_' + a.method
+ f.write(
+ '\tWT_STAT_INCR(ienv->method_stats, ' + s.upper() + ');\n')
# If the function is hand-coded, just call it.
if handcode:
@@ -224,7 +230,7 @@ def func_method_getset(a, f):
l.split('/')[0] + ' = ' + l.split('/')[0] + ';\n')
# getter/setter implies ienvlock: unlock the data structure.
- f.write('\t__wt_unlock(env->ienv->mtx);\n')
+ f.write('\t__wt_unlock(ienv->mtx);\n')
f.write('\treturn (')
if handcode:
f.write('ret')
@@ -262,22 +268,27 @@ def func_method(a, f):
handle.upper() + '.' + method + '";\n')
if (flagchk or locking) and handle != 'env':
f.write('\tENV *env = ' + handle + '->env;\n')
+ f.write('\tIENV *ienv = env->ienv;\n')
f.write('\tint ret;\n\n')
if flagchk:
f.write('\tWT_ENV_FCHK(env, method_name, flags, WT_APIMASK_' +
- handle.upper() + '_' + method.upper() + ');\n\n')
+ handle.upper() + '_' + method.upper() + ');\n')
# If the method is illegal for read-only databases, check that.
if rdonly:
- f.write('\tWT_DB_RDONLY(db, method_name);\n\n')
+ f.write('\tWT_DB_RDONLY(db, method_name);\n')
# If entering the API with a WT_TOC handle, set the generation number.
if toc_handle:
f.write('\tWT_TOC_SET_GEN(toc);\n')
if locking:
- f.write('\t__wt_lock(env, env->ienv->mtx);\n')
+ f.write('\t__wt_lock(env, ienv->mtx);\n')
+
+ # Count the call.
+ s = a.handle + '_' + a.method
+ f.write('\tWT_STAT_INCR(ienv->method_stats, ' + s.upper() + ');\n')
f.write('\t')
if restart:
@@ -292,7 +303,7 @@ def func_method(a, f):
else:
f.write(');\n')
if locking:
- f.write('\t__wt_unlock(env->ienv->mtx);\n')
+ f.write('\t__wt_unlock(ienv->mtx);\n')
# If entering the API with a WT_TOC handle, clear the generation number.
if toc_handle:
f.write('\tWT_TOC_CLR_GEN(toc);\n')
diff --git a/dist/stat.py b/dist/stat.py
index 1af65a8b78f..8ea51f18175 100644
--- a/dist/stat.py
+++ b/dist/stat.py
@@ -14,9 +14,22 @@ from dist import source_paths_list
# Read the source files and build a dictionary of handles and stat counters.
import stat_class
+class Stat:
+ def __init__(self, config, str):
+ self.config = config
+ self.str = str
+
+# method_stats --
+# Read the API class, and create statistics entries for each method.
+method_stats = {}
+import api_class
+api = api_class.methods
+for i in sorted(api.iteritems()):
+ method_stats[i[0].replace('.', '_').upper()] = Stat([], i[0])
+
# print_def --
# Print the #defines for the stat.h file.
-def print_def(title, handle, list):
+def print_def(title, list):
def_cnt = 0
f.write('/*\n')
f.write(' * Statistics entries for ' + title + '.\n')
@@ -24,7 +37,7 @@ def print_def(title, handle, list):
for l in sorted(list.iteritems()):
n = 'WT_STAT_' + l[0]
f.write('#define\t' + n +
- "\t" * max(1, 4 - len(n) / 8) + "%5d" % def_cnt + '\n')
+ "\t" * max(1, 5 - len(n) / 8) + "%5d" % def_cnt + '\n')
def_cnt += 1
f.write('\n')
@@ -41,11 +54,12 @@ for line in open('../inc_posix/stat.h', 'r'):
elif line.count('Statistics section: BEGIN'):
f.write('\n')
skip = 1
- print_def('CACHE handle', 'CACHE', stat_class.cache_stats)
- print_def('DB/IDB database', 'DATABASE', stat_class.idb_dstats)
- print_def('DB/IDB handle', 'DB', stat_class.idb_stats)
- print_def('ENV/IENV handle', 'ENV', stat_class.ienv_stats)
- print_def('FH handle', 'FH', stat_class.fh_stats)
+ print_def('CACHE handle', stat_class.cache_stats)
+ print_def('DB/IDB database', stat_class.idb_dstats)
+ print_def('DB/IDB handle', stat_class.idb_stats)
+ print_def('ENV/IENV handle', stat_class.ienv_stats)
+ print_def('FH handle', stat_class.fh_stats)
+ print_def('Methods', method_stats)
f.close()
compare_srcfile(tmp_file, '../inc_posix/stat.h')
@@ -87,10 +101,14 @@ def print_func(handle, list):
f = open(tmp_file, 'w')
f.write('/* DO NOT EDIT: automatically built by dist/stat.py. */\n\n')
f.write('#include "wt_internal.h"\n')
+
print_func('CACHE', stat_class.cache_stats)
print_func('DATABASE', stat_class.idb_dstats)
print_func('DB', stat_class.idb_stats)
print_func('ENV', stat_class.ienv_stats)
print_func('FH', stat_class.fh_stats)
+print_func('METHOD', method_stats)
+
f.close()
+
compare_srcfile(tmp_file, '../support/stat.c')