aboutsummaryrefslogtreecommitdiff
path: root/src/zenstore/compactcas.cpp
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2025-03-06 17:27:59 +0100
committerStefan Boberg <[email protected]>2025-03-06 17:27:59 +0100
commit66e5d1f4e288e0c32f854ebe3b63584b42b83554 (patch)
treed67e9d358419b5baccd429d54988414e0d7cd7a6 /src/zenstore/compactcas.cpp
parentreduced memory churn using fixed_xxx containers (#236) (diff)
downloadzen-66e5d1f4e288e0c32f854ebe3b63584b42b83554.tar.xz
zen-66e5d1f4e288e0c32f854ebe3b63584b42b83554.zip
switched std::vector -> eastl::vector
Diffstat (limited to 'src/zenstore/compactcas.cpp')
-rw-r--r--src/zenstore/compactcas.cpp66
1 files changed, 33 insertions, 33 deletions
diff --git a/src/zenstore/compactcas.cpp b/src/zenstore/compactcas.cpp
index 2be0542db..2e331ab34 100644
--- a/src/zenstore/compactcas.cpp
+++ b/src/zenstore/compactcas.cpp
@@ -225,14 +225,14 @@ CasContainerStrategy::InsertChunk(IoBuffer Chunk, const IoHash& ChunkHash)
return InsertChunk(Chunk.Data(), Chunk.Size(), ChunkHash);
}
-std::vector<CasStore::InsertResult>
+eastl::vector<CasStore::InsertResult>
CasContainerStrategy::InsertChunks(std::span<IoBuffer> Chunks, std::span<IoHash> ChunkHashes)
{
ZEN_MEMSCOPE(GetCasContainerTag());
ZEN_ASSERT(Chunks.size() == ChunkHashes.size());
- std::vector<CasStore::InsertResult> Result(Chunks.size());
- std::vector<size_t> NewChunkIndexes;
+ eastl::vector<CasStore::InsertResult> Result(Chunks.size());
+ eastl::vector<size_t> NewChunkIndexes;
{
RwLock::SharedLockScope _(m_LocationMapLock);
for (size_t ChunkIndex = 0; ChunkIndex < ChunkHashes.size(); ChunkIndex++)
@@ -252,7 +252,7 @@ CasContainerStrategy::InsertChunks(std::span<IoBuffer> Chunks, std::span<IoHash>
return Result;
}
- std::vector<IoBuffer> Datas;
+ eastl::vector<IoBuffer> Datas;
for (size_t ChunkIndex : NewChunkIndexes)
{
const IoBuffer& Chunk = Chunks[ChunkIndex];
@@ -265,7 +265,7 @@ CasContainerStrategy::InsertChunks(std::span<IoBuffer> Chunks, std::span<IoHash>
size_t ChunkOffset = 0;
m_BlockStore.WriteChunks(Datas, m_PayloadAlignment, [&](std::span<BlockStoreLocation> Locations) {
ZEN_MEMSCOPE(GetCasContainerTag());
- std::vector<CasDiskIndexEntry> IndexEntries;
+ eastl::vector<CasDiskIndexEntry> IndexEntries;
for (const BlockStoreLocation& Location : Locations)
{
size_t ChunkIndex = NewChunkIndexes[ChunkOffset++];
@@ -330,9 +330,9 @@ CasContainerStrategy::IterateChunks(std::span<IoHash> ChunkHashes,
{
ZEN_MEMSCOPE(GetCasContainerTag());
- const size_t ChunkCount = ChunkHashes.size();
- std::vector<size_t> FoundChunkIndexes;
- std::vector<BlockStoreLocation> FoundChunkLocations;
+ const size_t ChunkCount = ChunkHashes.size();
+ eastl::vector<size_t> FoundChunkIndexes;
+ eastl::vector<BlockStoreLocation> FoundChunkLocations;
FoundChunkIndexes.reserve(ChunkCount);
FoundChunkLocations.reserve(ChunkCount);
{
@@ -395,7 +395,7 @@ CasContainerStrategy::IterateChunks(std::span<IoHash> ChunkHashes,
if (OptionalWorkerPool && (ChunkIndexes.size() > 3))
{
WorkLatch.AddCount(1);
- OptionalWorkerPool->ScheduleWork([&, ChunkIndexes = std::vector<size_t>(ChunkIndexes.begin(), ChunkIndexes.end())]() {
+ OptionalWorkerPool->ScheduleWork([&, ChunkIndexes = eastl::vector<size_t>(ChunkIndexes.begin(), ChunkIndexes.end())]() {
auto _ = MakeGuard([&WorkLatch]() { WorkLatch.CountDown(); });
if (!AsyncContinue)
{
@@ -455,11 +455,11 @@ CasContainerStrategy::ScrubStorage(ScrubContext& Ctx)
ZEN_INFO("scrubbing '{}'", m_BlocksBasePath);
- RwLock BadKeysLock;
- std::vector<IoHash> BadKeys;
- std::atomic_uint64_t ChunkCount{0}, ChunkBytes{0};
- std::vector<BlockStoreLocation> ChunkLocations;
- std::vector<IoHash> ChunkIndexToChunkHash;
+ RwLock BadKeysLock;
+ eastl::vector<IoHash> BadKeys;
+ std::atomic_uint64_t ChunkCount{0}, ChunkBytes{0};
+ eastl::vector<BlockStoreLocation> ChunkLocations;
+ eastl::vector<IoHash> ChunkIndexToChunkHash;
try
{
@@ -550,7 +550,7 @@ CasContainerStrategy::ScrubStorage(ScrubContext& Ctx)
{
// Deal with bad chunks by removing them from our lookup map
- std::vector<CasDiskIndexEntry> LogEntries;
+ eastl::vector<CasDiskIndexEntry> LogEntries;
LogEntries.reserve(BadKeys.size());
{
RwLock::ExclusiveLockScope IndexLock(m_LocationMapLock);
@@ -642,7 +642,7 @@ public:
{
BlockStoreCompactState BlockCompactState;
- std::vector<IoHash> BlockCompactStateKeys;
+ eastl::vector<IoHash> BlockCompactStateKeys;
BlockStore::BlockEntryCountMap BlocksToCompact =
m_CasContainerStrategy.m_BlockStore.GetBlocksToCompact(BlockUsage, Ctx.Settings.CompactBlockUsageThresholdPercent);
@@ -678,8 +678,8 @@ public:
BlockCompactState,
m_CasContainerStrategy.m_PayloadAlignment,
[&](const BlockStore::MovedChunksArray& MovedArray, uint64_t FreedDiskSpace) {
- std::vector<CasDiskIndexEntry> MovedEntries;
- RwLock::ExclusiveLockScope _(m_CasContainerStrategy.m_LocationMapLock);
+ eastl::vector<CasDiskIndexEntry> MovedEntries;
+ RwLock::ExclusiveLockScope _(m_CasContainerStrategy.m_LocationMapLock);
for (const std::pair<size_t, BlockStoreLocation>& Moved : MovedArray)
{
size_t ChunkIndex = Moved.first;
@@ -736,7 +736,7 @@ public:
class CasContainerReferencePruner : public GcReferencePruner
{
public:
- CasContainerReferencePruner(CasContainerStrategy& Owner, std::vector<IoHash>&& Cids)
+ CasContainerReferencePruner(CasContainerStrategy& Owner, eastl::vector<IoHash>&& Cids)
: m_CasContainerStrategy(Owner)
, m_Cids(std::move(Cids))
{
@@ -780,7 +780,7 @@ public:
{
if (Ctx.Settings.IsDeleteMode)
{
- std::vector<CasDiskIndexEntry> ExpiredEntries;
+ eastl::vector<CasDiskIndexEntry> ExpiredEntries;
ExpiredEntries.reserve(UnusedCids.size());
{
@@ -819,7 +819,7 @@ public:
private:
CasContainerStrategy& m_CasContainerStrategy;
- std::vector<IoHash> m_Cids;
+ eastl::vector<IoHash> m_Cids;
};
std::string
@@ -847,7 +847,7 @@ CasContainerStrategy::CreateReferencePruner(GcCtx& Ctx, GcReferenceStoreStats&)
NiceTimeSpanMs(Timer.GetElapsedTimeMs()));
});
- std::vector<IoHash> CidsToCheck;
+ eastl::vector<IoHash> CidsToCheck;
{
RwLock::SharedLockScope __(m_LocationMapLock);
if (m_LocationMap.empty())
@@ -878,9 +878,9 @@ CasContainerStrategy::CompactIndex(RwLock::ExclusiveLockScope&)
ZEN_MEMSCOPE(GetCasContainerTag());
ZEN_TRACE_CPU("CasContainer::CompactIndex");
- size_t EntryCount = m_LocationMap.size();
- LocationMap_t LocationMap;
- std::vector<BlockStoreDiskLocation> Locations;
+ size_t EntryCount = m_LocationMap.size();
+ LocationMap_t LocationMap;
+ eastl::vector<BlockStoreDiskLocation> Locations;
Locations.reserve(EntryCount);
LocationMap.reserve(EntryCount);
for (auto It : m_LocationMap)
@@ -945,8 +945,8 @@ CasContainerStrategy::MakeIndexSnapshot()
}
// Write the current state of the location map to a new index state
- std::vector<CasDiskIndexEntry> Entries;
- uint64_t IndexLogPosition = 0;
+ eastl::vector<CasDiskIndexEntry> Entries;
+ uint64_t IndexLogPosition = 0;
{
RwLock::SharedLockScope ___(m_LocationMapLock);
@@ -1042,7 +1042,7 @@ CasContainerStrategy::ReadIndexFile(const std::filesystem::path& IndexPath, uint
m_Locations.reserve(ExpectedEntryCount);
m_LocationMap.reserve(ExpectedEntryCount);
- std::vector<CasDiskIndexEntry> Entries;
+ eastl::vector<CasDiskIndexEntry> Entries;
Entries.resize(128 * 1024 / sizeof(CasDiskIndexEntry));
uint64_t RemainingEntries = Header.EntryCount;
@@ -1258,7 +1258,7 @@ TEST_CASE("compactcas.compact.gc")
const int kIterationCount = 1000;
- std::vector<IoHash> Keys(kIterationCount);
+ eastl::vector<IoHash> Keys(kIterationCount);
{
GcManager Gc;
@@ -1478,7 +1478,7 @@ TEST_CASE("compactcas.threadedinsert")
}
tsl::robin_set<IoHash, IoHash::Hasher> ChunksToDelete;
- std::vector<IoHash> KeepHashes(GcChunkHashes.begin(), GcChunkHashes.end());
+ eastl::vector<IoHash> KeepHashes(GcChunkHashes.begin(), GcChunkHashes.end());
size_t C = 0;
while (C < KeepHashes.size())
@@ -1503,7 +1503,7 @@ TEST_CASE("compactcas.threadedinsert")
auto DoGC = [](CasContainerStrategy& Cas,
const tsl::robin_set<IoHash, IoHash::Hasher>& ChunksToDelete,
- const std::vector<IoHash>& KeepHashes,
+ const eastl::vector<IoHash>& KeepHashes,
tsl::robin_set<IoHash, IoHash::Hasher>& GcChunkHashes) {
std::atomic_bool IsCancelledFlag = false;
GcCtx Ctx = {.Settings = {.CacheExpireTime = GcClock::Now() - std::chrono::hours(24),
@@ -1519,8 +1519,8 @@ TEST_CASE("compactcas.threadedinsert")
GcStats Stats;
GcStoreCompactor* Compactor =
Pruner->RemoveUnreferencedData(Ctx, Stats, [&](std::span<IoHash> References) -> std::span<IoHash> {
- std::vector<IoHash> Unreferenced;
- HashKeySet Retain;
+ eastl::vector<IoHash> Unreferenced;
+ HashKeySet Retain;
Retain.AddHashesToSet(KeepHashes);
for (const IoHash& ChunkHash : References)
{