diff options
author | Michael Cahill <michael.cahill@wiredtiger.com> | 2012-11-16 21:02:27 +1100 |
---|---|---|
committer | Michael Cahill <michael.cahill@wiredtiger.com> | 2012-11-16 21:02:27 +1100 |
commit | 3bdf27747a59f4af52244ddc519932de9e2ad6d4 (patch) | |
tree | 3baaece5ed8a7a7368868e0ac58f1ca4d8e7b795 | |
parent | c7258fd32736db32a01981c12625213d0b865310 (diff) | |
download | mongo-3bdf27747a59f4af52244ddc519932de9e2ad6d4.tar.gz |
Add a "size of checkpoint" statistic.
Merge statistics from file and LSM sources into a "data source" statistic structure. Rename and regroup some shared stastistics. Make statistics constant names upper case. Add a helper to the Python API to lookup in a cursor in a simple expression.
closes #232
-rw-r--r-- | dist/s_string.ok | 1 | ||||
-rw-r--r-- | dist/stat.py | 74 | ||||
-rw-r--r-- | dist/stat_data.py | 125 | ||||
-rw-r--r-- | examples/c/ex_stat.c | 2 | ||||
-rw-r--r-- | lang/python/wiredtiger.i | 47 | ||||
-rw-r--r-- | src/block/block_ext.c | 6 | ||||
-rw-r--r-- | src/block/block_open.c | 1 | ||||
-rw-r--r-- | src/btree/bt_cursor.c | 8 | ||||
-rw-r--r-- | src/btree/bt_handle.c | 2 | ||||
-rw-r--r-- | src/btree/bt_stat.c | 32 | ||||
-rw-r--r-- | src/cursor/cur_stat.c | 10 | ||||
-rw-r--r-- | src/include/btree.h | 2 | ||||
-rw-r--r-- | src/include/btree.i | 2 | ||||
-rw-r--r-- | src/include/extern.h | 9 | ||||
-rw-r--r-- | src/include/lsm.h | 2 | ||||
-rw-r--r-- | src/include/stat.h | 117 | ||||
-rw-r--r-- | src/include/txn.i | 2 | ||||
-rw-r--r-- | src/include/wiredtiger.in | 290 | ||||
-rw-r--r-- | src/include/wt_internal.h | 6 | ||||
-rw-r--r-- | src/lsm/lsm_cursor.c | 10 | ||||
-rw-r--r-- | src/lsm/lsm_stat.c | 64 | ||||
-rw-r--r-- | src/lsm/lsm_tree.c | 2 | ||||
-rw-r--r-- | src/support/stat.c | 195 | ||||
-rw-r--r-- | test/suite/test_bug001.py | 10 | ||||
-rw-r--r-- | test/suite/test_checkpoint01.py | 8 | ||||
-rw-r--r-- | test/suite/test_config04.py | 7 | ||||
-rw-r--r-- | test/suite/test_cursor04.py | 8 | ||||
-rw-r--r-- | test/suite/test_cursor05.py | 4 | ||||
-rw-r--r-- | test/suite/test_stat01.py | 62 |
29 files changed, 518 insertions, 590 deletions
diff --git a/dist/s_string.ok b/dist/s_string.ok index 7e9825ef609..0e8904ca9d0 100644 --- a/dist/s_string.ok +++ b/dist/s_string.ok @@ -53,6 +53,7 @@ Config CustomersPhone DATAITEMs DESC +DSRC DUPLICATEV Decrement EB diff --git a/dist/stat.py b/dist/stat.py index bbaaa08b06c..a70c09e8a63 100644 --- a/dist/stat.py +++ b/dist/stat.py @@ -1,24 +1,20 @@ # Read the source files and output the statistics #defines and allocation code. import re, string, sys, textwrap -from operator import attrgetter from dist import compare_srcfile from dist import source_paths_list # Read the source files. -from stat_data import btree_stats, connection_stats, lsm_stats +from stat_data import dsrc_stats, connection_stats -# print_struct -- -# Print the structures for the stat.h file. -def print_struct(title, name, list): +def print_struct(title, name, stats): + '''Print the structures for the stat.h file.''' f.write('/*\n') - f.write(' * Statistics entries for ' + title + ' handle.\n') + f.write(' * Statistics entries for ' + title + '.\n') f.write(' */\n') f.write('struct __wt_' + name + '_stats {\n') - # Sort the structure fields by their description, so the eventual - # disply is sorted by string. - for l in sorted(list, key=attrgetter('desc')): + for l in stats: f.write('\tWT_STATS ' + l.name + ';\n') f.write('};\n\n') @@ -35,59 +31,41 @@ for line in open('../src/include/stat.h', 'r'): elif line.count('Statistics section: BEGIN'): f.write('\n') skip = 1 - print_struct('BTREE', 'btree', btree_stats) - print_struct('CONNECTION', 'connection', connection_stats) - print_struct('LSM', 'lsm', lsm_stats) + print_struct('data sources', 'dsrc', dsrc_stats) + print_struct('connections', 'connection', connection_stats) f.close() compare_srcfile(tmp_file, '../src/include/stat.h') -# print_define -- -# Print the #defines for the wiredtiger.in file. -def print_define(): - # Sort the structure fields by their description so they match - # the structure lists. +def print_defines(): + '''Print the #defines for the wiredtiger.in file.''' f.write(''' /*! - * @name Statistics for connection handles + * @name Connection statistics * @anchor statistics_keys * @anchor statistics_conn - * Statistics in WiredTiger are accessed through cursors with \c "statistics:" - * URIs. Individual statistics can be queried through the cursor using the - * following keys. + * Statistics are accessed through cursors with \c "statistics:" URIs. + * Individual statistics can be queried through the cursor using the following + * keys. * @{ */ ''') - for v, l in enumerate(sorted(connection_stats, key=attrgetter('desc'))): + for v, l in enumerate(connection_stats): f.write('/*! %s */\n' % '\n * '.join(textwrap.wrap(l.desc, 70))) - f.write('#define\tWT_STAT_' + l.name + "\t" * - max(1, 6 - int((len('WT_STAT_') + len(l.name)) / 8)) + + f.write('#define\tWT_STAT_CONN_' + l.name.upper() + "\t" * + max(1, 6 - int((len('WT_STAT_CONN_' + l.name)) / 8)) + str(v) + '\n') f.write(''' /*! * @} - * @name Statistics for file objects - * @anchor statistics_file + * @name Statistics for data sources + * @anchor statistics_dsrc * @{ */ ''') - for v, l in enumerate(sorted(btree_stats, key=attrgetter('desc'))): + for v, l in enumerate(dsrc_stats): f.write('/*! %s */\n' % '\n * '.join(textwrap.wrap(l.desc, 70))) - f.write('#define\tWT_STAT_' + l.name + "\t" * - max(1, 6 - int((len('WT_STAT_') + len(l.name)) / 8)) + - str(v) + '\n') - f.write('/*! @} */\n') - f.write(''' -/*! - * @} - * @name Statistics for lsm objects - * @anchor statistics_lsm - * @{ - */ -''') - for v, l in enumerate(sorted(lsm_stats, key=attrgetter('desc'))): - f.write('/*! %s */\n' % '\n * '.join(textwrap.wrap(l.desc, 70))) - f.write('#define\tWT_STAT_' + l.name + "\t" * - max(1, 6 - int((len('WT_STAT_') + len(l.name)) / 8)) + + f.write('#define\tWT_STAT_DSRC_' + l.name.upper() + "\t" * + max(1, 6 - int((len('WT_STAT_DSRC_' + l.name)) / 8)) + str(v) + '\n') f.write('/*! @} */\n') @@ -104,14 +82,13 @@ for line in open('../src/include/wiredtiger.in', 'r'): elif line.count('Statistics section: BEGIN'): f.write(' */\n') skip = 1 - print_define() + print_defines() f.write('/*\n') f.close() compare_srcfile(tmp_file, '../src/include/wiredtiger.in') -# print_func -- -# Print the functions for the stat.c file. def print_func(name, list): + '''Print the functions for the stat.c file.''' f.write(''' int __wt_stat_alloc_''' + name + '''_stats(WT_SESSION_IMPL *session, WT_''' + @@ -145,7 +122,7 @@ __wt_stat_clear_''' + name + '''_stats(WT_STATS *stats_arg) for l in sorted(list): # Items marked permanent aren't cleared by the stat clear # methods. - if not l.config.count('perm'): + if not l.flags.get('perm', 0): f.write('\tstats->' + l.name + '.v = 0;\n'); f.write('}\n') @@ -154,8 +131,7 @@ 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('btree', btree_stats) +print_func('dsrc', dsrc_stats) print_func('connection', connection_stats) -print_func('lsm', lsm_stats) f.close() compare_srcfile(tmp_file, '../src/support/stat.c') diff --git a/dist/stat_data.py b/dist/stat_data.py index f7663bd3c42..2129b72dfa9 100644 --- a/dist/stat_data.py +++ b/dist/stat_data.py @@ -5,11 +5,13 @@ # are: # perm -- Field is not cleared by the stat clear function. +from operator import attrgetter + class Stat: - def __init__(self, name, desc, config=None): + def __init__(self, name, desc, **flags): self.name = name self.desc = desc - self.config = config or [] + self.flags = flags def __cmp__(self, other): return cmp(self.name, other.name) @@ -20,14 +22,18 @@ class Stat: connection_stats = [ Stat('block_read', 'blocks read from a file'), Stat('block_write', 'blocks written to a file'), - Stat('cache_bytes_inuse', 'cache: bytes currently held in the cache', 'perm'), - Stat('cache_bytes_max', 'cache: maximum bytes configured', 'perm'), - Stat('cache_evict_hazard', 'cache: pages selected for eviction not evicted because of a hazard reference'), + Stat('cache_bytes_inuse', + 'cache: bytes currently held in the cache', perm=1), + Stat('cache_bytes_max', 'cache: maximum bytes configured', perm=1), + Stat('cache_evict_hazard', 'cache: pages selected for eviction not ' + + 'evicted because of a hazard reference'), Stat('cache_evict_internal', 'cache: internal pages evicted'), Stat('cache_evict_modified', 'cache: modified pages evicted'), - Stat('cache_evict_slow', 'cache: eviction server unable to reach eviction goal'), + Stat('cache_evict_slow', + 'cache: eviction server unable to reach eviction goal'), Stat('cache_evict_unmodified', 'cache: unmodified pages evicted'), - Stat('cache_pages_inuse', 'cache: pages currently held in the cache', 'perm'), + Stat('cache_pages_inuse', + 'cache: pages currently held in the cache', perm=1), Stat('checkpoint', 'checkpoints'), Stat('cond_wait', 'condition wait calls'), Stat('file_open', 'files currently open'), @@ -44,28 +50,28 @@ connection_stats = [ Stat('txn_rollback', 'transactions rolled-back'), ] +connection_stats = sorted(connection_stats, key=attrgetter('name')) + ########################################## -# BTREE statistics +# Data source statistics ########################################## -btree_stats = [ - Stat('alloc', 'file: block allocations'), - Stat('cursor_inserts', 'cursor-inserts'), +dsrc_stats = [ + Stat('block_alloc', 'block allocations'), + Stat('block_extend', 'block allocations required file extension'), + Stat('block_free', 'block frees'), + Stat('ckpt_size', 'checkpoint size'), + Stat('cursor_insert', 'cursor-inserts'), Stat('cursor_read', 'cursor-read'), Stat('cursor_read_near', 'cursor-read-near'), Stat('cursor_read_next', 'cursor-read-next'), Stat('cursor_read_prev', 'cursor-read-prev'), - Stat('cursor_removes', 'cursor-removes'), - Stat('cursor_resets', 'cursor-resets'), - Stat('cursor_updates', 'cursor-updates'), - Stat('extend', 'file: block allocations required file extension'), + Stat('cursor_remove', 'cursor-removes'), + Stat('cursor_reset', 'cursor-resets'), + Stat('cursor_update', 'cursor-updates'), + Stat('entries', 'total entries'), Stat('file_allocsize', 'page size allocation unit'), Stat('file_bulk_loaded', 'bulk-loaded entries'), - Stat('file_col_deleted', 'column-store deleted values'), - Stat('file_col_fix_pages', 'column-store fixed-size leaf pages'), - Stat('file_col_int_pages', 'column-store internal pages'), - Stat('file_col_var_pages', 'column-store variable-size leaf pages'), Stat('file_compact_rewrite', 'pages rewritten by compaction'), - Stat('file_entries', 'total entries'), Stat('file_fixed_len', 'fixed-record size'), Stat('file_magic', 'magic number'), Stat('file_major', 'major version number'), @@ -74,49 +80,48 @@ btree_stats = [ Stat('file_maxleafitem', 'maximum leaf page item size'), Stat('file_maxleafpage', 'maximum leaf page size'), Stat('file_minor', 'minor version number'), - Stat('file_overflow', 'overflow pages'), - Stat('file_row_int_pages', 'row-store internal pages'), - Stat('file_row_leaf_pages', 'row-store leaf pages'), - Stat('file_size', 'file: size'), - Stat('file_write_conflicts', 'write generation conflicts'), - Stat('free', 'file: block frees'), - Stat('overflow_read', 'file: overflow pages read from the file'), - Stat('overflow_value_cache', 'file: overflow values cached in memory'), - Stat('page_evict', 'file: pages evicted from the file'), - Stat('page_evict_fail', 'file: pages that were selected for eviction that could not be evicted'), - Stat('page_read', 'file: pages read from the file'), - Stat('page_write', 'file: pages written to the file'), + Stat('file_size', 'file size'), + Stat('page_col_deleted', 'column-store deleted values'), + Stat('page_col_fix', 'column-store fixed-size leaf pages'), + Stat('page_col_int', 'column-store internal pages'), + Stat('page_col_var', 'column-store variable-size leaf pages'), + Stat('page_evict', 'pages evicted from the data source'), + Stat('page_evict_fail', + 'pages that were selected for eviction that could not be evicted'), + Stat('page_read', 'pages read into cache'), + Stat('page_row_int', 'row-store internal pages'), + Stat('page_row_leaf', 'row-store leaf pages'), + Stat('page_write', 'pages written from cache'), + Stat('overflow_page', 'overflow pages'), + Stat('overflow_read', 'overflow pages read into cache'), + Stat('overflow_value_cache', 'overflow values cached in memory'), Stat('rec_dictionary', 'reconcile: dictionary match'), - Stat('rec_hazard', 'reconcile: unable to acquire hazard reference'), - Stat('rec_ovfl_key', 'reconcile: overflow key'), - Stat('rec_ovfl_value', 'reconcile: overflow value'), - Stat('rec_page_delete', 'reconcile: pages deleted'), - Stat('rec_page_merge', 'reconcile: deleted or temporary pages merged'), - Stat('rec_split_intl', 'reconcile: internal pages split'), - Stat('rec_split_leaf', 'reconcile: leaf pages split'), - Stat('rec_written', 'reconcile: pages written'), - Stat('update_conflict', 'update conflicts'), -] - + Stat('rec_hazard', 'reconciliation unable to acquire hazard reference'), + Stat('rec_ovfl_key', 'reconciliation overflow key'), + Stat('rec_ovfl_value', 'reconciliation overflow value'), + Stat('rec_page_delete', 'pages deleted'), + Stat('rec_page_merge', 'deleted or temporary pages merged'), + Stat('rec_split_intl', 'internal pages split'), + Stat('rec_split_leaf', 'leaf pages split'), + Stat('rec_written', 'pages written'), + Stat('txn_update_conflict', 'update conflicts'), + Stat('txn_write_conflict', 'write generation conflicts'), ########################################## # LSM statistics ########################################## -lsm_stats = [ - Stat('chunk_cache_evict', 'Number of pages evicted from LSM chunks'), - Stat('chunk_cache_read', 'Number of pages read into LSM chunks'), - Stat('bloom_false_positives', 'Number of bloom filter false positives'), - Stat('bloom_hits', 'Number of bloom filter hits'), - Stat('bloom_misses', 'Number of bloom filter misses'), - Stat('search_miss_no_bloom', 'Number of queries that could have benefited from a bloom filter that did not exist'), - Stat('bloom_space', 'Total space used by bloom filters'), - Stat('bloom_cache_evict', 'Number of bloom pages evicted from cache'), - Stat('bloom_cache_read', 'Number of bloom pages read into cache'), - Stat('chunk_count', 'Number of chunks in the LSM tree'), - Stat('bloom_count', 'Number of bloom filters in the LSM tree'), - Stat('cache_evict', 'Number of pages evicted from cache'), - Stat('cache_evict_fail', 'Number of pages selected for eviction that could not be evicted'), - Stat('cache_read', 'Number of pages read into cache'), - Stat('cache_write', 'Number of pages written from cache'), - Stat('generation_max', 'Highest merge generation in the LSM tree'), + Stat('bloom_false_positive', + 'Number of Bloom filter false positives'), + Stat('bloom_hit', 'Number of Bloom filter hits'), + Stat('bloom_miss', 'Number of Bloom filter misses'), + Stat('bloom_size', 'Total size of Bloom filters'), + Stat('bloom_page_evict', 'Number of Bloom pages evicted from cache'), + Stat('bloom_page_read', 'Number of Bloom pages read into cache'), + Stat('bloom_count', + 'Number of Bloom filters in the LSM tree'), + Stat('lsm_chunk_count', 'Number of chunks in the LSM tree'), + Stat('lsm_generation_max', 'Highest merge generation in the LSM tree'), + Stat('lsm_lookup_no_bloom', 'Number of queries that could have benefited ' + + 'from a Bloom filter that did not exist'), ] +dsrc_stats = sorted(dsrc_stats, key=attrgetter('name')) diff --git a/examples/c/ex_stat.c b/examples/c/ex_stat.c index 9399f45f775..6bada3d8d1c 100644 --- a/examples/c/ex_stat.c +++ b/examples/c/ex_stat.c @@ -122,7 +122,7 @@ print_overflow_pages(WT_SESSION *session) "statistics:file:access.wt", NULL, NULL, &cursor)) != 0) return (ret); - cursor->set_key(cursor, WT_STAT_file_overflow); + cursor->set_key(cursor, WT_STAT_DSRC_OVERFLOW_PAGE); ret = cursor->search(cursor); ret = cursor->get_value(cursor, &desc, &pvalue, &value); printf("%s=%s\n", desc, pvalue); diff --git a/lang/python/wiredtiger.i b/lang/python/wiredtiger.i index 163b7c9a740..7372213cb77 100644 --- a/lang/python/wiredtiger.i +++ b/lang/python/wiredtiger.i @@ -89,6 +89,7 @@ DESTRUCTOR(__wt_session, close) /* Don't require empty config strings. */ %typemap(default) const char *config { $1 = NULL; } +%typemap(default) WT_CURSOR *to_dup { $1 = NULL; } /* * Error returns other than WT_NOTFOUND generate an exception. @@ -334,7 +335,10 @@ typedef int int_void; @copydoc WT_CURSOR::get_key Returns only the first column.''' - return self.get_keys()[0] + k = self.get_keys() + if len(k) == 1: + return k[0] + return k def get_keys(self): '''get_keys(self) -> (object, ...) @@ -350,7 +354,10 @@ typedef int int_void; @copydoc WT_CURSOR::get_value Returns only the first column.''' - return self.get_values()[0] + v = self.get_values() + if len(v) == 1: + return v[0] + return v def get_values(self): '''get_values(self) -> (object, ...) @@ -362,6 +369,8 @@ typedef int int_void; '''set_key(self) -> None @copydoc WT_CURSOR::set_key''' + if len(args) == 1 and type(args[0]) == tuple: + args = args[0] if self.is_column: self._set_recno(long(args[0])) else: @@ -373,6 +382,8 @@ typedef int int_void; '''set_value(self) -> None @copydoc WT_CURSOR::set_value''' + if len(args) == 1 and type(args[0]) == tuple: + args = args[0] # Keep the Python string pinned self._value = pack(self.value_format, *args) self._set_value(self._value) @@ -383,6 +394,13 @@ typedef int int_void; if not hasattr(self, '_iterable'): self._iterable = IterableCursor(self) return self._iterable + + def __getitem__(self, key): + '''Python convenience for searching''' + self.set_key(key) + if self.search() != 0: + raise KeyError + return self.get_value() %} }; @@ -427,27 +445,30 @@ typedef int int_void; ## @} class stat: - """ a set of static defines used by statistics cursor """ - pass + '''keys for statistics cursors''' + + class conn: + '''keys for cursors on connection statistics''' + pass -class filestat: - """ a set of static defines used by statistics cursor """ - pass + class dsrc: + '''keys for cursors on data source statistics''' + pass import sys -# All names starting with 'WT_STAT_file_' are renamed to -# the wiredtiger.filestat class, those starting with 'WT_STAT_' are -# renamed to wiredtiger.stat . +# All names starting with 'WT_STAT_DSRC_' are renamed to +# the wiredtiger.stat.dsrc class, those starting with 'WT_STAT_CONN' are +# renamed to wiredtiger.stat.conn class. def _rename_with_prefix(prefix, toclass): curmodule = sys.modules[__name__] for name in dir(curmodule): if name.startswith(prefix): - shortname = name[len(prefix):] + shortname = name[len(prefix):].lower() setattr(toclass, shortname, getattr(curmodule, name)) delattr(curmodule, name) -_rename_with_prefix('WT_STAT_file_', filestat) -_rename_with_prefix('WT_STAT_', stat) +_rename_with_prefix('WT_STAT_CONN_', stat.conn) +_rename_with_prefix('WT_STAT_DSRC_', stat.dsrc) del _rename_with_prefix %} diff --git a/src/block/block_ext.c b/src/block/block_ext.c index c2596823951..c11190dcc93 100644 --- a/src/block/block_ext.c +++ b/src/block/block_ext.c @@ -386,7 +386,7 @@ __wt_block_alloc( WT_EXT *ext; WT_SIZE *szp, **sstack[WT_SKIP_MAXDEPTH]; - WT_BSTAT_INCR(session, alloc); + WT_BSTAT_INCR(session, block_alloc); if (size % block->allocsize != 0) WT_RET_MSG(session, EINVAL, "cannot allocate a block size %" PRIdMAX " that is not " @@ -474,7 +474,7 @@ __wt_block_extend( *offp = fh->file_size; fh->file_size += size; - WT_BSTAT_INCR(session, extend); + WT_BSTAT_INCR(session, block_extend); WT_VERBOSE_RET(session, block, "file extend %" PRIdMAX "B @ %" PRIdMAX, (intmax_t)size, (intmax_t)*offp); @@ -495,7 +495,7 @@ __wt_block_free(WT_SESSION_IMPL *session, uint32_t cksum, size; WT_UNUSED(addr_size); - WT_BSTAT_INCR(session, free); + WT_BSTAT_INCR(session, block_free); /* Crack the cookie. */ WT_RET(__wt_block_buffer_to_addr(block, addr, &offset, &size, &cksum)); diff --git a/src/block/block_open.c b/src/block/block_open.c index 58f8f74ad61..b43c7abcdc1 100644 --- a/src/block/block_open.c +++ b/src/block/block_open.c @@ -248,6 +248,7 @@ err: __wt_scr_free(&buf); void __wt_block_stat(WT_SESSION_IMPL *session, WT_BLOCK *block) { + WT_BSTAT_SET(session, ckpt_size, block->live.ckpt_size); WT_BSTAT_SET(session, file_size, block->fh->file_size); WT_BSTAT_SET(session, file_magic, WT_BLOCK_MAGIC); WT_BSTAT_SET(session, file_major, WT_BLOCK_MAJOR_VERSION); diff --git a/src/btree/bt_cursor.c b/src/btree/bt_cursor.c index 25d65d557a8..15a411eab0c 100644 --- a/src/btree/bt_cursor.c +++ b/src/btree/bt_cursor.c @@ -108,7 +108,7 @@ __wt_btcur_reset(WT_CURSOR_BTREE *cbt) WT_SESSION_IMPL *session; session = (WT_SESSION_IMPL *)cbt->iface.session; - WT_BSTAT_INCR(session, cursor_resets); + WT_BSTAT_INCR(session, cursor_reset); __cursor_leave(cbt); __cursor_search_clear(cbt); @@ -246,7 +246,7 @@ __wt_btcur_insert(WT_CURSOR_BTREE *cbt) btree = cbt->btree; cursor = &cbt->iface; session = (WT_SESSION_IMPL *)cursor->session; - WT_BSTAT_INCR(session, cursor_inserts); + WT_BSTAT_INCR(session, cursor_insert); if (btree->type == BTREE_ROW) WT_RET(__cursor_size_chk(session, &cursor->key)); @@ -336,7 +336,7 @@ __wt_btcur_remove(WT_CURSOR_BTREE *cbt) btree = cbt->btree; cursor = &cbt->iface; session = (WT_SESSION_IMPL *)cursor->session; - WT_BSTAT_INCR(session, cursor_removes); + WT_BSTAT_INCR(session, cursor_remove); if (btree->type == BTREE_ROW) WT_RET(__cursor_size_chk(session, &cursor->key)); @@ -398,7 +398,7 @@ __wt_btcur_update(WT_CURSOR_BTREE *cbt) btree = cbt->btree; cursor = &cbt->iface; session = (WT_SESSION_IMPL *)cursor->session; - WT_BSTAT_INCR(session, cursor_updates); + WT_BSTAT_INCR(session, cursor_update); if (btree->type == BTREE_ROW) WT_RET(__cursor_size_chk(session, &cursor->key)); diff --git a/src/btree/bt_handle.c b/src/btree/bt_handle.c index 873edb1ea8f..64e692d1cbb 100644 --- a/src/btree/bt_handle.c +++ b/src/btree/bt_handle.c @@ -260,7 +260,7 @@ __btree_conf(WT_SESSION_IMPL *session, const char *cfg[]) WT_RET(__wt_rwlock_alloc( session, "btree overflow lock", &btree->val_ovfl_lock)); - WT_RET(__wt_stat_alloc_btree_stats(session, &btree->stats)); + WT_RET(__wt_stat_alloc_dsrc_stats(session, &btree->stats)); /* The tree has not been modified. */ btree->modified = 0; diff --git a/src/btree/bt_stat.c b/src/btree/bt_stat.c index c9ea8c84869..d8a4d95e33a 100644 --- a/src/btree/bt_stat.c +++ b/src/btree/bt_stat.c @@ -55,22 +55,22 @@ __stat_page(WT_SESSION_IMPL *session, WT_PAGE *page) */ switch (page->type) { case WT_PAGE_COL_FIX: - WT_BSTAT_INCR(session, file_col_fix_pages); - WT_BSTAT_INCRV(session, file_entries, page->entries); + WT_BSTAT_INCR(session, page_col_fix); + WT_BSTAT_INCRV(session, entries, page->entries); break; case WT_PAGE_COL_INT: - WT_BSTAT_INCR(session, file_col_int_pages); - WT_BSTAT_INCRV(session, file_entries, page->entries); + WT_BSTAT_INCR(session, page_col_int); + WT_BSTAT_INCRV(session, entries, page->entries); break; case WT_PAGE_COL_VAR: WT_RET(__stat_page_col_var(session, page)); break; case WT_PAGE_OVFL: - WT_BSTAT_INCR(session, file_overflow); + WT_BSTAT_INCR(session, overflow_page); break; case WT_PAGE_ROW_INT: - WT_BSTAT_INCR(session, file_row_int_pages); - WT_BSTAT_INCRV(session, file_entries, page->entries); + WT_BSTAT_INCR(session, page_row_int); + WT_BSTAT_INCRV(session, entries, page->entries); break; case WT_PAGE_ROW_LEAF: WT_RET(__stat_page_row_leaf(session, page)); @@ -97,7 +97,7 @@ __stat_page_col_var(WT_SESSION_IMPL *session, WT_PAGE *page) unpack = &_unpack; - WT_BSTAT_INCR(session, file_col_var_pages); + WT_BSTAT_INCR(session, page_col_var); /* * Walk the page, counting regular and overflow data items, and checking @@ -109,12 +109,12 @@ __stat_page_col_var(WT_SESSION_IMPL *session, WT_PAGE *page) WT_COL_FOREACH(page, cip, i) { if ((cell = WT_COL_PTR(page, cip)) == NULL) { orig_deleted = 1; - WT_BSTAT_INCR(session, file_col_deleted); + WT_BSTAT_INCR(session, page_col_deleted); } else { orig_deleted = 0; __wt_cell_unpack(cell, unpack); WT_BSTAT_INCRV( - session, file_entries, __wt_cell_rle(unpack)); + session, entries, __wt_cell_rle(unpack)); } /* @@ -126,13 +126,13 @@ __stat_page_col_var(WT_SESSION_IMPL *session, WT_PAGE *page) if (WT_UPDATE_DELETED_ISSET(upd)) { if (orig_deleted) continue; - WT_BSTAT_INCR(session, file_col_deleted); - WT_BSTAT_DECR(session, file_entries); + WT_BSTAT_INCR(session, page_col_deleted); + WT_BSTAT_DECR(session, entries); } else { if (!orig_deleted) continue; - WT_BSTAT_DECR(session, file_col_deleted); - WT_BSTAT_INCR(session, file_entries); + WT_BSTAT_DECR(session, page_col_deleted); + WT_BSTAT_INCR(session, entries); } } } @@ -151,7 +151,7 @@ __stat_page_row_leaf(WT_SESSION_IMPL *session, WT_PAGE *page) WT_UPDATE *upd; uint32_t cnt, i; - WT_BSTAT_INCR(session, file_row_leaf_pages); + WT_BSTAT_INCR(session, page_row_leaf); /* * Stat any K/V pairs inserted into the page before the first from-disk @@ -174,7 +174,7 @@ __stat_page_row_leaf(WT_SESSION_IMPL *session, WT_PAGE *page) ++cnt; } - WT_BSTAT_INCRV(session, file_entries, cnt); + WT_BSTAT_INCRV(session, entries, cnt); return (0); } diff --git a/src/cursor/cur_stat.c b/src/cursor/cur_stat.c index a66d41d354d..e37170200ce 100644 --- a/src/cursor/cur_stat.c +++ b/src/cursor/cur_stat.c @@ -309,7 +309,7 @@ __curstat_conn_init( cst->btree = NULL; cst->notpositioned = 1; cst->stats_first = (WT_STATS *)S2C(session)->stats; - cst->stats_count = sizeof(WT_CONNECTION_STATS) / sizeof(WT_STATS); + cst->stats_count = sizeof(*S2C(session)->stats) / sizeof(WT_STATS); cst->clear_func = LF_ISSET(WT_STATISTICS_CLEAR) ? __wt_stat_clear_connection_stats : NULL; } @@ -331,9 +331,9 @@ __curstat_file_init(WT_SESSION_IMPL *session, cst->btree = btree; cst->notpositioned = 1; cst->stats_first = (WT_STATS *)session->btree->stats; - cst->stats_count = sizeof(WT_BTREE_STATS) / sizeof(WT_STATS); + cst->stats_count = sizeof(*btree->stats) / sizeof(WT_STATS); cst->clear_func = LF_ISSET(WT_STATISTICS_CLEAR) ? - __wt_stat_clear_btree_stats : NULL; + __wt_stat_clear_dsrc_stats : NULL; return (0); } @@ -359,9 +359,9 @@ __curstat_lsm_init(WT_SESSION_IMPL *session, cst->btree = NULL; cst->notpositioned = 1; cst->stats_first = (WT_STATS *)lsm_tree->stats; - cst->stats_count = sizeof(WT_LSM_STATS) / sizeof(WT_STATS); + cst->stats_count = sizeof(*lsm_tree->stats) / sizeof(WT_STATS); cst->clear_func = LF_ISSET(WT_STATISTICS_CLEAR) ? - __wt_stat_clear_lsm_stats : NULL; + __wt_stat_clear_dsrc_stats : NULL; return (0); } diff --git a/src/include/btree.h b/src/include/btree.h index 6a2de1ae509..178de6879d2 100644 --- a/src/include/btree.h +++ b/src/include/btree.h @@ -122,7 +122,7 @@ struct __wt_btree { uint64_t evict_priority; /* Relative priority of cached pages. */ volatile uint32_t lru_count; /* Count of threads in LRU eviction */ - WT_BTREE_STATS *stats; /* Btree statistics */ + WT_DSRC_STATS *stats; /* Btree statistics */ #define WT_BTREE_BULK 0x0001 /* Bulk-load handle */ #define WT_BTREE_DISCARD 0x0002 /* Discard on release */ diff --git a/src/include/btree.i b/src/include/btree.i index 7bccf1fb9d1..708ceeda548 100644 --- a/src/include/btree.i +++ b/src/include/btree.i @@ -207,7 +207,7 @@ __wt_page_write_gen_check( if (mod->write_gen == write_gen && mod->write_gen + 1 != mod->disk_gen) return (0); - WT_BSTAT_INCR(session, file_write_conflicts); + WT_BSTAT_INCR(session, txn_write_conflict); return (WT_RESTART); } diff --git a/src/include/extern.h b/src/include/extern.h index d0414f03869..09826b23a4d 100644 --- a/src/include/extern.h +++ b/src/include/extern.h @@ -1239,15 +1239,12 @@ extern void *__wt_scr_alloc_ext(WT_SESSION *wt_session, size_t size); extern void __wt_scr_free_ext(WT_SESSION *wt_session, void *p); extern void __wt_session_dump_all(WT_SESSION_IMPL *session); extern void __wt_session_dump(WT_SESSION_IMPL *session); -extern int __wt_stat_alloc_btree_stats(WT_SESSION_IMPL *session, - WT_BTREE_STATS **statsp); -extern void __wt_stat_clear_btree_stats(WT_STATS *stats_arg); +extern int __wt_stat_alloc_dsrc_stats(WT_SESSION_IMPL *session, + WT_DSRC_STATS **statsp); +extern void __wt_stat_clear_dsrc_stats(WT_STATS *stats_arg); extern int __wt_stat_alloc_connection_stats(WT_SESSION_IMPL *session, WT_CONNECTION_STATS **statsp); extern void __wt_stat_clear_connection_stats(WT_STATS *stats_arg); -extern int __wt_stat_alloc_lsm_stats(WT_SESSION_IMPL *session, - WT_LSM_STATS **statsp); -extern void __wt_stat_clear_lsm_stats(WT_STATS *stats_arg); extern int __wt_txnid_cmp(const void *v1, const void *v2); extern void __wt_txn_release_snapshot(WT_SESSION_IMPL *session); extern void __wt_txn_get_oldest(WT_SESSION_IMPL *session); diff --git a/src/include/lsm.h b/src/include/lsm.h index 4d4ee8b2326..24abc0bef1c 100644 --- a/src/include/lsm.h +++ b/src/include/lsm.h @@ -65,7 +65,7 @@ struct __wt_lsm_tree { WT_RWLOCK *rwlock; TAILQ_ENTRY(__wt_lsm_tree) q; - WT_LSM_STATS *stats; /* LSM statistics */ + WT_DSRC_STATS *stats; /* LSM statistics */ uint64_t dsk_gen; uint32_t *memsizep; diff --git a/src/include/stat.h b/src/include/stat.h index 0eea8ced061..9f8445cc5e8 100644 --- a/src/include/stat.h +++ b/src/include/stat.h @@ -68,32 +68,32 @@ struct __wt_stats { /* Statistics section: BEGIN */ /* - * Statistics entries for BTREE handle. + * Statistics entries for data sources. */ -struct __wt_btree_stats { - WT_STATS file_bulk_loaded; - WT_STATS file_col_deleted; - WT_STATS file_col_fix_pages; - WT_STATS file_col_int_pages; - WT_STATS file_col_var_pages; - WT_STATS cursor_inserts; +struct __wt_dsrc_stats { + WT_STATS block_alloc; + WT_STATS block_extend; + WT_STATS block_free; + WT_STATS bloom_count; + WT_STATS bloom_false_positive; + WT_STATS bloom_hit; + WT_STATS bloom_miss; + WT_STATS bloom_page_evict; + WT_STATS bloom_page_read; + WT_STATS bloom_size; + WT_STATS ckpt_size; + WT_STATS cursor_insert; WT_STATS cursor_read; WT_STATS cursor_read_near; WT_STATS cursor_read_next; WT_STATS cursor_read_prev; - WT_STATS cursor_removes; - WT_STATS cursor_resets; - WT_STATS cursor_updates; - WT_STATS alloc; - WT_STATS extend; - WT_STATS free; - WT_STATS overflow_read; - WT_STATS overflow_value_cache; - WT_STATS page_evict; - WT_STATS page_read; - WT_STATS page_evict_fail; - WT_STATS page_write; - WT_STATS file_size; + WT_STATS cursor_remove; + WT_STATS cursor_reset; + WT_STATS cursor_update; + WT_STATS entries; + WT_STATS file_allocsize; + WT_STATS file_bulk_loaded; + WT_STATS file_compact_rewrite; WT_STATS file_fixed_len; WT_STATS file_magic; WT_STATS file_major; @@ -102,75 +102,64 @@ struct __wt_btree_stats { WT_STATS file_maxleafitem; WT_STATS file_maxleafpage; WT_STATS file_minor; - WT_STATS file_overflow; - WT_STATS file_allocsize; - WT_STATS file_compact_rewrite; - WT_STATS rec_page_merge; + WT_STATS file_size; + WT_STATS lsm_chunk_count; + WT_STATS lsm_generation_max; + WT_STATS lsm_lookup_no_bloom; + WT_STATS overflow_page; + WT_STATS overflow_read; + WT_STATS overflow_value_cache; + WT_STATS page_col_deleted; + WT_STATS page_col_fix; + WT_STATS page_col_int; + WT_STATS page_col_var; + WT_STATS page_evict; + WT_STATS page_evict_fail; + WT_STATS page_read; + WT_STATS page_row_int; + WT_STATS page_row_leaf; + WT_STATS page_write; WT_STATS rec_dictionary; - WT_STATS rec_split_intl; - WT_STATS rec_split_leaf; + WT_STATS rec_hazard; WT_STATS rec_ovfl_key; WT_STATS rec_ovfl_value; WT_STATS rec_page_delete; + WT_STATS rec_page_merge; + WT_STATS rec_split_intl; + WT_STATS rec_split_leaf; WT_STATS rec_written; - WT_STATS rec_hazard; - WT_STATS file_row_int_pages; - WT_STATS file_row_leaf_pages; - WT_STATS file_entries; - WT_STATS update_conflict; - WT_STATS file_write_conflicts; + WT_STATS txn_update_conflict; + WT_STATS txn_write_conflict; }; /* - * Statistics entries for CONNECTION handle. + * Statistics entries for connections. */ struct __wt_connection_stats { - WT_STATS txn_ancient; WT_STATS block_read; WT_STATS block_write; WT_STATS cache_bytes_inuse; - WT_STATS cache_evict_slow; - WT_STATS cache_evict_internal; WT_STATS cache_bytes_max; - WT_STATS cache_evict_modified; - WT_STATS cache_pages_inuse; WT_STATS cache_evict_hazard; + WT_STATS cache_evict_internal; + WT_STATS cache_evict_modified; + WT_STATS cache_evict_slow; WT_STATS cache_evict_unmodified; + WT_STATS cache_pages_inuse; WT_STATS checkpoint; WT_STATS cond_wait; WT_STATS file_open; - WT_STATS rwlock_rdlock; - WT_STATS rwlock_wrlock; WT_STATS memalloc; WT_STATS memfree; + WT_STATS rwlock_rdlock; + WT_STATS rwlock_wrlock; WT_STATS total_read_io; WT_STATS total_write_io; - WT_STATS txn_fail_cache; + WT_STATS txn_ancient; WT_STATS txn_begin; WT_STATS txn_commit; + WT_STATS txn_fail_cache; WT_STATS txn_rollback; }; -/* - * Statistics entries for LSM handle. - */ -struct __wt_lsm_stats { - WT_STATS generation_max; - WT_STATS bloom_false_positives; - WT_STATS bloom_hits; - WT_STATS bloom_misses; - WT_STATS bloom_count; - WT_STATS bloom_cache_evict; - WT_STATS bloom_cache_read; - WT_STATS chunk_count; - WT_STATS chunk_cache_evict; - WT_STATS cache_evict; - WT_STATS chunk_cache_read; - WT_STATS cache_read; - WT_STATS cache_evict_fail; - WT_STATS cache_write; - WT_STATS search_miss_no_bloom; - WT_STATS bloom_space; -}; - /* Statistics section: END */ diff --git a/src/include/txn.i b/src/include/txn.i index 0f0425a5961..be58e027fe2 100644 --- a/src/include/txn.i +++ b/src/include/txn.i @@ -189,7 +189,7 @@ __wt_txn_update_check(WT_SESSION_IMPL *session, WT_UPDATE *upd) if (txn->isolation == TXN_ISO_SNAPSHOT) while (upd != NULL && !__wt_txn_visible(session, upd->txnid)) { if (upd->txnid != WT_TXN_ABORTED) { - WT_BSTAT_INCR(session, update_conflict); + WT_BSTAT_INCR(session, txn_update_conflict); return (WT_DEADLOCK); } upd = upd->next; diff --git a/src/include/wiredtiger.in b/src/include/wiredtiger.in index 05eb99be9d0..0fc9c72ab5c 100644 --- a/src/include/wiredtiger.in +++ b/src/include/wiredtiger.in @@ -1688,207 +1688,189 @@ extern int wiredtiger_extension_init(WT_SESSION *session, */ /*! - * @name Statistics for connection handles + * @name Connection statistics * @anchor statistics_keys * @anchor statistics_conn - * Statistics in WiredTiger are accessed through cursors with \c "statistics:" - * URIs. Individual statistics can be queried through the cursor using the - * following keys. + * Statistics are accessed through cursors with \c "statistics:" URIs. + * Individual statistics can be queried through the cursor using the following + * keys. * @{ */ -/*! ancient transactions */ -#define WT_STAT_txn_ancient 0 /*! blocks read from a file */ -#define WT_STAT_block_read 1 +#define WT_STAT_CONN_BLOCK_READ 0 /*! blocks written to a file */ -#define WT_STAT_block_write 2 +#define WT_STAT_CONN_BLOCK_WRITE 1 /*! cache: bytes currently held in the cache */ -#define WT_STAT_cache_bytes_inuse 3 -/*! cache: eviction server unable to reach eviction goal */ -#define WT_STAT_cache_evict_slow 4 -/*! cache: internal pages evicted */ -#define WT_STAT_cache_evict_internal 5 +#define WT_STAT_CONN_CACHE_BYTES_INUSE 2 /*! cache: maximum bytes configured */ -#define WT_STAT_cache_bytes_max 6 -/*! cache: modified pages evicted */ -#define WT_STAT_cache_evict_modified 7 -/*! cache: pages currently held in the cache */ -#define WT_STAT_cache_pages_inuse 8 +#define WT_STAT_CONN_CACHE_BYTES_MAX 3 /*! cache: pages selected for eviction not evicted because of a hazard * reference */ -#define WT_STAT_cache_evict_hazard 9 +#define WT_STAT_CONN_CACHE_EVICT_HAZARD 4 +/*! cache: internal pages evicted */ +#define WT_STAT_CONN_CACHE_EVICT_INTERNAL 5 +/*! cache: modified pages evicted */ +#define WT_STAT_CONN_CACHE_EVICT_MODIFIED 6 +/*! cache: eviction server unable to reach eviction goal */ +#define WT_STAT_CONN_CACHE_EVICT_SLOW 7 /*! cache: unmodified pages evicted */ -#define WT_STAT_cache_evict_unmodified 10 +#define WT_STAT_CONN_CACHE_EVICT_UNMODIFIED 8 +/*! cache: pages currently held in the cache */ +#define WT_STAT_CONN_CACHE_PAGES_INUSE 9 /*! checkpoints */ -#define WT_STAT_checkpoint 11 +#define WT_STAT_CONN_CHECKPOINT 10 /*! condition wait calls */ -#define WT_STAT_cond_wait 12 +#define WT_STAT_CONN_COND_WAIT 11 /*! files currently open */ -#define WT_STAT_file_open 13 -/*! rwlock readlock calls */ -#define WT_STAT_rwlock_rdlock 14 -/*! rwlock writelock calls */ -#define WT_STAT_rwlock_wrlock 15 +#define WT_STAT_CONN_FILE_OPEN 12 /*! total memory allocations */ -#define WT_STAT_memalloc 16 +#define WT_STAT_CONN_MEMALLOC 13 /*! total memory frees */ -#define WT_STAT_memfree 17 +#define WT_STAT_CONN_MEMFREE 14 +/*! rwlock readlock calls */ +#define WT_STAT_CONN_RWLOCK_RDLOCK 15 +/*! rwlock writelock calls */ +#define WT_STAT_CONN_RWLOCK_WRLOCK 16 /*! total read I/Os */ -#define WT_STAT_total_read_io 18 +#define WT_STAT_CONN_TOTAL_READ_IO 17 /*! total write I/Os */ -#define WT_STAT_total_write_io 19 -/*! transaction failures due to cache overflow */ -#define WT_STAT_txn_fail_cache 20 +#define WT_STAT_CONN_TOTAL_WRITE_IO 18 +/*! ancient transactions */ +#define WT_STAT_CONN_TXN_ANCIENT 19 /*! transactions */ -#define WT_STAT_txn_begin 21 +#define WT_STAT_CONN_TXN_BEGIN 20 /*! transactions committed */ -#define WT_STAT_txn_commit 22 +#define WT_STAT_CONN_TXN_COMMIT 21 +/*! transaction failures due to cache overflow */ +#define WT_STAT_CONN_TXN_FAIL_CACHE 22 /*! transactions rolled-back */ -#define WT_STAT_txn_rollback 23 +#define WT_STAT_CONN_TXN_ROLLBACK 23 /*! * @} - * @name Statistics for file objects - * @anchor statistics_file + * @name Statistics for data sources + * @anchor statistics_dsrc * @{ */ -/*! bulk-loaded entries */ -#define WT_STAT_file_bulk_loaded 0 -/*! column-store deleted values */ -#define WT_STAT_file_col_deleted 1 -/*! column-store fixed-size leaf pages */ -#define WT_STAT_file_col_fix_pages 2 -/*! column-store internal pages */ -#define WT_STAT_file_col_int_pages 3 -/*! column-store variable-size leaf pages */ -#define WT_STAT_file_col_var_pages 4 +/*! block allocations */ +#define WT_STAT_DSRC_BLOCK_ALLOC 0 +/*! block allocations required file extension */ +#define WT_STAT_DSRC_BLOCK_EXTEND 1 +/*! block frees */ +#define WT_STAT_DSRC_BLOCK_FREE 2 +/*! Number of Bloom filters in the LSM tree */ +#define WT_STAT_DSRC_BLOOM_COUNT 3 +/*! Number of Bloom filter false positives */ +#define WT_STAT_DSRC_BLOOM_FALSE_POSITIVE 4 +/*! Number of Bloom filter hits */ +#define WT_STAT_DSRC_BLOOM_HIT 5 +/*! Number of Bloom filter misses */ +#define WT_STAT_DSRC_BLOOM_MISS 6 +/*! Number of Bloom pages evicted from cache */ +#define WT_STAT_DSRC_BLOOM_PAGE_EVICT 7 +/*! Number of Bloom pages read into cache */ +#define WT_STAT_DSRC_BLOOM_PAGE_READ 8 +/*! Total size of Bloom filters */ +#define WT_STAT_DSRC_BLOOM_SIZE 9 +/*! checkpoint size */ +#define WT_STAT_DSRC_CKPT_SIZE 10 /*! cursor-inserts */ -#define WT_STAT_cursor_inserts 5 +#define WT_STAT_DSRC_CURSOR_INSERT 11 /*! cursor-read */ -#define WT_STAT_cursor_read 6 +#define WT_STAT_DSRC_CURSOR_READ 12 /*! cursor-read-near */ -#define WT_STAT_cursor_read_near 7 +#define WT_STAT_DSRC_CURSOR_READ_NEAR 13 /*! cursor-read-next */ -#define WT_STAT_cursor_read_next 8 +#define WT_STAT_DSRC_CURSOR_READ_NEXT 14 /*! cursor-read-prev */ -#define WT_STAT_cursor_read_prev 9 +#define WT_STAT_DSRC_CURSOR_READ_PREV 15 /*! cursor-removes */ -#define WT_STAT_cursor_removes 10 +#define WT_STAT_DSRC_CURSOR_REMOVE 16 /*! cursor-resets */ -#define WT_STAT_cursor_resets 11 +#define WT_STAT_DSRC_CURSOR_RESET 17 /*! cursor-updates */ -#define WT_STAT_cursor_updates 12 -/*! file: block allocations */ -#define WT_STAT_alloc 13 -/*! file: block allocations required file extension */ -#define WT_STAT_extend 14 -/*! file: block frees */ -#define WT_STAT_free 15 -/*! file: overflow pages read from the file */ -#define WT_STAT_overflow_read 16 -/*! file: overflow values cached in memory */ -#define WT_STAT_overflow_value_cache 17 -/*! file: pages evicted from the file */ -#define WT_STAT_page_evict 18 -/*! file: pages read from the file */ -#define WT_STAT_page_read 19 -/*! file: pages that were selected for eviction that could not be evicted */ -#define WT_STAT_page_evict_fail 20 -/*! file: pages written to the file */ -#define WT_STAT_page_write 21 -/*! file: size */ -#define WT_STAT_file_size 22 +#define WT_STAT_DSRC_CURSOR_UPDATE 18 +/*! total entries */ +#define WT_STAT_DSRC_ENTRIES 19 +/*! page size allocation unit */ +#define WT_STAT_DSRC_FILE_ALLOCSIZE 20 +/*! bulk-loaded entries */ +#define WT_STAT_DSRC_FILE_BULK_LOADED 21 +/*! pages rewritten by compaction */ +#define WT_STAT_DSRC_FILE_COMPACT_REWRITE 22 /*! fixed-record size */ -#define WT_STAT_file_fixed_len 23 +#define WT_STAT_DSRC_FILE_FIXED_LEN 23 /*! magic number */ -#define WT_STAT_file_magic 24 +#define WT_STAT_DSRC_FILE_MAGIC 24 /*! major version number */ -#define WT_STAT_file_major 25 +#define WT_STAT_DSRC_FILE_MAJOR 25 /*! maximum internal page item size */ -#define WT_STAT_file_maxintlitem 26 +#define WT_STAT_DSRC_FILE_MAXINTLITEM 26 /*! maximum internal page size */ -#define WT_STAT_file_maxintlpage 27 +#define WT_STAT_DSRC_FILE_MAXINTLPAGE 27 /*! maximum leaf page item size */ -#define WT_STAT_file_maxleafitem 28 +#define WT_STAT_DSRC_FILE_MAXLEAFITEM 28 /*! maximum leaf page size */ -#define WT_STAT_file_maxleafpage 29 +#define WT_STAT_DSRC_FILE_MAXLEAFPAGE 29 /*! minor version number */ -#define WT_STAT_file_minor 30 +#define WT_STAT_DSRC_FILE_MINOR 30 +/*! file size */ +#define WT_STAT_DSRC_FILE_SIZE 31 +/*! Number of chunks in the LSM tree */ +#define WT_STAT_DSRC_LSM_CHUNK_COUNT 32 +/*! Highest merge generation in the LSM tree */ +#define WT_STAT_DSRC_LSM_GENERATION_MAX 33 +/*! Number of queries that could have benefited from a Bloom filter that + * did not exist */ +#define WT_STAT_DSRC_LSM_LOOKUP_NO_BLOOM 34 /*! overflow pages */ -#define WT_STAT_file_overflow 31 -/*! page size allocation unit */ -#define WT_STAT_file_allocsize 32 -/*! pages rewritten by compaction */ -#define WT_STAT_file_compact_rewrite 33 -/*! reconcile: deleted or temporary pages merged */ -#define WT_STAT_rec_page_merge 34 -/*! reconcile: dictionary match */ -#define WT_STAT_rec_dictionary 35 -/*! reconcile: internal pages split */ -#define WT_STAT_rec_split_intl 36 -/*! reconcile: leaf pages split */ -#define WT_STAT_rec_split_leaf 37 -/*! reconcile: overflow key */ -#define WT_STAT_rec_ovfl_key 38 -/*! reconcile: overflow value */ -#define WT_STAT_rec_ovfl_value 39 -/*! reconcile: pages deleted */ -#define WT_STAT_rec_page_delete 40 -/*! reconcile: pages written */ -#define WT_STAT_rec_written 41 -/*! reconcile: unable to acquire hazard reference */ -#define WT_STAT_rec_hazard 42 +#define WT_STAT_DSRC_OVERFLOW_PAGE 35 +/*! overflow pages read into cache */ +#define WT_STAT_DSRC_OVERFLOW_READ 36 +/*! overflow values cached in memory */ +#define WT_STAT_DSRC_OVERFLOW_VALUE_CACHE 37 +/*! column-store deleted values */ +#define WT_STAT_DSRC_PAGE_COL_DELETED 38 +/*! column-store fixed-size leaf pages */ +#define WT_STAT_DSRC_PAGE_COL_FIX 39 +/*! column-store internal pages */ +#define WT_STAT_DSRC_PAGE_COL_INT 40 +/*! column-store variable-size leaf pages */ +#define WT_STAT_DSRC_PAGE_COL_VAR 41 +/*! pages evicted from the data source */ +#define WT_STAT_DSRC_PAGE_EVICT 42 +/*! pages that were selected for eviction that could not be evicted */ +#define WT_STAT_DSRC_PAGE_EVICT_FAIL 43 +/*! pages read into cache */ +#define WT_STAT_DSRC_PAGE_READ 44 /*! row-store internal pages */ -#define WT_STAT_file_row_int_pages 43 +#define WT_STAT_DSRC_PAGE_ROW_INT 45 /*! row-store leaf pages */ -#define WT_STAT_file_row_leaf_pages 44 -/*! total entries */ -#define WT_STAT_file_entries 45 +#define WT_STAT_DSRC_PAGE_ROW_LEAF 46 +/*! pages written from cache */ +#define WT_STAT_DSRC_PAGE_WRITE 47 +/*! reconcile: dictionary match */ +#define WT_STAT_DSRC_REC_DICTIONARY 48 +/*! reconciliation unable to acquire hazard reference */ +#define WT_STAT_DSRC_REC_HAZARD 49 +/*! reconciliation overflow key */ +#define WT_STAT_DSRC_REC_OVFL_KEY 50 +/*! reconciliation overflow value */ +#define WT_STAT_DSRC_REC_OVFL_VALUE 51 +/*! pages deleted */ +#define WT_STAT_DSRC_REC_PAGE_DELETE 52 +/*! deleted or temporary pages merged */ +#define WT_STAT_DSRC_REC_PAGE_MERGE 53 +/*! internal pages split */ +#define WT_STAT_DSRC_REC_SPLIT_INTL 54 +/*! leaf pages split */ +#define WT_STAT_DSRC_REC_SPLIT_LEAF 55 +/*! pages written */ +#define WT_STAT_DSRC_REC_WRITTEN 56 /*! update conflicts */ -#define WT_STAT_update_conflict 46 +#define WT_STAT_DSRC_TXN_UPDATE_CONFLICT 57 /*! write generation conflicts */ -#define WT_STAT_file_write_conflicts 47 -/*! @} */ - -/*! - * @} - * @name Statistics for lsm objects - * @anchor statistics_lsm - * @{ - */ -/*! Highest merge generation in the LSM tree */ -#define WT_STAT_generation_max 0 -/*! Number of bloom filter false positives */ -#define WT_STAT_bloom_false_positives 1 -/*! Number of bloom filter hits */ -#define WT_STAT_bloom_hits 2 -/*! Number of bloom filter misses */ -#define WT_STAT_bloom_misses 3 -/*! Number of bloom filters in the LSM tree */ -#define WT_STAT_bloom_count 4 -/*! Number of bloom pages evicted from cache */ -#define WT_STAT_bloom_cache_evict 5 -/*! Number of bloom pages read into cache */ -#define WT_STAT_bloom_cache_read 6 -/*! Number of chunks in the LSM tree */ -#define WT_STAT_chunk_count 7 -/*! Number of pages evicted from LSM chunks */ -#define WT_STAT_chunk_cache_evict 8 -/*! Number of pages evicted from cache */ -#define WT_STAT_cache_evict 9 -/*! Number of pages read into LSM chunks */ -#define WT_STAT_chunk_cache_read 10 -/*! Number of pages read into cache */ -#define WT_STAT_cache_read 11 -/*! Number of pages selected for eviction that could not be evicted */ -#define WT_STAT_cache_evict_fail 12 -/*! Number of pages written from cache */ -#define WT_STAT_cache_write 13 -/*! Number of queries that could have benefited from a bloom filter that - * did not exist */ -#define WT_STAT_search_miss_no_bloom 14 -/*! Total space used by bloom filters */ -#define WT_STAT_bloom_space 15 +#define WT_STAT_DSRC_TXN_WRITE_CONFLICT 58 /*! @} */ /* * Statistics section: END diff --git a/src/include/wt_internal.h b/src/include/wt_internal.h index eefa18cb447..68791cfa3b1 100644 --- a/src/include/wt_internal.h +++ b/src/include/wt_internal.h @@ -65,8 +65,6 @@ struct __wt_btree; typedef struct __wt_btree WT_BTREE; struct __wt_btree_session; typedef struct __wt_btree_session WT_BTREE_SESSION; -struct __wt_btree_stats; - typedef struct __wt_btree_stats WT_BTREE_STATS; struct __wt_cache; typedef struct __wt_cache WT_CACHE; struct __wt_cache_pool; @@ -115,6 +113,8 @@ struct __wt_cursor_table; typedef struct __wt_cursor_table WT_CURSOR_TABLE; struct __wt_dlh; typedef struct __wt_dlh WT_DLH; +struct __wt_dsrc_stats; + typedef struct __wt_dsrc_stats WT_DSRC_STATS; struct __wt_evict_entry; typedef struct __wt_evict_entry WT_EVICT_ENTRY; struct __wt_ext; @@ -137,8 +137,6 @@ struct __wt_lsm_chunk; typedef struct __wt_lsm_chunk WT_LSM_CHUNK; struct __wt_lsm_data_source; typedef struct __wt_lsm_data_source WT_LSM_DATA_SOURCE; -struct __wt_lsm_stats; - typedef struct __wt_lsm_stats WT_LSM_STATS; struct __wt_lsm_tree; typedef struct __wt_lsm_tree WT_LSM_TREE; struct __wt_lsm_worker_args; diff --git a/src/lsm/lsm_cursor.c b/src/lsm/lsm_cursor.c index 7d769fdd603..f4227fbd9d1 100644 --- a/src/lsm/lsm_cursor.c +++ b/src/lsm/lsm_cursor.c @@ -563,10 +563,10 @@ __clsm_search(WT_CURSOR *cursor) ret = __wt_bloom_hash_get(bloom, &bhash); if (ret == WT_NOTFOUND) { WT_STAT_INCR( - clsm->lsm_tree->stats, bloom_misses); + clsm->lsm_tree->stats, bloom_miss); continue; } else if (ret == 0) - WT_STAT_INCR(clsm->lsm_tree->stats, bloom_hits); + WT_STAT_INCR(clsm->lsm_tree->stats, bloom_hit); WT_ERR(ret); } c->set_key(c, &cursor->key); @@ -581,11 +581,11 @@ __clsm_search(WT_CURSOR *cursor) goto err; else if (bloom != NULL) WT_STAT_INCR( - clsm->lsm_tree->stats, bloom_false_positives); + clsm->lsm_tree->stats, bloom_false_positive); /* The active chunk can't have a bloom filter. */ - else if (i != clsm->nchunks) + else if (clsm->primary_chunk == NULL || i != clsm->nchunks) WT_STAT_INCR( - clsm->lsm_tree->stats, search_miss_no_bloom); + clsm->lsm_tree->stats, lsm_lookup_no_bloom); } ret = WT_NOTFOUND; diff --git a/src/lsm/lsm_stat.c b/src/lsm/lsm_stat.c index 31bd7adf156..aa3ff1548c6 100644 --- a/src/lsm/lsm_stat.c +++ b/src/lsm/lsm_stat.c @@ -35,29 +35,27 @@ __wt_lsm_stat_init( * consistent view? If so should the copy belong to the stat cursor? */ /* Clear the statistics we are about to recalculate. */ - WT_STAT_SET(lsm_tree->stats, bloom_cache_read, 0); - WT_STAT_SET(lsm_tree->stats, bloom_cache_evict, 0); + WT_STAT_SET(lsm_tree->stats, bloom_page_read, 0); + WT_STAT_SET(lsm_tree->stats, bloom_page_evict, 0); WT_STAT_SET(lsm_tree->stats, bloom_count, 0); - WT_STAT_SET(lsm_tree->stats, bloom_space, 0); - WT_STAT_SET(lsm_tree->stats, cache_evict, 0); - WT_STAT_SET(lsm_tree->stats, cache_evict_fail, 0); - WT_STAT_SET(lsm_tree->stats, cache_read, 0); - WT_STAT_SET(lsm_tree->stats, cache_write, 0); - WT_STAT_SET(lsm_tree->stats, chunk_cache_evict, 0); - WT_STAT_SET(lsm_tree->stats, chunk_cache_read, 0); - WT_STAT_SET(lsm_tree->stats, generation_max, 0); + WT_STAT_SET(lsm_tree->stats, bloom_size, 0); + WT_STAT_SET(lsm_tree->stats, page_evict, 0); + WT_STAT_SET(lsm_tree->stats, page_evict_fail, 0); + WT_STAT_SET(lsm_tree->stats, page_read, 0); + WT_STAT_SET(lsm_tree->stats, page_write, 0); + WT_STAT_SET(lsm_tree->stats, lsm_generation_max, 0); /* Hold the LSM lock so that we can safely walk through the chunks. */ __wt_readlock(session, lsm_tree->rwlock); /* Set the stats for this run. */ - WT_STAT_SET(lsm_tree->stats, chunk_count, lsm_tree->nchunks); + WT_STAT_SET(lsm_tree->stats, lsm_chunk_count, lsm_tree->nchunks); for (i = 0; i < lsm_tree->nchunks; i++) { chunk = lsm_tree->chunk[i]; if (chunk->generation > - (uint32_t)WT_STAT(lsm_tree->stats, generation_max)) + (uint32_t)WT_STAT(lsm_tree->stats, lsm_generation_max)) WT_STAT_SET(lsm_tree->stats, - generation_max, chunk->generation); + lsm_generation_max, chunk->generation); /* * LSM chunk reads happen from a checkpoint, so get the @@ -78,38 +76,36 @@ __wt_lsm_stat_init( session, uribuf->data, cfg, &stat_cursor); WT_ERR(ret); - stat_cursor->set_key(stat_cursor, WT_STAT_page_evict_fail); + stat_cursor->set_key(stat_cursor, WT_STAT_DSRC_PAGE_EVICT_FAIL); WT_ERR(stat_cursor->search(stat_cursor)); WT_ERR(stat_cursor->get_value( stat_cursor, &desc, &pvalue, &value)); - WT_STAT_INCRV(lsm_tree->stats, cache_evict_fail, value); + WT_STAT_INCRV(lsm_tree->stats, page_evict_fail, value); - stat_cursor->set_key(stat_cursor, WT_STAT_page_evict); + stat_cursor->set_key(stat_cursor, WT_STAT_DSRC_PAGE_EVICT); WT_ERR(stat_cursor->search(stat_cursor)); WT_ERR(stat_cursor->get_value( stat_cursor, &desc, &pvalue, &value)); - WT_STAT_INCRV(lsm_tree->stats, cache_evict, value); - WT_STAT_INCRV(lsm_tree->stats, chunk_cache_evict, value); + WT_STAT_INCRV(lsm_tree->stats, page_evict, value); - stat_cursor->set_key(stat_cursor, WT_STAT_page_read); + stat_cursor->set_key(stat_cursor, WT_STAT_DSRC_PAGE_READ); WT_ERR(stat_cursor->search(stat_cursor)); WT_ERR(stat_cursor->get_value( stat_cursor, &desc, &pvalue, &value)); - WT_STAT_INCRV(lsm_tree->stats, cache_read, value); - WT_STAT_INCRV(lsm_tree->stats, chunk_cache_read, value); + WT_STAT_INCRV(lsm_tree->stats, page_read, value); - stat_cursor->set_key(stat_cursor, WT_STAT_page_write); + stat_cursor->set_key(stat_cursor, WT_STAT_DSRC_PAGE_WRITE); WT_ERR(stat_cursor->search(stat_cursor)); WT_ERR(stat_cursor->get_value( stat_cursor, &desc, &pvalue, &value)); - WT_STAT_INCRV(lsm_tree->stats, cache_write, value); + WT_STAT_INCRV(lsm_tree->stats, page_write, value); WT_ERR(stat_cursor->close(stat_cursor)); if (!F_ISSET(chunk, WT_LSM_CHUNK_BLOOM)) continue; WT_STAT_INCR(lsm_tree->stats, bloom_count); - WT_STAT_INCRV(lsm_tree->stats, bloom_space, + WT_STAT_INCRV(lsm_tree->stats, bloom_size, (chunk->count * lsm_tree->bloom_bit_count) / 8); WT_ERR(__wt_buf_fmt( @@ -117,31 +113,31 @@ __wt_lsm_stat_init( WT_ERR(__wt_curstat_open(session, uribuf->data, cfg, &stat_cursor)); - stat_cursor->set_key(stat_cursor, WT_STAT_page_evict); + stat_cursor->set_key(stat_cursor, WT_STAT_DSRC_PAGE_EVICT); WT_ERR(stat_cursor->search(stat_cursor)); WT_ERR(stat_cursor->get_value( stat_cursor, &desc, &pvalue, &value)); - WT_STAT_INCRV(lsm_tree->stats, cache_evict, value); - WT_STAT_INCRV(lsm_tree->stats, bloom_cache_evict, value); + WT_STAT_INCRV(lsm_tree->stats, page_evict, value); + WT_STAT_INCRV(lsm_tree->stats, bloom_page_evict, value); - stat_cursor->set_key(stat_cursor, WT_STAT_page_evict_fail); + stat_cursor->set_key(stat_cursor, WT_STAT_DSRC_PAGE_EVICT_FAIL); WT_ERR(stat_cursor->search(stat_cursor)); WT_ERR(stat_cursor->get_value( stat_cursor, &desc, &pvalue, &value)); - WT_STAT_INCRV(lsm_tree->stats, cache_evict_fail, value); + WT_STAT_INCRV(lsm_tree->stats, page_evict_fail, value); - stat_cursor->set_key(stat_cursor, WT_STAT_page_read); + stat_cursor->set_key(stat_cursor, WT_STAT_DSRC_PAGE_READ); WT_ERR(stat_cursor->search(stat_cursor)); WT_ERR(stat_cursor->get_value( stat_cursor, &desc, &pvalue, &value)); - WT_STAT_INCRV(lsm_tree->stats, cache_read, value); - WT_STAT_INCRV(lsm_tree->stats, bloom_cache_read, value); + WT_STAT_INCRV(lsm_tree->stats, page_read, value); + WT_STAT_INCRV(lsm_tree->stats, bloom_page_read, value); - stat_cursor->set_key(stat_cursor, WT_STAT_page_write); + stat_cursor->set_key(stat_cursor, WT_STAT_DSRC_PAGE_WRITE); WT_ERR(stat_cursor->search(stat_cursor)); WT_ERR(stat_cursor->get_value( stat_cursor, &desc, &pvalue, &value)); - WT_STAT_INCRV(lsm_tree->stats, cache_write, value); + WT_STAT_INCRV(lsm_tree->stats, page_write, value); WT_ERR(stat_cursor->close(stat_cursor)); } diff --git a/src/lsm/lsm_tree.c b/src/lsm/lsm_tree.c index da19dae231b..ea70889df5f 100644 --- a/src/lsm/lsm_tree.c +++ b/src/lsm/lsm_tree.c @@ -425,7 +425,7 @@ __lsm_tree_open( WT_ERR(__wt_rwlock_alloc(session, "lsm tree", &lsm_tree->rwlock)); WT_ERR(__wt_strdup(session, uri, &lsm_tree->name)); lsm_tree->filename = lsm_tree->name + strlen("lsm:"); - WT_ERR(__wt_stat_alloc_lsm_stats(session, &lsm_tree->stats)); + WT_ERR(__wt_stat_alloc_dsrc_stats(session, &lsm_tree->stats)); WT_ERR(__wt_lsm_meta_read(session, lsm_tree)); diff --git a/src/support/stat.c b/src/support/stat.c index 23065e706a5..b79f7f3e8e5 100644 --- a/src/support/stat.c +++ b/src/support/stat.c @@ -3,31 +3,37 @@ #include "wt_internal.h" int -__wt_stat_alloc_btree_stats(WT_SESSION_IMPL *session, WT_BTREE_STATS **statsp) +__wt_stat_alloc_dsrc_stats(WT_SESSION_IMPL *session, WT_DSRC_STATS **statsp) { - WT_BTREE_STATS *stats; + WT_DSRC_STATS *stats; WT_RET(__wt_calloc_def(session, 1, &stats)); - stats->alloc.desc = "file: block allocations"; - stats->cursor_inserts.desc = "cursor-inserts"; + stats->block_alloc.desc = "block allocations"; + stats->block_extend.desc = "block allocations required file extension"; + stats->block_free.desc = "block frees"; + stats->bloom_count.desc = "Number of Bloom filters in the LSM tree"; + stats->bloom_false_positive.desc = + "Number of Bloom filter false positives"; + stats->bloom_hit.desc = "Number of Bloom filter hits"; + stats->bloom_miss.desc = "Number of Bloom filter misses"; + stats->bloom_page_evict.desc = + "Number of Bloom pages evicted from cache"; + stats->bloom_page_read.desc = "Number of Bloom pages read into cache"; + stats->bloom_size.desc = "Total size of Bloom filters"; + stats->ckpt_size.desc = "checkpoint size"; + stats->cursor_insert.desc = "cursor-inserts"; stats->cursor_read.desc = "cursor-read"; stats->cursor_read_near.desc = "cursor-read-near"; stats->cursor_read_next.desc = "cursor-read-next"; stats->cursor_read_prev.desc = "cursor-read-prev"; - stats->cursor_removes.desc = "cursor-removes"; - stats->cursor_resets.desc = "cursor-resets"; - stats->cursor_updates.desc = "cursor-updates"; - stats->extend.desc = "file: block allocations required file extension"; + stats->cursor_remove.desc = "cursor-removes"; + stats->cursor_reset.desc = "cursor-resets"; + stats->cursor_update.desc = "cursor-updates"; + stats->entries.desc = "total entries"; stats->file_allocsize.desc = "page size allocation unit"; stats->file_bulk_loaded.desc = "bulk-loaded entries"; - stats->file_col_deleted.desc = "column-store deleted values"; - stats->file_col_fix_pages.desc = "column-store fixed-size leaf pages"; - stats->file_col_int_pages.desc = "column-store internal pages"; - stats->file_col_var_pages.desc = - "column-store variable-size leaf pages"; stats->file_compact_rewrite.desc = "pages rewritten by compaction"; - stats->file_entries.desc = "total entries"; stats->file_fixed_len.desc = "fixed-record size"; stats->file_magic.desc = "magic number"; stats->file_major.desc = "major version number"; @@ -36,61 +42,72 @@ __wt_stat_alloc_btree_stats(WT_SESSION_IMPL *session, WT_BTREE_STATS **statsp) stats->file_maxleafitem.desc = "maximum leaf page item size"; stats->file_maxleafpage.desc = "maximum leaf page size"; stats->file_minor.desc = "minor version number"; - stats->file_overflow.desc = "overflow pages"; - stats->file_row_int_pages.desc = "row-store internal pages"; - stats->file_row_leaf_pages.desc = "row-store leaf pages"; - stats->file_size.desc = "file: size"; - stats->file_write_conflicts.desc = "write generation conflicts"; - stats->free.desc = "file: block frees"; - stats->overflow_read.desc = "file: overflow pages read from the file"; - stats->overflow_value_cache.desc = - "file: overflow values cached in memory"; - stats->page_evict.desc = "file: pages evicted from the file"; + stats->file_size.desc = "file size"; + stats->lsm_chunk_count.desc = "Number of chunks in the LSM tree"; + stats->lsm_generation_max.desc = + "Highest merge generation in the LSM tree"; + stats->lsm_lookup_no_bloom.desc = + "Number of queries that could have benefited from a Bloom filter that did not exist"; + stats->overflow_page.desc = "overflow pages"; + stats->overflow_read.desc = "overflow pages read into cache"; + stats->overflow_value_cache.desc = "overflow values cached in memory"; + stats->page_col_deleted.desc = "column-store deleted values"; + stats->page_col_fix.desc = "column-store fixed-size leaf pages"; + stats->page_col_int.desc = "column-store internal pages"; + stats->page_col_var.desc = "column-store variable-size leaf pages"; + stats->page_evict.desc = "pages evicted from the data source"; stats->page_evict_fail.desc = - "file: pages that were selected for eviction that could not be evicted"; - stats->page_read.desc = "file: pages read from the file"; - stats->page_write.desc = "file: pages written to the file"; + "pages that were selected for eviction that could not be evicted"; + stats->page_read.desc = "pages read into cache"; + stats->page_row_int.desc = "row-store internal pages"; + stats->page_row_leaf.desc = "row-store leaf pages"; + stats->page_write.desc = "pages written from cache"; stats->rec_dictionary.desc = "reconcile: dictionary match"; stats->rec_hazard.desc = - "reconcile: unable to acquire hazard reference"; - stats->rec_ovfl_key.desc = "reconcile: overflow key"; - stats->rec_ovfl_value.desc = "reconcile: overflow value"; - stats->rec_page_delete.desc = "reconcile: pages deleted"; - stats->rec_page_merge.desc = - "reconcile: deleted or temporary pages merged"; - stats->rec_split_intl.desc = "reconcile: internal pages split"; - stats->rec_split_leaf.desc = "reconcile: leaf pages split"; - stats->rec_written.desc = "reconcile: pages written"; - stats->update_conflict.desc = "update conflicts"; + "reconciliation unable to acquire hazard reference"; + stats->rec_ovfl_key.desc = "reconciliation overflow key"; + stats->rec_ovfl_value.desc = "reconciliation overflow value"; + stats->rec_page_delete.desc = "pages deleted"; + stats->rec_page_merge.desc = "deleted or temporary pages merged"; + stats->rec_split_intl.desc = "internal pages split"; + stats->rec_split_leaf.desc = "leaf pages split"; + stats->rec_written.desc = "pages written"; + stats->txn_update_conflict.desc = "update conflicts"; + stats->txn_write_conflict.desc = "write generation conflicts"; *statsp = stats; return (0); } void -__wt_stat_clear_btree_stats(WT_STATS *stats_arg) +__wt_stat_clear_dsrc_stats(WT_STATS *stats_arg) { - WT_BTREE_STATS *stats; + WT_DSRC_STATS *stats; - stats = (WT_BTREE_STATS *)stats_arg; - stats->alloc.v = 0; - stats->cursor_inserts.v = 0; + stats = (WT_DSRC_STATS *)stats_arg; + stats->block_alloc.v = 0; + stats->block_extend.v = 0; + stats->block_free.v = 0; + stats->bloom_count.v = 0; + stats->bloom_false_positive.v = 0; + stats->bloom_hit.v = 0; + stats->bloom_miss.v = 0; + stats->bloom_page_evict.v = 0; + stats->bloom_page_read.v = 0; + stats->bloom_size.v = 0; + stats->ckpt_size.v = 0; + stats->cursor_insert.v = 0; stats->cursor_read.v = 0; stats->cursor_read_near.v = 0; stats->cursor_read_next.v = 0; stats->cursor_read_prev.v = 0; - stats->cursor_removes.v = 0; - stats->cursor_resets.v = 0; - stats->cursor_updates.v = 0; - stats->extend.v = 0; + stats->cursor_remove.v = 0; + stats->cursor_reset.v = 0; + stats->cursor_update.v = 0; + stats->entries.v = 0; stats->file_allocsize.v = 0; stats->file_bulk_loaded.v = 0; - stats->file_col_deleted.v = 0; - stats->file_col_fix_pages.v = 0; - stats->file_col_int_pages.v = 0; - stats->file_col_var_pages.v = 0; stats->file_compact_rewrite.v = 0; - stats->file_entries.v = 0; stats->file_fixed_len.v = 0; stats->file_magic.v = 0; stats->file_major.v = 0; @@ -99,17 +116,22 @@ __wt_stat_clear_btree_stats(WT_STATS *stats_arg) stats->file_maxleafitem.v = 0; stats->file_maxleafpage.v = 0; stats->file_minor.v = 0; - stats->file_overflow.v = 0; - stats->file_row_int_pages.v = 0; - stats->file_row_leaf_pages.v = 0; stats->file_size.v = 0; - stats->file_write_conflicts.v = 0; - stats->free.v = 0; + stats->lsm_chunk_count.v = 0; + stats->lsm_generation_max.v = 0; + stats->lsm_lookup_no_bloom.v = 0; + stats->overflow_page.v = 0; stats->overflow_read.v = 0; stats->overflow_value_cache.v = 0; + stats->page_col_deleted.v = 0; + stats->page_col_fix.v = 0; + stats->page_col_int.v = 0; + stats->page_col_var.v = 0; stats->page_evict.v = 0; stats->page_evict_fail.v = 0; stats->page_read.v = 0; + stats->page_row_int.v = 0; + stats->page_row_leaf.v = 0; stats->page_write.v = 0; stats->rec_dictionary.v = 0; stats->rec_hazard.v = 0; @@ -120,7 +142,8 @@ __wt_stat_clear_btree_stats(WT_STATS *stats_arg) stats->rec_split_intl.v = 0; stats->rec_split_leaf.v = 0; stats->rec_written.v = 0; - stats->update_conflict.v = 0; + stats->txn_update_conflict.v = 0; + stats->txn_write_conflict.v = 0; } int @@ -192,61 +215,3 @@ __wt_stat_clear_connection_stats(WT_STATS *stats_arg) stats->txn_fail_cache.v = 0; stats->txn_rollback.v = 0; } - -int -__wt_stat_alloc_lsm_stats(WT_SESSION_IMPL *session, WT_LSM_STATS **statsp) -{ - WT_LSM_STATS *stats; - - WT_RET(__wt_calloc_def(session, 1, &stats)); - - stats->bloom_cache_evict.desc = - "Number of bloom pages evicted from cache"; - stats->bloom_cache_read.desc = "Number of bloom pages read into cache"; - stats->bloom_count.desc = "Number of bloom filters in the LSM tree"; - stats->bloom_false_positives.desc = - "Number of bloom filter false positives"; - stats->bloom_hits.desc = "Number of bloom filter hits"; - stats->bloom_misses.desc = "Number of bloom filter misses"; - stats->bloom_space.desc = "Total space used by bloom filters"; - stats->cache_evict.desc = "Number of pages evicted from cache"; - stats->cache_evict_fail.desc = - "Number of pages selected for eviction that could not be evicted"; - stats->cache_read.desc = "Number of pages read into cache"; - stats->cache_write.desc = "Number of pages written from cache"; - stats->chunk_cache_evict.desc = - "Number of pages evicted from LSM chunks"; - stats->chunk_cache_read.desc = "Number of pages read into LSM chunks"; - stats->chunk_count.desc = "Number of chunks in the LSM tree"; - stats->generation_max.desc = - "Highest merge generation in the LSM tree"; - stats->search_miss_no_bloom.desc = - "Number of queries that could have benefited from a bloom filter that did not exist"; - - *statsp = stats; - return (0); -} - -void -__wt_stat_clear_lsm_stats(WT_STATS *stats_arg) -{ - WT_LSM_STATS *stats; - - stats = (WT_LSM_STATS *)stats_arg; - stats->bloom_cache_evict.v = 0; - stats->bloom_cache_read.v = 0; - stats->bloom_count.v = 0; - stats->bloom_false_positives.v = 0; - stats->bloom_hits.v = 0; - stats->bloom_misses.v = 0; - stats->bloom_space.v = 0; - stats->cache_evict.v = 0; - stats->cache_evict_fail.v = 0; - stats->cache_read.v = 0; - stats->cache_write.v = 0; - stats->chunk_cache_evict.v = 0; - stats->chunk_cache_read.v = 0; - stats->chunk_count.v = 0; - stats->generation_max.v = 0; - stats->search_miss_no_bloom.v = 0; -} diff --git a/test/suite/test_bug001.py b/test/suite/test_bug001.py index d9f17fd3699..8a42fe6ecbe 100644 --- a/test/suite/test_bug001.py +++ b/test/suite/test_bug001.py @@ -58,10 +58,7 @@ class test_bug001(wttest.WiredTigerTestCase): # Check search inside trailing implicit keys. for i in range(0, 5): - cursor.set_key(60 + i) - self.assertEqual(cursor.search(), 0) - self.assertEqual(cursor.get_key(), 60 + i) - self.assertEqual(cursor.get_value(), 0x00) + self.assertEqual(cursor[60 + i], 0x00) # Check cursor next inside trailing implicit keys. cursor.set_key(60) @@ -85,10 +82,7 @@ class test_bug001(wttest.WiredTigerTestCase): # Check search inside leading implicit keys. for i in range(0, 5): - cursor.set_key(10 + i) - self.assertEqual(cursor.search(), 0) - self.assertEqual(cursor.get_key(), 10 + i) - self.assertEqual(cursor.get_value(), 0x00) + self.assertEqual(cursor[10 + i], 0x00) # Check cursor next inside leading implicit keys. cursor.set_key(10) diff --git a/test/suite/test_checkpoint01.py b/test/suite/test_checkpoint01.py index 1482c1fdaf6..e218e8c76af 100644 --- a/test/suite/test_checkpoint01.py +++ b/test/suite/test_checkpoint01.py @@ -218,9 +218,7 @@ class test_checkpoint_target(wttest.WiredTigerTestCase): def check(self, uri, value): cursor = self.session.open_cursor(uri, None, "checkpoint=checkpoint-1") - cursor.set_key(key_populate(cursor, 10)) - cursor.search() - self.assertEquals(cursor.get_value(), value) + self.assertEquals(cursor[key_populate(cursor, 10)], value) cursor.close() def test_checkpoint_target(self): @@ -303,9 +301,7 @@ class test_checkpoint_last(wttest.WiredTigerTestCase): # Verify the "last" checkpoint sees the correct value. cursor = self.session.open_cursor( uri, None, "checkpoint=WiredTigerCheckpoint") - cursor.set_key(key_populate(cursor, 10)) - cursor.search() - self.assertEquals(cursor.get_value(), value) + self.assertEquals(cursor[key_populate(cursor, 10)], value) # Don't close the checkpoint cursor, we want it to remain open until # the test completes. diff --git a/test/suite/test_config04.py b/test/suite/test_config04.py index fdda95e74dc..14918636f19 100644 --- a/test/suite/test_config04.py +++ b/test/suite/test_config04.py @@ -27,6 +27,7 @@ import os import wiredtiger, wttest +from wiredtiger import stat # test_config04.py # Individually test config options @@ -82,10 +83,8 @@ class test_config04(wttest.WiredTigerTestCase): def common_cache_size_test(self, sizestr, size): self.common_test('cache_size=' + sizestr) cursor = self.session.open_cursor('statistics:', None, None) - cursor.set_key(wiredtiger.stat.cache_bytes_max) - self.assertEqual(cursor.search(), 0) - got_cache = cursor.get_values()[2] - self.assertEqual(got_cache, size) + self.assertEqual(cursor[stat.conn.cache_bytes_max][2], size) + cursor.close() def test_bad_config(self): self.assertRaisesWithMessage(wiredtiger.WiredTigerError, diff --git a/test/suite/test_cursor04.py b/test/suite/test_cursor04.py index e62aaf2a1e5..55a884f80c5 100644 --- a/test/suite/test_cursor04.py +++ b/test/suite/test_cursor04.py @@ -128,14 +128,10 @@ class test_cursor04(wttest.WiredTigerTestCase): cursor.insert() # 1. Calling search for a value that exists - cursor.set_key(self.genkey(5)) - self.assertEqual(cursor.search(), 0) - self.assertEqual(cursor.get_key(), self.genkey(5)) - self.assertEqual(cursor.get_value(), self.genvalue(5)) + self.assertEqual(cursor[self.genkey(5)], self.genvalue(5)) # 2. Calling search for a value that does not exist - cursor.set_key(self.genkey(self.nentries)) - self.assertEqual(cursor.search(), wiredtiger.WT_NOTFOUND) + self.assertRaises(KeyError, lambda: cursor[self.genkey(self.nentries)]) # 2. Calling search_near for a value beyond the end cursor.set_key(self.genkey(self.nentries)) diff --git a/test/suite/test_cursor05.py b/test/suite/test_cursor05.py index c349edce7f0..23b39e445ed 100644 --- a/test/suite/test_cursor05.py +++ b/test/suite/test_cursor05.py @@ -109,9 +109,7 @@ class test_cursor05(wttest.WiredTigerTestCase): # Do something that leaves the cursor in an uninitialized spot if expectcount > 0: n = expectcount - 1 - cursor.set_key(n, 'key' + str(n)) - cursor.search() - (s1, i2, s3, i4) = cursor.get_values() + s1, i2, s3, i4 = cursor[(n, 'key' + str(n))] self.assertEqual(s1, 'val' + str(n)) self.assertEqual(i2, n) self.assertEqual(s3, 'val' + str(n)) diff --git a/test/suite/test_stat01.py b/test/suite/test_stat01.py index 736917ea9cd..9ad3c3a133c 100644 --- a/test/suite/test_stat01.py +++ b/test/suite/test_stat01.py @@ -25,7 +25,8 @@ # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR # OTHER DEALINGS IN THE SOFTWARE. -import wiredtiger, wttest +import helper, wiredtiger, wttest +from wiredtiger import stat # test_stat01.py # Statistics operations @@ -35,6 +36,8 @@ class test_stat01(wttest.WiredTigerTestCase): """ tablename = 'test_stat01.wt' + uri = 'file:' + tablename + config = 'key_format=S,allocation_size=512,internal_page_max=16K,leaf_page_max=128K' nentries = 25 def statstr_to_int(self, str): @@ -69,50 +72,61 @@ class test_stat01(wttest.WiredTigerTestCase): self.assertTrue(count > mincount) self.assertTrue(found, 'in stats, did not see: ' + lookfor) - def test_statistics(self): - extra_params = ',allocation_size=512,internal_page_max=16384,leaf_page_max=131072' - self.session.create('table:' + self.tablename, 'key_format=S,value_format=S' + extra_params) - cursor = self.session.open_cursor('table:' + self.tablename, None, None) - value = "" - for i in range(0, self.nentries): - key = str(i) - value = value + key + value # size grows exponentially - cursor.set_key(key) - cursor.set_value(value) - cursor.insert() - cursor.close() - + def test_basic_conn_stats(self): self.printVerbose(2, 'overall database stats:') allstat_cursor = self.session.open_cursor('statistics:', None, None) self.check_stats(allstat_cursor, 10, 'blocks written to a file') # See that we can get a specific stat value by its key, # and verify that its entry is self-consistent - allstat_cursor.set_key(wiredtiger.stat.block_write) - self.assertEqual(allstat_cursor.search(), 0) - values = allstat_cursor.get_values() + values = allstat_cursor[stat.conn.block_write] self.assertEqual(values[0], 'blocks written to a file') val = self.statstr_to_int(values[1]) self.assertEqual(val, values[2]) allstat_cursor.close() + def test_basic_file_stats(self): + self.session.create(self.uri, self.config) + cursor = self.session.open_cursor(self.uri, None, None) + value = "" + for i in range(0, self.nentries): + key = str(i) + value = value + key + value # size grows exponentially + cursor.set_key(key) + cursor.set_value(value) + cursor.insert() + cursor.close() + self.printVerbose(2, 'file specific stats:') - filestat_cursor = self.session.open_cursor('statistics:file:' + self.tablename + ".wt", None, None) + filestat_cursor = self.session.open_cursor('statistics:' + self.uri, None, None) self.check_stats(filestat_cursor, 10, 'overflow pages') # See that we can get a specific stat value by its key, # and verify that its entry is self-consistent - filestat_cursor.set_key(wiredtiger.filestat.overflow) - self.assertEqual(filestat_cursor.search(), 0) - values = filestat_cursor.get_values() + values = filestat_cursor[stat.dsrc.overflow_page] self.assertEqual(values[0], 'overflow pages') val = self.statstr_to_int(values[1]) self.assertEqual(val, values[2]) filestat_cursor.close() - self.assertRaises(wiredtiger.WiredTigerError, - lambda: self.session.open_cursor( - 'statistics:file:DoesNotExist', None, None)) + def test_missing_file_stats(self): + self.assertRaises(wiredtiger.WiredTigerError, lambda: + self.session.open_cursor('statistics:file:DoesNotExist')) + + def test_checkpoint_stats(self): + nentries = 0 + last_size = 0 + for name in ('first', 'second', 'third'): + helper.simple_populate(self, self.uri, self.config, nentries) + nentries += self.nentries + self.session.checkpoint('name=' + name) + cursor = self.session.open_cursor( + 'statistics:' + self.uri, None, 'checkpoint=' + name) + size = cursor[stat.dsrc.overflow_page][1] + self.assertTrue(size >= last_size) + last_size = size + cursor.close() + self.session.truncate(self.uri, None, None) if __name__ == '__main__': wttest.run() |