summaryrefslogtreecommitdiff
path: root/src/mongo/db
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2017-07-03 10:44:27 -0400
committerBenety Goh <benety@mongodb.com>2017-07-03 10:44:27 -0400
commit5a933be9235b7d02bb5c790c7ff7eba3a867c43a (patch)
tree20bd1fba88db73c6ad32906bdc72bd5b35e6d028 /src/mongo/db
parent3fd1d565b0dd8863be687843746b2cd7e5860377 (diff)
downloadmongo-5a933be9235b7d02bb5c790c7ff7eba3a867c43a.tar.gz
Revert "SERVER-29462 Align locks in mongo::Paritioned to avoid false sharing"
This reverts commit edc858ca3a32974c07f027e6860a52ac6e89039b.
Diffstat (limited to 'src/mongo/db')
-rw-r--r--src/mongo/db/catalog/util/partitioned.h18
1 files changed, 5 insertions, 13 deletions
diff --git a/src/mongo/db/catalog/util/partitioned.h b/src/mongo/db/catalog/util/partitioned.h
index ab960cc7cc1..475ea415f48 100644
--- a/src/mongo/db/catalog/util/partitioned.h
+++ b/src/mongo/db/catalog/util/partitioned.h
@@ -29,7 +29,6 @@
#pragma once
#include <algorithm>
-#include <array>
#include <cstdlib>
#include <iterator>
#include <memory>
@@ -40,9 +39,7 @@
#include "mongo/platform/atomic_word.h"
#include "mongo/stdx/memory.h"
#include "mongo/stdx/mutex.h"
-#include "mongo/stdx/new.h"
#include "mongo/util/assert_util.h"
-#include "mongo/util/with_alignment.h"
namespace mongo {
@@ -103,8 +100,6 @@ struct Partitioner {
namespace partitioned_detail {
-using CacheAlignedMutex = CacheAligned<stdx::mutex>;
-
template <typename Key, typename Value>
Key getKey(const std::pair<Key, Value>& pair) {
return std::get<0>(pair);
@@ -115,10 +110,9 @@ Key getKey(const Key& key) {
return key;
}
-template <typename T>
-inline std::vector<stdx::unique_lock<stdx::mutex>> lockAllPartitions(T& mutexes) {
+inline std::vector<stdx::unique_lock<stdx::mutex>> lockAllPartitions(
+ std::vector<stdx::mutex>& mutexes) {
std::vector<stdx::unique_lock<stdx::mutex>> result;
- result.reserve(mutexes.size());
std::transform(mutexes.begin(), mutexes.end(), std::back_inserter(result), [](auto&& mutex) {
return stdx::unique_lock<stdx::mutex>{mutex};
});
@@ -381,14 +375,12 @@ public:
/**
* Constructs a partitioned version of a AssociativeContainer, with `nPartitions` partitions.
*/
- Partitioned() = default;
+ Partitioned() : _mutexes(nPartitions), _partitions(nPartitions) {}
private:
// These two vectors parallel each other, but we keep them separate so that we can return an
// iterator over `_partitions` from within All.
- mutable std::array<partitioned_detail::CacheAlignedMutex, nPartitions> _mutexes;
-
- using CacheAlignedAssociativeContainer = CacheAligned<AssociativeContainer>;
- std::array<CacheAlignedAssociativeContainer, nPartitions> _partitions;
+ mutable std::vector<stdx::mutex> _mutexes;
+ std::vector<AssociativeContainer> _partitions;
};
} // namespace mongo