aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2023-08-21 13:09:37 +0200
committerGitHub <[email protected]>2023-08-21 13:09:37 +0200
commit21066f050050d1e7141975e70f557de91bae1a2a (patch)
tree54854a632e0a7b85f4217a5dafcb54f61480e335 /src
parentuse atexit hook to shut down tracing (#369) (diff)
downloadzen-21066f050050d1e7141975e70f557de91bae1a2a.tar.xz
zen-21066f050050d1e7141975e70f557de91bae1a2a.zip
use robinmap in compact cas (#368)
* Use robin-map in compactcas for 30% faster CasContainerStrategy::CollectGarbage * use robin_set in ProjectStore::Oplog::GatherReferences and BlockStore::ReclaimSpace * changelog
Diffstat (limited to 'src')
-rw-r--r--src/zenserver/projectstore/projectstore.cpp9
-rw-r--r--src/zenstore/blockstore.cpp17
-rw-r--r--src/zenstore/compactcas.cpp1
-rw-r--r--src/zenstore/compactcas.h11
4 files changed, 24 insertions, 14 deletions
diff --git a/src/zenserver/projectstore/projectstore.cpp b/src/zenserver/projectstore/projectstore.cpp
index 421a6486f..06d5221c4 100644
--- a/src/zenserver/projectstore/projectstore.cpp
+++ b/src/zenserver/projectstore/projectstore.cpp
@@ -26,6 +26,7 @@
ZEN_THIRD_PARTY_INCLUDES_START
#include <cpr/cpr.h>
+#include <tsl/robin_set.h>
#include <xxh3.h>
ZEN_THIRD_PARTY_INCLUDES_END
@@ -448,7 +449,7 @@ ProjectStore::Oplog::GatherReferences(GcContext& GcCtx)
{
ZEN_TRACE_CPU("ProjectStore::Oplog::GatherReferences");
- std::unordered_set<IoHash> AttachmentHashes;
+ tsl::robin_set<IoHash> AttachmentHashes;
IterateOplog([&](CbObject Op) {
Op.IterateAttachments([&](CbFieldView Visitor) {
IoHash Attachment = Visitor.AsAttachment();
@@ -2235,9 +2236,9 @@ ProjectStore::WriteOplog(const std::string_view ProjectId, const std::string_vie
return {HttpResponseCode::BadRequest, "Invalid payload format"};
}
- CidStore& ChunkStore = m_CidStore;
- RwLock AttachmentsLock;
- std::unordered_set<IoHash, IoHash::Hasher> Attachments;
+ CidStore& ChunkStore = m_CidStore;
+ RwLock AttachmentsLock;
+ tsl::robin_set<IoHash, IoHash::Hasher> Attachments;
auto HasAttachment = [&ChunkStore](const IoHash& RawHash) { return ChunkStore.ContainsChunk(RawHash); };
auto OnNeedBlock = [&AttachmentsLock, &Attachments](const IoHash& BlockHash, const std::vector<IoHash>&& ChunkHashes) {
diff --git a/src/zenstore/blockstore.cpp b/src/zenstore/blockstore.cpp
index 997774ebe..d1490dce2 100644
--- a/src/zenstore/blockstore.cpp
+++ b/src/zenstore/blockstore.cpp
@@ -10,6 +10,11 @@
#include <algorithm>
+ZEN_THIRD_PARTY_INCLUDES_START
+#include <tsl/robin_map.h>
+#include <tsl/robin_set.h>
+ZEN_THIRD_PARTY_INCLUDES_END
+
#if ZEN_WITH_TESTS
# include <zencore/compactbinarybuilder.h>
# include <zencore/testing.h>
@@ -190,7 +195,7 @@ BlockStore::Prune(const std::vector<BlockStoreLocation>& KnownLocations)
RwLock::ExclusiveLockScope InsertLock(m_InsertLock);
- std::unordered_set<uint32_t> KnownBlocks;
+ tsl::robin_set<uint32_t> KnownBlocks;
for (const auto& Entry : KnownLocations)
{
KnownBlocks.insert(Entry.BlockIndex);
@@ -391,16 +396,16 @@ BlockStore::ReclaimSpace(const ReclaimSnapshotState& Snapshot,
return;
}
- std::unordered_set<size_t> KeepChunkMap;
+ tsl::robin_set<size_t> KeepChunkMap;
KeepChunkMap.reserve(KeepChunkIndexes.size());
for (size_t KeepChunkIndex : KeepChunkIndexes)
{
KeepChunkMap.insert(KeepChunkIndex);
}
- std::unordered_map<uint32_t, size_t> BlockIndexToChunkMapIndex;
- std::vector<ChunkIndexArray> BlockKeepChunks;
- std::vector<ChunkIndexArray> BlockDeleteChunks;
+ tsl::robin_map<uint32_t, size_t> BlockIndexToChunkMapIndex;
+ std::vector<ChunkIndexArray> BlockKeepChunks;
+ std::vector<ChunkIndexArray> BlockDeleteChunks;
BlockIndexToChunkMapIndex.reserve(BlockCount);
BlockKeepChunks.reserve(BlockCount);
@@ -445,7 +450,7 @@ BlockStore::ReclaimSpace(const ReclaimSnapshotState& Snapshot,
DeleteCount++;
}
- std::unordered_set<uint32_t> BlocksToReWrite;
+ tsl::robin_set<uint32_t> BlocksToReWrite;
BlocksToReWrite.reserve(BlockIndexToChunkMapIndex.size());
for (const auto& Entry : BlockIndexToChunkMapIndex)
{
diff --git a/src/zenstore/compactcas.cpp b/src/zenstore/compactcas.cpp
index e9037b16c..fe31ad759 100644
--- a/src/zenstore/compactcas.cpp
+++ b/src/zenstore/compactcas.cpp
@@ -442,6 +442,7 @@ CasContainerStrategy::CollectGarbage(GcContext& GcCtx)
BlockStore::ChunkIndexArray KeepChunkIndexes;
std::vector<IoHash> ChunkIndexToChunkHash;
ChunkLocations.reserve(TotalChunkCount);
+ KeepChunkIndexes.reserve(TotalChunkCount);
ChunkIndexToChunkHash.reserve(TotalChunkCount);
GcCtx.FilterCids(TotalChunkHashes, [&](const IoHash& ChunkHash, bool Keep) {
diff --git a/src/zenstore/compactcas.h b/src/zenstore/compactcas.h
index b149fd682..eff9cc135 100644
--- a/src/zenstore/compactcas.h
+++ b/src/zenstore/compactcas.h
@@ -11,7 +11,10 @@
#include <atomic>
#include <limits>
-#include <unordered_map>
+
+ZEN_THIRD_PARTY_INCLUDES_START
+#include <tsl/robin_map.h>
+ZEN_THIRD_PARTY_INCLUDES_END
namespace spdlog {
class logger;
@@ -88,9 +91,9 @@ private:
std::filesystem::path m_BlocksBasePath;
BlockStore m_BlockStore;
- RwLock m_LocationMapLock;
- typedef std::unordered_map<IoHash, BlockStoreDiskLocation, IoHash::Hasher> LocationMap_t;
- LocationMap_t m_LocationMap;
+ RwLock m_LocationMapLock;
+ typedef tsl::robin_map<IoHash, BlockStoreDiskLocation, IoHash::Hasher> LocationMap_t;
+ LocationMap_t m_LocationMap;
};
void compactcas_forcelink();