summaryrefslogtreecommitdiff
path: root/dist/stat.py
diff options
context:
space:
mode:
authorKeith Bostic <keith@wiredtiger.com>2013-04-30 19:57:37 -0400
committerKeith Bostic <keith@wiredtiger.com>2013-04-30 19:57:37 -0400
commit9213cc4af1d221abf233d35c62bf5e740786f9f7 (patch)
tree5b8030c196d899106b4c44f1479515017bb8a299 /dist/stat.py
parent859482f76151cdc3571a166159464356a7030c93 (diff)
downloadmongo-9213cc4af1d221abf233d35c62bf5e740786f9f7.tar.gz
Add support for aggregating data-source statistics, currently only
used by the LSM tree. Add support for automatically updating the list of statistics that are to be "scaled per second" by statlog.py.
Diffstat (limited to 'dist/stat.py')
-rw-r--r--dist/stat.py58
1 files changed, 55 insertions, 3 deletions
diff --git a/dist/stat.py b/dist/stat.py
index dfeaef82935..0c6c912e533 100644
--- a/dist/stat.py
+++ b/dist/stat.py
@@ -112,12 +112,37 @@ __wt_stat_clear_''' + name + '''_stats(void *stats_arg)
\tstats = (WT_''' + name.upper() + '''_STATS *)stats_arg;
''')
for l in sorted(list):
- # Items marked permanent aren't cleared by the stat clear
- # methods.
- if not l.flags.get('perm', 0):
+ # noclear: don't clear the value.
+ if not 'noclear' in l.flags:
f.write('\tstats->' + l.name + '.v = 0;\n');
f.write('}\n')
+ # Aggregation is only interesting for data-source statistics.
+ if name == 'connection':
+ return;
+
+ f.write('''
+void
+__wt_stat_aggregate_''' + name + '''_stats(void *child, void *parent)
+{
+\tWT_''' + name.upper() + '''_STATS *c, *p;
+
+\tc = (WT_''' + name.upper() + '''_STATS *)child;
+\tp = (WT_''' + name.upper() + '''_STATS *)parent;
+''')
+ for l in sorted(list):
+ if 'aggrignore' in l.flags:
+ continue;
+ elif 'aggrmax' in l.flags:
+ o = 'if (c->' + l.name + '.v > p->' + l.name +\
+ '.v)\n\t p->' + l.name + '.v = c->' + l.name + '.v;'
+ elif 'aggrset' in l.flags:
+ o = 'p->' + l.name + '.v += c->' + l.name + '.v;'
+ else:
+ o = 'p->' + l.name + '.v += c->' + l.name + '.v;'
+ f.write('\t' + o + '\n')
+ f.write('}\n')
+
# Write the stat initialization and clear routines to the stat.c file.
f = open(tmp_file, 'w')
f.write('/* DO NOT EDIT: automatically built by dist/stat.py. */\n\n')
@@ -127,3 +152,30 @@ print_func('dsrc', dsrc_stats)
print_func('connection', connection_stats)
f.close()
compare_srcfile(tmp_file, '../src/support/stat.c')
+
+
+# Update the statlog file with the entries we can scale per second.
+sps_info = 'scale_per_second_list = [\n'
+for l in sorted(connection_stats):
+ if 'sps' in l.flags:
+ sps_info += ' \'' + l.desc + '\',\n'
+for l in sorted(dsrc_stats):
+ if 'sps' in l.flags:
+ sps_info += ' \'' + l.desc + '\',\n'
+sps_info += ']\n'
+
+tmp_file = '__tmp'
+tfile = open(tmp_file, 'w')
+skip = 0
+for line in open('../tools/statlog.py', 'r'):
+ if skip:
+ if line.count('scale-per-second list section: END'):
+ tfile.write(line)
+ skip = 0
+ else:
+ tfile.write(line)
+ if line.count('scale-per-second list section: BEGIN'):
+ skip = 1
+ tfile.write(sps_info)
+tfile.close()
+compare_srcfile(tmp_file, '../tools/statlog.py')