summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorQingyang Chen <qingyang.chen@10gen.com>2015-07-23 11:05:44 -0400
committerQingyang Chen <qingyang.chen@10gen.com>2015-07-23 18:56:02 -0400
commit26c5394f79d12ac1c9df7263199e2926ee2e19ff (patch)
tree844e87c053083354c13b8cc2cb20feae340e2114 /src
parentcd5bff570f1e17e43cbd81d9eb56fa6097c18b3c (diff)
downloadmongo-26c5394f79d12ac1c9df7263199e2926ee2e19ff.tar.gz
SERVER-17895 Remove clearing plan cache after 1000 write ops
Diffstat (limited to 'src')
-rw-r--r--src/mongo/db/catalog/collection.cpp10
-rw-r--r--src/mongo/db/catalog/collection_info_cache.cpp6
-rw-r--r--src/mongo/db/catalog/collection_info_cache.h3
-rw-r--r--src/mongo/db/query/plan_cache.cpp12
-rw-r--r--src/mongo/db/query/plan_cache.h6
-rw-r--r--src/mongo/db/query/plan_cache_test.cpp40
-rw-r--r--src/mongo/db/query/query_knobs.cpp2
-rw-r--r--src/mongo/db/query/query_knobs.h3
8 files changed, 1 insertions, 81 deletions
diff --git a/src/mongo/db/catalog/collection.cpp b/src/mongo/db/catalog/collection.cpp
index f5128b1065d..77f0db43687 100644
--- a/src/mongo/db/catalog/collection.cpp
+++ b/src/mongo/db/catalog/collection.cpp
@@ -399,8 +399,6 @@ StatusWith<RecordId> Collection::_insertDocument(OperationContext* txn,
invariant(RecordId::min() < loc.getValue());
invariant(loc.getValue() < RecordId::max());
- _infoCache.notifyOfWriteOp();
-
Status s = _indexCatalog.indexRecord(txn, docToInsert, loc.getValue());
if (!s.isOK())
return StatusWith<RecordId>(s);
@@ -446,8 +444,6 @@ void Collection::deleteDocument(
_recordStore->deleteRecord(txn, loc);
- _infoCache.notifyOfWriteOp();
-
if (!id.isEmpty()) {
getGlobalServiceContext()->getOpObserver()->onDelete(txn, ns().ns(), id);
}
@@ -531,11 +527,7 @@ StatusWith<RecordId> Collection::updateDocument(OperationContext* txn,
}
// At this point, the old object may or may not still be indexed, depending on if it was
- // moved.
-
- _infoCache.notifyOfWriteOp();
-
- // If the object did move, we need to add the new location to all indexes.
+ // moved. If the object did move, we need to add the new location to all indexes.
if (newLocation.getValue() != oldLocation) {
if (debug) {
if (debug->nmoved == -1) // default of -1 rather than 0
diff --git a/src/mongo/db/catalog/collection_info_cache.cpp b/src/mongo/db/catalog/collection_info_cache.cpp
index 994dc9945c5..ba2e9c6befa 100644
--- a/src/mongo/db/catalog/collection_info_cache.cpp
+++ b/src/mongo/db/catalog/collection_info_cache.cpp
@@ -123,12 +123,6 @@ void CollectionInfoCache::computeIndexKeys(OperationContext* txn) {
_keysComputed = true;
}
-void CollectionInfoCache::notifyOfWriteOp() {
- if (NULL != _planCache.get()) {
- _planCache->notifyOfWriteOp();
- }
-}
-
void CollectionInfoCache::clearQueryCache() {
if (NULL != _planCache.get()) {
_planCache->clear();
diff --git a/src/mongo/db/catalog/collection_info_cache.h b/src/mongo/db/catalog/collection_info_cache.h
index 7e418b4e123..05462ffaad4 100644
--- a/src/mongo/db/catalog/collection_info_cache.h
+++ b/src/mongo/db/catalog/collection_info_cache.h
@@ -84,9 +84,6 @@ public:
void clearQueryCache();
- /* you must notify the cache if you are doing writes, as query plan utility will change */
- void notifyOfWriteOp();
-
private:
Collection* _collection; // not owned
diff --git a/src/mongo/db/query/plan_cache.cpp b/src/mongo/db/query/plan_cache.cpp
index be0028fe6d9..2b165557c71 100644
--- a/src/mongo/db/query/plan_cache.cpp
+++ b/src/mongo/db/query/plan_cache.cpp
@@ -746,18 +746,6 @@ size_t PlanCache::size() const {
return _cache.size();
}
-void PlanCache::notifyOfWriteOp() {
- // It's fine to clear the cache multiple times if multiple threads
- // increment the counter to kPlanCacheMaxWriteOperations or greater.
- if (_writeOperations.addAndFetch(1) < internalQueryCacheWriteOpsBetweenFlush) {
- return;
- }
-
- LOG(1) << _ns << ": clearing collection plan cache - " << internalQueryCacheWriteOpsBetweenFlush
- << " write operations detected since last refresh.";
- clear();
-}
-
void PlanCache::notifyOfIndexEntries(const std::vector<IndexEntry>& indexEntries) {
_indexabilityState.updateDiscriminators(indexEntries);
}
diff --git a/src/mongo/db/query/plan_cache.h b/src/mongo/db/query/plan_cache.h
index 974d827e31f..e5d598268b0 100644
--- a/src/mongo/db/query/plan_cache.h
+++ b/src/mongo/db/query/plan_cache.h
@@ -381,12 +381,6 @@ public:
size_t size() const;
/**
- * You must notify the cache if you are doing writes, as query plan utility will change.
- * Cache is flushed after every 1000 notifications.
- */
- void notifyOfWriteOp();
-
- /**
* Updates internal state kept about the collection's indexes. Must be called when the set
* of indexes on the associated collection have changed.
*
diff --git a/src/mongo/db/query/plan_cache_test.cpp b/src/mongo/db/query/plan_cache_test.cpp
index 867f5261d6d..7578893620d 100644
--- a/src/mongo/db/query/plan_cache_test.cpp
+++ b/src/mongo/db/query/plan_cache_test.cpp
@@ -388,46 +388,6 @@ TEST(PlanCacheTest, AddValidSolution) {
ASSERT_EQUALS(planCache.size(), 1U);
}
-TEST(PlanCacheTest, NotifyOfWriteOp) {
- PlanCache planCache;
- unique_ptr<CanonicalQuery> cq(canonicalize("{a: 1}"));
- QuerySolution qs;
- qs.cacheData.reset(new SolutionCacheData());
- qs.cacheData->tree.reset(new PlanCacheIndexTree());
- std::vector<QuerySolution*> solns;
- solns.push_back(&qs);
- ASSERT_OK(planCache.add(*cq, solns, createDecision(1U)));
- ASSERT_EQUALS(planCache.size(), 1U);
-
- // First (N - 1) write ops should have no effect on cache contents.
- for (int i = 0; i < (internalQueryCacheWriteOpsBetweenFlush - 1); ++i) {
- planCache.notifyOfWriteOp();
- }
- ASSERT_EQUALS(planCache.size(), 1U);
-
- // N-th notification will cause cache to be cleared.
- planCache.notifyOfWriteOp();
- ASSERT_EQUALS(planCache.size(), 0U);
-
- // Clearing the cache should reset the internal write
- // operation counter.
- // Repopulate cache. Write (N - 1) times.
- // Clear cache.
- // Add cache entry again.
- // After clearing and adding a new entry, the next write operation should not
- // clear the cache.
- ASSERT_OK(planCache.add(*cq, solns, createDecision(1U)));
- for (int i = 0; i < (internalQueryCacheWriteOpsBetweenFlush - 1); ++i) {
- planCache.notifyOfWriteOp();
- }
- ASSERT_EQUALS(planCache.size(), 1U);
- planCache.clear();
- ASSERT_OK(planCache.add(*cq, solns, createDecision(1U)));
- // Notification after clearing will not flush cache.
- planCache.notifyOfWriteOp();
- ASSERT_EQUALS(planCache.size(), 1U);
-}
-
/**
* Each test in the CachePlanSelectionTest suite goes through
* the following flow:
diff --git a/src/mongo/db/query/query_knobs.cpp b/src/mongo/db/query/query_knobs.cpp
index c73759cebd4..410890c4861 100644
--- a/src/mongo/db/query/query_knobs.cpp
+++ b/src/mongo/db/query/query_knobs.cpp
@@ -44,8 +44,6 @@ MONGO_EXPORT_SERVER_PARAMETER(internalQueryCacheFeedbacksStored, int, 20);
MONGO_EXPORT_SERVER_PARAMETER(internalQueryCacheEvictionRatio, double, 10.0);
-MONGO_EXPORT_SERVER_PARAMETER(internalQueryCacheWriteOpsBetweenFlush, int, 1000);
-
MONGO_EXPORT_SERVER_PARAMETER(internalQueryPlannerMaxIndexedSolutions, int, 64);
MONGO_EXPORT_SERVER_PARAMETER(internalQueryEnumerationMaxOrSolutions, int, 10);
diff --git a/src/mongo/db/query/query_knobs.h b/src/mongo/db/query/query_knobs.h
index c82d6828a29..0b7f5e000de 100644
--- a/src/mongo/db/query/query_knobs.h
+++ b/src/mongo/db/query/query_knobs.h
@@ -69,9 +69,6 @@ extern int internalQueryCacheFeedbacksStored;
// and replanning?
extern double internalQueryCacheEvictionRatio;
-// How many write ops should we allow in a collection before tossing all cache entries?
-extern int internalQueryCacheWriteOpsBetweenFlush;
-
//
// Planning and enumeration.
//