summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Bostic <keith@wiredtiger.com>2015-12-14 16:59:52 -0500
committerKeith Bostic <keith@wiredtiger.com>2015-12-14 16:59:52 -0500
commitdd13b348ad54551fe8928daa8149386fc5fd1fa9 (patch)
tree95ff2db96722cf5a8ed241a9c86fd6cb3631c863
parent0f2932b966b494df966f8f1a1c7228baa661e67a (diff)
downloadmongo-dd13b348ad54551fe8928daa8149386fc5fd1fa9.tar.gz
Add counts of the pages reviewed, skipped and written during a compaction
pass, report those statistics and the overall state of the file when the compaction pass completes.
-rw-r--r--src/block/block_compact.c56
-rw-r--r--src/include/block.h5
2 files changed, 55 insertions, 6 deletions
diff --git a/src/block/block_compact.c b/src/block/block_compact.c
index 3030a6bcfa9..cd304b848d4 100644
--- a/src/block/block_compact.c
+++ b/src/block/block_compact.c
@@ -8,7 +8,7 @@
#include "wt_internal.h"
-static int __block_dump_avail(WT_SESSION_IMPL *, WT_BLOCK *);
+static int __block_dump_avail(WT_SESSION_IMPL *, WT_BLOCK *, bool);
/*
* __wt_block_compact_start --
@@ -32,12 +32,21 @@ __wt_block_compact_start(WT_SESSION_IMPL *session, WT_BLOCK *block)
int
__wt_block_compact_end(WT_SESSION_IMPL *session, WT_BLOCK *block)
{
+ WT_DECL_RET;
+
WT_UNUSED(session);
/* Restore the original allocation plan. */
__wt_block_configure_first_fit(block, false);
- return (0);
+ /* Dump the results of the compaction pass. */
+ if (WT_VERBOSE_ISSET(session, WT_VERB_COMPACT)) {
+ __wt_spin_lock(session, &block->live_lock);
+ ret = __block_dump_avail(session, block, false);
+ __wt_spin_unlock(session, &block->live_lock);
+ }
+
+ return (ret);
}
/*
@@ -66,12 +75,23 @@ __wt_block_compact_skip(WT_SESSION_IMPL *session, WT_BLOCK *block, bool *skipp)
if (fh->size <= WT_MEGABYTE)
return (0);
+ /*
+ * Reset the compaction state information. This is done here, not in the
+ * compaction "start" routine, because this function is called first to
+ * determine if compaction is useful.
+ */
+ block->compact_pct_tenths = 0;
+ block->compact_pages_reviewed = 0;
+ block->compact_pages_skipped = 0;
+ block->compact_pages_written = 0;
+
__wt_spin_lock(session, &block->live_lock);
+ /* Dump the current state of the file. */
if (WT_VERBOSE_ISSET(session, WT_VERB_COMPACT))
- WT_ERR(__block_dump_avail(session, block));
+ WT_ERR(__block_dump_avail(session, block, true));
- /* Sum the available bytes in the first 80% and 90% of the file. */
+ /* Sum the available bytes in the initial 80% and 90% of the file. */
avail_eighty = avail_ninety = 0;
ninety = fh->size - fh->size / 10;
eighty = fh->size - ((fh->size / 10) * 2);
@@ -173,6 +193,14 @@ __wt_block_compact_page_skip(WT_SESSION_IMPL *session,
}
__wt_spin_unlock(session, &block->live_lock);
+ if (WT_VERBOSE_ISSET(session, WT_VERB_COMPACT)) {
+ ++block->compact_pages_reviewed;
+ if (*skipp)
+ ++block->compact_pages_skipped;
+ else
+ ++block->compact_pages_written;
+ }
+
return (ret);
}
@@ -181,7 +209,7 @@ __wt_block_compact_page_skip(WT_SESSION_IMPL *session,
* Dump out the avail list so we can see what compaction will look like.
*/
static int
-__block_dump_avail(WT_SESSION_IMPL *session, WT_BLOCK *block)
+__block_dump_avail(WT_SESSION_IMPL *session, WT_BLOCK *block, bool start)
{
WT_EXTLIST *el;
WT_EXT *ext;
@@ -192,6 +220,20 @@ __block_dump_avail(WT_SESSION_IMPL *session, WT_BLOCK *block)
size = block->fh->size;
WT_RET(__wt_verbose(session, WT_VERB_COMPACT,
+ "============ %s",
+ start ? "testing for compaction" : "ending compaction pass"));
+
+ if (!start) {
+ WT_RET(__wt_verbose(session, WT_VERB_COMPACT,
+ "pages reviewed: %" PRIuMAX,
+ block->compact_pages_reviewed));
+ WT_RET(__wt_verbose(session, WT_VERB_COMPACT,
+ "pages skipped: %" PRIuMAX, block->compact_pages_skipped));
+ WT_RET(__wt_verbose(session, WT_VERB_COMPACT,
+ "pages written: %" PRIuMAX, block->compact_pages_written));
+ }
+
+ WT_RET(__wt_verbose(session, WT_VERB_COMPACT,
"file size %" PRIuMAX "MB (%" PRIuMAX ") with %" PRIuMAX
"%% space available %" PRIuMAX "MB (%" PRIuMAX ")",
(uintmax_t)size / WT_MEGABYTE, (uintmax_t)size,
@@ -215,6 +257,10 @@ __block_dump_avail(WT_SESSION_IMPL *session, WT_BLOCK *block)
}
#ifdef __VERBOSE_OUTPUT_PERCENTILE
+ /*
+ * The verbose output always displays 10% buckets, running this code
+ * as well also displays 1% buckets.
+ */
for (i = 0; i < WT_ELEMENTS(percentile); ++i) {
v = percentile[i] * 512;
WT_RET(__wt_verbose(session, WT_VERB_COMPACT,
diff --git a/src/include/block.h b/src/include/block.h
index 4bff6c82783..f398ff494fd 100644
--- a/src/include/block.h
+++ b/src/include/block.h
@@ -244,7 +244,10 @@ struct __wt_block {
bool ckpt_inprogress;/* Live checkpoint in progress */
/* Compaction support */
- int compact_pct_tenths; /* Percent to compact */
+ int compact_pct_tenths; /* Percent to compact */
+ uint64_t compact_pages_reviewed;/* Pages reviewed */
+ uint64_t compact_pages_skipped; /* Pages skipped */
+ uint64_t compact_pages_written; /* Pages rewritten */
/* Salvage support */
wt_off_t slvg_off; /* Salvage file offset */