summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Gorrod <alexander.gorrod@mongodb.com>2015-05-29 15:22:37 +1000
committerMichael Cahill <michael.cahill@mongodb.com>2015-05-29 15:46:02 +1000
commit0f3098e6ff3ad2ddfb2a03390b5b46515ecb7afb (patch)
tree7a92a6af743d359be32c67dba673056f5b1a7e1a
parent13e942f2611aaeae05376d1bc8391ae12647ff76 (diff)
downloadmongo-0f3098e6ff3ad2ddfb2a03390b5b46515ecb7afb.tar.gz
Merge pull request #2001 from wiredtiger/compact-early-exit
Compact early exit (cherry picked from commit 1aa7725e24265ecc4cf86051227c64325ce53115)
-rw-r--r--src/block/block_compact.c13
-rw-r--r--src/btree/bt_compact.c2
2 files changed, 10 insertions, 5 deletions
diff --git a/src/block/block_compact.c b/src/block/block_compact.c
index 4fcf6ea24ff..862bd62596a 100644
--- a/src/block/block_compact.c
+++ b/src/block/block_compact.c
@@ -67,7 +67,7 @@ __wt_block_compact_skip(WT_SESSION_IMPL *session, WT_BLOCK *block, int *skipp)
* worth doing. Ignore small files, and files where we are unlikely
* to recover 10% of the file.
*/
- if (fh->size <= 10 * 1024)
+ if (fh->size <= WT_MEGABYTE)
return (0);
__wt_spin_lock(session, &block->live_lock);
@@ -106,6 +106,8 @@ __wt_block_compact_skip(WT_SESSION_IMPL *session, WT_BLOCK *block, int *skipp)
*skipp ? "skipped" : "proceeding"));
/*
+ * Skip files where we can't recover at least 1MB.
+ *
* If at least 20% of the total file is available and in the first 80%
* of the file, we'll try compaction on the last 20% of the file; else,
* if at least 10% of the total file is available and in the first 90%
@@ -115,11 +117,14 @@ __wt_block_compact_skip(WT_SESSION_IMPL *session, WT_BLOCK *block, int *skipp)
* empty file can be processed quickly, so more aggressive compaction is
* less useful.
*/
- if (avail_ninety >= fh->size / 10) {
+ if (avail_eighty > WT_MEGABYTE &&
+ avail_eighty >= ((fh->size / 10) * 2)) {
+ *skipp = 0;
+ block->compact_pct_tenths = 2;
+ } else if (avail_ninety > WT_MEGABYTE &&
+ avail_ninety >= fh->size / 10) {
*skipp = 0;
block->compact_pct_tenths = 1;
- if (avail_eighty >= ((fh->size / 10) * 2))
- block->compact_pct_tenths = 2;
}
err: __wt_spin_unlock(session, &block->live_lock);
diff --git a/src/btree/bt_compact.c b/src/btree/bt_compact.c
index 1528d65b8c8..769423f7796 100644
--- a/src/btree/bt_compact.c
+++ b/src/btree/bt_compact.c
@@ -142,7 +142,6 @@ __wt_compact(WT_SESSION_IMPL *session, const char *cfg[])
block_manager_begin = 1;
/* Walk the tree reviewing pages to see if they should be re-written. */
- session->compaction = 1;
for (;;) {
/*
* Pages read for compaction aren't "useful"; don't update the
@@ -159,6 +158,7 @@ __wt_compact(WT_SESSION_IMPL *session, const char *cfg[])
if (skip)
continue;
+ session->compaction = 1;
/* Rewrite the page: mark the page and tree dirty. */
WT_ERR(__wt_page_modify_init(session, ref->page));
__wt_page_modify_set(session, ref->page);