diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2022-08-19 10:07:06 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2022-08-19 10:07:06 +0000 |
commit | e293065d80c26b2771f7977a5b6bbb5ac9906a0b (patch) | |
tree | 737af04d7b4286cdf468814939af817007df968d | |
parent | a520fda96ce01c92f28ea4c6b700a39396544d2e (diff) |
Use xxhash for all BucketId hash sets and maps.
10 files changed, 34 insertions, 61 deletions
diff --git a/document/src/vespa/document/bucket/bucketid.cpp b/document/src/vespa/document/bucket/bucketid.cpp index 3752eab4810..72dd3734ce7 100644 --- a/document/src/vespa/document/bucket/bucketid.cpp +++ b/document/src/vespa/document/bucket/bucketid.cpp @@ -158,5 +158,4 @@ operator>>(nbostream &is, BucketId &bucketId) } // document -VESPALIB_HASH_SET_INSTANTIATE_H(document::BucketId, document::BucketId::hash); VESPALIB_HASH_SET_INSTANTIATE_H(document::BucketId, document::BucketId::xxhash); diff --git a/document/src/vespa/document/bucket/bucketid.h b/document/src/vespa/document/bucket/bucketid.h index a0f9ca4e94f..1f944f5349c 100644 --- a/document/src/vespa/document/bucket/bucketid.h +++ b/document/src/vespa/document/bucket/bucketid.h @@ -36,14 +36,10 @@ namespace bucket { class BucketIdList; } class BucketId { public: - struct hash { - size_t operator () (const BucketId& g) const noexcept { - return g.getId(); - } - }; struct xxhash { uint64_t operator () (const BucketId& g) const noexcept; }; + using hash = xxhash; /** * The primitive type used to store bucket identifiers. If you use the diff --git a/persistence/src/vespa/persistence/dummyimpl/dummypersistence.cpp b/persistence/src/vespa/persistence/dummyimpl/dummypersistence.cpp index 6eabadc2f86..34d6feb0724 100644 --- a/persistence/src/vespa/persistence/dummyimpl/dummypersistence.cpp +++ b/persistence/src/vespa/persistence/dummyimpl/dummypersistence.cpp @@ -934,4 +934,4 @@ DummyPersistence::internal_create_bucket(const Bucket& b) } -VESPALIB_HASH_MAP_INSTANTIATE_H(storage::spi::Bucket, std::shared_ptr<storage::spi::dummy::BucketContent>, document::BucketId::hash) +VESPALIB_HASH_MAP_INSTANTIATE_H(storage::spi::Bucket, std::shared_ptr<storage::spi::dummy::BucketContent>, document::BucketId::xxhash) diff --git a/persistence/src/vespa/persistence/dummyimpl/dummypersistence.h b/persistence/src/vespa/persistence/dummyimpl/dummypersistence.h index 56602b3ab00..71c639c2a9b 100644 --- a/persistence/src/vespa/persistence/dummyimpl/dummypersistence.h +++ b/persistence/src/vespa/persistence/dummyimpl/dummypersistence.h @@ -208,7 +208,7 @@ private: mutable bool _initialized; std::shared_ptr<const document::DocumentTypeRepo> _repo; - using Content = vespalib::hash_map<Bucket, BucketContent::SP, document::BucketId::hash>; + using Content = vespalib::hash_map<Bucket, BucketContent::SP, document::BucketId::xxhash>; Content _content; IteratorId _nextIterator; diff --git a/searchcore/src/vespa/searchcore/bmcluster/bucket_db_snapshot.cpp b/searchcore/src/vespa/searchcore/bmcluster/bucket_db_snapshot.cpp index 3ddb1afdb35..f91eb135066 100644 --- a/searchcore/src/vespa/searchcore/bmcluster/bucket_db_snapshot.cpp +++ b/searchcore/src/vespa/searchcore/bmcluster/bucket_db_snapshot.cpp @@ -2,7 +2,6 @@ #include "bucket_db_snapshot.h" #include <vespa/persistence/spi/persistenceprovider.h> -#include <vespa/vespalib/stllike/hash_set.hpp> #include <vespa/vespalib/stllike/hash_map.hpp> #include <cassert> @@ -66,9 +65,4 @@ BucketDbSnapshot::try_get_bucket_info(BucketId bucket_id) const } -namespace vespalib { - -template class hash_map<BucketId, BucketInfo, BucketId::hash>; -template class hash_set<BucketId, BucketId::hash>; - -} +VESPALIB_HASH_MAP_INSTANTIATE_H(document::BucketId, storage::spi::BucketInfo, document::BucketId::xxhash);
\ No newline at end of file diff --git a/searchcore/src/vespa/searchcore/bmcluster/bucket_db_snapshot.h b/searchcore/src/vespa/searchcore/bmcluster/bucket_db_snapshot.h index d750a73f207..5881267f2e0 100644 --- a/searchcore/src/vespa/searchcore/bmcluster/bucket_db_snapshot.h +++ b/searchcore/src/vespa/searchcore/bmcluster/bucket_db_snapshot.h @@ -17,11 +17,15 @@ namespace search::bmcluster { */ class BucketDbSnapshot { - using BucketInfoMap = vespalib::hash_map<document::BucketId, storage::spi::BucketInfo, document::BucketId::hash>; + using BucketInfoMap = vespalib::hash_map<document::BucketId, storage::spi::BucketInfo, document::BucketId::xxhash>; BucketInfoMap _buckets; public: - using BucketIdSet = vespalib::hash_set<document::BucketId, document::BucketId::hash>; + using BucketIdSet = vespalib::hash_set<document::BucketId, document::BucketId::xxhash>; BucketDbSnapshot(); + BucketDbSnapshot(const BucketDbSnapshot &) = delete; + BucketDbSnapshot & operator=(const BucketDbSnapshot &) = delete; + BucketDbSnapshot(BucketDbSnapshot &&) noexcept = default; + BucketDbSnapshot & operator=(BucketDbSnapshot &&) noexcept = default; ~BucketDbSnapshot(); void populate(document::BucketSpace bucket_space, storage::spi::PersistenceProvider& provider); uint32_t count_new_documents(const BucketDbSnapshot &old) const; diff --git a/searchcore/src/vespa/searchcore/bmcluster/bucket_db_snapshot_vector.h b/searchcore/src/vespa/searchcore/bmcluster/bucket_db_snapshot_vector.h index 7799ed8fc58..df6183fd6f9 100644 --- a/searchcore/src/vespa/searchcore/bmcluster/bucket_db_snapshot_vector.h +++ b/searchcore/src/vespa/searchcore/bmcluster/bucket_db_snapshot_vector.h @@ -16,8 +16,9 @@ class BucketDbSnapshotVector vespalib::hash_map<document::BucketSpace, std::vector<BucketDbSnapshot>, document::BucketSpace::hash> _snapshots; using BucketIdSet = BucketDbSnapshot::BucketIdSet; public: - BucketDbSnapshotVector(const std::vector<storage::spi::PersistenceProvider *>& providers, const storage::lib::ClusterStateBundle &cluster_state_bundle); + BucketDbSnapshotVector(const BucketDbSnapshotVector &) = delete; + BucketDbSnapshotVector & operator = (const BucketDbSnapshotVector &) = delete; ~BucketDbSnapshotVector(); uint32_t count_moved_documents(const BucketDbSnapshotVector &old) const; uint32_t count_lost_unique_documents(const BucketDbSnapshotVector &old) const; diff --git a/storage/src/tests/persistence/filestorage/operationabortingtest.cpp b/storage/src/tests/persistence/filestorage/operationabortingtest.cpp index ecf4ddde911..1943bb62936 100644 --- a/storage/src/tests/persistence/filestorage/operationabortingtest.cpp +++ b/storage/src/tests/persistence/filestorage/operationabortingtest.cpp @@ -163,7 +163,7 @@ OperationAbortingTest::validateReplies(DummyStorageLink& link, size_t repliesTot namespace { class ExplicitBucketSetPredicate : public AbortBucketOperationsCommand::AbortPredicate { - using BucketSet = vespalib::hash_set<document::BucketId, document::BucketId::hash>; + using BucketSet = vespalib::hash_set<document::BucketId, document::BucketId::xxhash>; BucketSet _bucketsToAbort; bool doShouldAbort(const document::Bucket &bucket) const override; diff --git a/storage/src/vespa/storage/bucketdb/bucketmanager.h b/storage/src/vespa/storage/bucketdb/bucketmanager.h index eacd0c8ca6a..268513d8934 100644 --- a/storage/src/vespa/storage/bucketdb/bucketmanager.h +++ b/storage/src/vespa/storage/bucketdb/bucketmanager.h @@ -34,7 +34,6 @@ class BucketManager : public StorageLink, { public: /** Type used for message queues */ - using CommandList = std::list<std::shared_ptr<api::StorageCommand>>; using BucketInfoRequestList = std::list<std::shared_ptr<api::RequestBucketInfoCommand>>; using BucketInfoRequestMap = std::unordered_map<document::BucketSpace, BucketInfoRequestList, document::BucketSpace::hash>; @@ -55,8 +54,7 @@ private: mutable std::mutex _queueProcessingLock; using ReplyQueue = std::vector<api::StorageReply::SP>; - using ConflictingBuckets = std::unordered_set<document::BucketId, - document::BucketId::hash>; + using ConflictingBuckets = std::unordered_set<document::BucketId, document::BucketId::xxhash>; ReplyQueue _queuedReplies; ConflictingBuckets _conflictingBuckets; /** @@ -80,9 +78,6 @@ private: framework::Thread::UP _thread; std::chrono::milliseconds _simulated_processing_delay; - BucketManager(const BucketManager&); - BucketManager& operator=(const BucketManager&); - class ScopedQueueDispatchGuard { BucketManager& _mgr; public: @@ -94,8 +89,9 @@ private: }; public: - explicit BucketManager(const config::ConfigUri&, - ServiceLayerComponentRegister&); + BucketManager(const config::ConfigUri&, ServiceLayerComponentRegister&); + BucketManager(const BucketManager&) = delete; + BucketManager& operator=(const BucketManager&) = delete; ~BucketManager(); void startWorkerThread(); @@ -127,8 +123,7 @@ private: void updateMinUsedBits(); bool onRequestBucketInfo(const std::shared_ptr<api::RequestBucketInfoCommand>&) override; - bool processRequestBucketInfoCommands(document::BucketSpace bucketSpace, - BucketInfoRequestList &reqs); + bool processRequestBucketInfoCommands(document::BucketSpace bucketSpace, BucketInfoRequestList &reqs); /** * Enqueue reply and add its bucket to the set of conflicting buckets iff @@ -199,42 +194,26 @@ private: * * Not thread safe. */ - bool replyConflictsWithConcurrentOperation( - const api::BucketReply& reply) const; - + bool replyConflictsWithConcurrentOperation(const api::BucketReply& reply) const; bool enqueueIfBucketHasConflicts(const api::BucketReply::SP& reply); - bool onUp(const std::shared_ptr<api::StorageMessage>&) override; - bool onSetSystemState( - const std::shared_ptr<api::SetSystemStateCommand>&) override; - bool onCreateBucket( - const std::shared_ptr<api::CreateBucketCommand>&) override; - bool onMergeBucket( - const std::shared_ptr<api::MergeBucketCommand>&) override; - bool onRemove( - const std::shared_ptr<api::RemoveCommand>&) override; - bool onRemoveReply( - const std::shared_ptr<api::RemoveReply>&) override; - bool onPut( - const std::shared_ptr<api::PutCommand>&) override; - bool onPutReply( - const std::shared_ptr<api::PutReply>&) override; - bool onUpdate( - const std::shared_ptr<api::UpdateCommand>&) override; - bool onUpdateReply( - const std::shared_ptr<api::UpdateReply>&) override; - bool onNotifyBucketChangeReply( - const std::shared_ptr<api::NotifyBucketChangeReply>&) override; + bool onSetSystemState(const std::shared_ptr<api::SetSystemStateCommand>&) override; + bool onCreateBucket(const std::shared_ptr<api::CreateBucketCommand>&) override; + bool onMergeBucket(const std::shared_ptr<api::MergeBucketCommand>&) override; + bool onRemove(const std::shared_ptr<api::RemoveCommand>&) override; + bool onRemoveReply(const std::shared_ptr<api::RemoveReply>&) override; + bool onPut(const std::shared_ptr<api::PutCommand>&) override; + bool onPutReply(const std::shared_ptr<api::PutReply>&) override; + bool onUpdate(const std::shared_ptr<api::UpdateCommand>&) override; + bool onUpdateReply(const std::shared_ptr<api::UpdateReply>&) override; + bool onNotifyBucketChangeReply(const std::shared_ptr<api::NotifyBucketChangeReply>&) override; bool verifyAndUpdateLastModified(api::StorageCommand& cmd, const document::Bucket& bucket, uint64_t lastModified); - bool onSplitBucketReply( - const std::shared_ptr<api::SplitBucketReply>&) override; - bool onJoinBucketsReply( - const std::shared_ptr<api::JoinBucketsReply>&) override; - bool onDeleteBucketReply( - const std::shared_ptr<api::DeleteBucketReply>&) override; + bool onSplitBucketReply(const std::shared_ptr<api::SplitBucketReply>&) override; + bool onJoinBucketsReply(const std::shared_ptr<api::JoinBucketsReply>&) override; + bool onDeleteBucketReply(const std::shared_ptr<api::DeleteBucketReply>&) override; }; } // storage diff --git a/storage/src/vespa/storage/distributor/distributor_bucket_space.h b/storage/src/vespa/storage/distributor/distributor_bucket_space.h index 3dfd1e1ce30..51f8f134edd 100644 --- a/storage/src/vespa/storage/distributor/distributor_bucket_space.h +++ b/storage/src/vespa/storage/distributor/distributor_bucket_space.h @@ -40,8 +40,8 @@ class DistributorBucketSpace { bool _merges_inhibited; std::shared_ptr<const lib::ClusterState> _pending_cluster_state; std::vector<bool> _available_nodes; - mutable vespalib::hash_map<document::BucketId, BucketOwnershipFlags, document::BucketId::hash> _ownerships; - mutable vespalib::hash_map<document::BucketId, IdealServiceLayerNodesBundle, document::BucketId::hash> _ideal_nodes; + mutable vespalib::hash_map<document::BucketId, BucketOwnershipFlags, document::BucketId::xxhash> _ownerships; + mutable vespalib::hash_map<document::BucketId, IdealServiceLayerNodesBundle, document::BucketId::xxhash> _ideal_nodes; void clear(); void enumerate_available_nodes(); |