diff options
author | Alex Gorrod <alexg@wiredtiger.com> | 2015-05-28 04:55:32 +0000 |
---|---|---|
committer | Alex Gorrod <alexg@wiredtiger.com> | 2015-05-28 04:55:32 +0000 |
commit | 98c646d5191a70530f3094ea1754bbec4817ced6 (patch) | |
tree | 0a3581fc487322a722b1d50bab9960eeac7fbe8b | |
parent | 5cdf0ec8c4367fd3e49904231f97843c996dbea4 (diff) | |
download | mongo-98c646d5191a70530f3094ea1754bbec4817ced6.tar.gz |
Give the btree code a chance to flag compaction as unnecessary.
Previously only the block manager was checked.
-rw-r--r-- | src/btree/bt_compact.c | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/src/btree/bt_compact.c b/src/btree/bt_compact.c index 18f8ca54601..51d77101398 100644 --- a/src/btree/bt_compact.c +++ b/src/btree/bt_compact.c @@ -65,6 +65,31 @@ __compact_rewrite(WT_SESSION_IMPL *session, WT_REF *ref, int *skipp) } /* + * __compact_skip -- + * Return if it may be worthwhile compacting a file. + */ +static int +__compact_skip(WT_SESSION_IMPL *session, int *skipp) +{ + WT_BTREE *btree; + WT_PAGE_INDEX *pindex; + + *skipp = 1; + + btree = S2BT(session); + + /* Trees with less than 4 level one pages aren't worth compacting */ + WT_INTL_INDEX_GET(session, btree->root.page, pindex); + if (pindex->entries < 4) + return (0); + + /* Check with the block manager whether compaction may be useful */ + WT_RET(btree->bm->compact_skip(btree->bm, session, skipp)); + + return (0); +} + +/* * __wt_compact -- * Compact a file. */ @@ -93,7 +118,7 @@ __wt_compact(WT_SESSION_IMPL *session, const char *cfg[]) * to compact the data source if we make no progress, set a flag if the * block layer thinks compaction is possible. */ - WT_RET(bm->compact_skip(bm, session, &skip)); + WT_RET(__compact_skip(session, &skip)); if (skip) return (0); |