From 12132c60c7229824332a29d2c6839511e27d8a01 Mon Sep 17 00:00:00 2001 From: jsteemann Date: Tue, 6 Jun 2017 12:44:39 +0200 Subject: [PATCH] improve waitForSync performance for mmfiles --- arangod/MMFiles/MMFilesCollection.cpp | 2 -- arangod/MMFiles/MMFilesTransactionState.cpp | 4 +++- arangod/StorageEngine/PhysicalCollection.cpp | 10 ++++++++++ arangod/StorageEngine/PhysicalCollection.h | 3 +++ 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/arangod/MMFiles/MMFilesCollection.cpp b/arangod/MMFiles/MMFilesCollection.cpp index a9da868e2c..6f3b788df8 100644 --- a/arangod/MMFiles/MMFilesCollection.cpp +++ b/arangod/MMFiles/MMFilesCollection.cpp @@ -2778,8 +2778,6 @@ int MMFilesCollection::insert(transaction::Methods* trx, VPackSlice const slice, bool const useDeadlockDetector = (lock && !trx->isSingleOperationTransaction() && !trx->state()->hasHint(transaction::Hints::Hint::NO_DLD)); try { - // TODO Do we use the CollectionLocker on LogicalCollections - // or do we use it on the SE specific one? arangodb::MMFilesCollectionWriteLocker collectionLocker( this, useDeadlockDetector, lock); diff --git a/arangod/MMFiles/MMFilesTransactionState.cpp b/arangod/MMFiles/MMFilesTransactionState.cpp index 9b208e156e..befd8b6b6c 100644 --- a/arangod/MMFiles/MMFilesTransactionState.cpp +++ b/arangod/MMFiles/MMFilesTransactionState.cpp @@ -282,7 +282,9 @@ int MMFilesTransactionState::addOperation(TRI_voc_rid_t revisionId, } if (localWaitForSync) { // also sync RocksDB WAL - MMFilesPersistentIndexFeature::syncWal(); + if (collection->getPhysical()->hasIndexOfType(arangodb::Index::TRI_IDX_TYPE_PERSISTENT_INDEX)) { + MMFilesPersistentIndexFeature::syncWal(); + } } operation.setTick(slotInfo.tick); fid = slotInfo.logfileId; diff --git a/arangod/StorageEngine/PhysicalCollection.cpp b/arangod/StorageEngine/PhysicalCollection.cpp index 29522d71f5..f348b44e91 100644 --- a/arangod/StorageEngine/PhysicalCollection.cpp +++ b/arangod/StorageEngine/PhysicalCollection.cpp @@ -66,6 +66,16 @@ void PhysicalCollection::drop() { } } +bool PhysicalCollection::hasIndexOfType(arangodb::Index::IndexType type) const { + READ_LOCKER(guard, _indexesLock); + for (auto const& idx : _indexes) { + if (idx->type() == type) { + return true; + } + } + return false; +} + std::shared_ptr PhysicalCollection::lookupIndex( TRI_idx_iid_t idxId) const { READ_LOCKER(guard, _indexesLock); diff --git a/arangod/StorageEngine/PhysicalCollection.h b/arangod/StorageEngine/PhysicalCollection.h index 7293d9000e..c8d6a54ebf 100644 --- a/arangod/StorageEngine/PhysicalCollection.h +++ b/arangod/StorageEngine/PhysicalCollection.h @@ -26,6 +26,7 @@ #include "Basics/Common.h" #include "Basics/ReadWriteLock.h" +#include "Indexes/Index.h" #include "VocBase/voc-types.h" #include @@ -94,6 +95,8 @@ class PhysicalCollection { /////////////////////////////////// virtual void prepareIndexes(arangodb::velocypack::Slice indexesSlice) = 0; + + bool hasIndexOfType(arangodb::Index::IndexType type) const; /// @brief Find index by definition virtual std::shared_ptr lookupIndex(