diff options
| author | Stefan Boberg <[email protected]> | 2025-03-06 17:27:59 +0100 |
|---|---|---|
| committer | Stefan Boberg <[email protected]> | 2025-03-06 17:27:59 +0100 |
| commit | 66e5d1f4e288e0c32f854ebe3b63584b42b83554 (patch) | |
| tree | d67e9d358419b5baccd429d54988414e0d7cd7a6 /src/zenstore/filecas.cpp | |
| parent | reduced memory churn using fixed_xxx containers (#236) (diff) | |
| download | zen-66e5d1f4e288e0c32f854ebe3b63584b42b83554.tar.xz zen-66e5d1f4e288e0c32f854ebe3b63584b42b83554.zip | |
switched std::vector -> eastl::vector
Diffstat (limited to 'src/zenstore/filecas.cpp')
| -rw-r--r-- | src/zenstore/filecas.cpp | 78 |
1 files changed, 40 insertions, 38 deletions
diff --git a/src/zenstore/filecas.cpp b/src/zenstore/filecas.cpp index 34db51aa9..36942b515 100644 --- a/src/zenstore/filecas.cpp +++ b/src/zenstore/filecas.cpp @@ -204,7 +204,7 @@ FileCasStrategy::Initialize(const std::filesystem::path& RootDirectory, bool IsN } return false; } - std::vector<std::filesystem::path> ShardedRoots; + eastl::vector<std::filesystem::path> ShardedRoots; } CasVisitor; FileSystemTraversal Traversal; @@ -619,8 +619,8 @@ FileCasStrategy::IterateChunks(std::span<IoHash> ChunkHashes, const std::function<bool(size_t Index, const IoBuffer& Payload)>& AsyncCallback, WorkerThreadPool* OptionalWorkerPool) { - std::vector<size_t> FoundChunkIndexes; - std::vector<uint64_t> FoundChunkExpectedSizes; + eastl::vector<size_t> FoundChunkIndexes; + eastl::vector<uint64_t> FoundChunkExpectedSizes; { RwLock::SharedLockScope _(m_Lock); for (size_t ChunkIndex = 0; ChunkIndex < ChunkHashes.size(); ChunkIndex++) @@ -697,8 +697,8 @@ FileCasStrategy::IterateChunks(std::function<void(const IoHash& Hash, IoBuffer&& ZEN_ASSERT(m_IsInitialized); - std::vector<IoHash> RawHashes; - std::vector<uint64_t> ExpectedSizes; + eastl::vector<IoHash> RawHashes; + eastl::vector<uint64_t> ExpectedSizes; { RwLock::SharedLockScope _(m_Lock); @@ -748,14 +748,14 @@ FileCasStrategy::ScrubStorage(ScrubContext& Ctx) ZEN_ASSERT(m_IsInitialized); - std::vector<IoHash> BadHashes; - uint64_t ChunkCount{0}, ChunkBytes{0}; + eastl::vector<IoHash> BadHashes; + uint64_t ChunkCount{0}, ChunkBytes{0}; int DiscoveredFilesNotInIndex = 0; { - std::vector<FileCasStrategy::FileCasIndexEntry> ScannedEntries = FileCasStrategy::ScanFolderForCasFiles(m_RootDirectory); - RwLock::ExclusiveLockScope _(m_Lock); + eastl::vector<FileCasStrategy::FileCasIndexEntry> ScannedEntries = FileCasStrategy::ScanFolderForCasFiles(m_RootDirectory); + RwLock::ExclusiveLockScope _(m_Lock); for (const FileCasStrategy::FileCasIndexEntry& Entry : ScannedEntries) { if (m_Index.insert_or_assign(Entry.Key, IndexEntry{.Size = Entry.Size}).second) @@ -959,8 +959,8 @@ FileCasStrategy::MakeIndexSnapshot() } // Write the current state of the location map to a new index state - std::vector<FileCasIndexEntry> Entries; - uint64_t IndexLogPosition = 0; + eastl::vector<FileCasIndexEntry> Entries; + uint64_t IndexLogPosition = 0; { RwLock::SharedLockScope __(m_Lock); @@ -1031,7 +1031,7 @@ FileCasStrategy::ReadIndexFile(const std::filesystem::path& IndexPath, uint32_t& using namespace filecas::impl; - std::vector<FileCasIndexEntry> Entries; + eastl::vector<FileCasIndexEntry> Entries; if (std::filesystem::is_regular_file(IndexPath)) { Stopwatch Timer; @@ -1093,7 +1093,7 @@ FileCasStrategy::ReadIndexFile(const std::filesystem::path& IndexPath, uint32_t& std::filesystem::path LogPath = GetLogPath(m_RootDirectory); - std::vector<FileCasStrategy::FileCasIndexEntry> ScannedEntries = FileCasStrategy::ScanFolderForCasFiles(m_RootDirectory); + eastl::vector<FileCasStrategy::FileCasIndexEntry> ScannedEntries = FileCasStrategy::ScanFolderForCasFiles(m_RootDirectory); CasLog.Open(LogPath, CasLogFile::Mode::kTruncate); std::string InvalidEntryReason; for (const FileCasStrategy::FileCasIndexEntry& Entry : ScannedEntries) @@ -1163,17 +1163,19 @@ FileCasStrategy::ReadLog(const std::filesystem::path& LogPath, uint64_t SkipEntr return 0; } -std::vector<FileCasStrategy::FileCasIndexEntry> +eastl::vector<FileCasStrategy::FileCasIndexEntry> FileCasStrategy::ScanFolderForCasFiles(const std::filesystem::path& RootDir) { ZEN_TRACE_CPU("FileCas::ScanFolderForCasFiles"); using namespace filecas::impl; - std::vector<FileCasIndexEntry> Entries; + eastl::vector<FileCasIndexEntry> Entries; struct Visitor : public FileSystemTraversal::TreeVisitor { - Visitor(const std::filesystem::path& RootDir, std::vector<FileCasIndexEntry>& Entries) : RootDirectory(RootDir), Entries(Entries) {} + Visitor(const std::filesystem::path& RootDir, eastl::vector<FileCasIndexEntry>& Entries) : RootDirectory(RootDir), Entries(Entries) + { + } virtual void VisitFile(const std::filesystem::path& Parent, const path_view& File, uint64_t FileSize, uint32_t, uint64_t) override { std::filesystem::path RelPath = std::filesystem::relative(Parent, RootDirectory); @@ -1202,8 +1204,8 @@ FileCasStrategy::ScanFolderForCasFiles(const std::filesystem::path& RootDir) virtual bool VisitDirectory(const std::filesystem::path&, const path_view&, uint32_t) override { return true; } - const std::filesystem::path& RootDirectory; - std::vector<FileCasIndexEntry>& Entries; + const std::filesystem::path& RootDirectory; + eastl::vector<FileCasIndexEntry>& Entries; } CasVisitor{RootDir, Entries}; FileSystemTraversal Traversal; @@ -1214,7 +1216,7 @@ FileCasStrategy::ScanFolderForCasFiles(const std::filesystem::path& RootDir) class FileCasStoreCompactor : public GcStoreCompactor { public: - FileCasStoreCompactor(FileCasStrategy& Owner, std::vector<IoHash>&& ReferencesToClean) + FileCasStoreCompactor(FileCasStrategy& Owner, eastl::vector<IoHash>&& ReferencesToClean) : m_FileCasStrategy(Owner) , m_ReferencesToClean(std::move(ReferencesToClean)) { @@ -1352,14 +1354,14 @@ public: virtual std::string GetGcName(GcCtx& Ctx) override { return m_FileCasStrategy.GetGcName(Ctx); } private: - FileCasStrategy& m_FileCasStrategy; - std::vector<IoHash> m_ReferencesToClean; + FileCasStrategy& m_FileCasStrategy; + eastl::vector<IoHash> m_ReferencesToClean; }; class FileCasReferencePruner : public GcReferencePruner { public: - FileCasReferencePruner(FileCasStrategy& Owner, std::vector<IoHash>&& Cids) : m_FileCasStrategy(Owner), m_Cids(std::move(Cids)) {} + FileCasReferencePruner(FileCasStrategy& Owner, eastl::vector<IoHash>&& Cids) : m_FileCasStrategy(Owner), m_Cids(std::move(Cids)) {} virtual std::string GetGcName(GcCtx& Ctx) override { return m_FileCasStrategy.GetGcName(Ctx); } @@ -1397,7 +1399,7 @@ public: if (Ctx.Settings.IsDeleteMode) { - std::vector<FileCasStrategy::FileCasIndexEntry> ExpiredEntries; + eastl::vector<FileCasStrategy::FileCasIndexEntry> ExpiredEntries; ExpiredEntries.reserve(UnusedCids.size()); { RwLock::ExclusiveLockScope __(m_FileCasStrategy.m_Lock); @@ -1432,12 +1434,12 @@ public: } } - return new FileCasStoreCompactor(m_FileCasStrategy, std::vector<IoHash>(UnusedCids.begin(), UnusedCids.end())); + return new FileCasStoreCompactor(m_FileCasStrategy, eastl::vector<IoHash>(UnusedCids.begin(), UnusedCids.end())); } private: - FileCasStrategy& m_FileCasStrategy; - std::vector<IoHash> m_Cids; + FileCasStrategy& m_FileCasStrategy; + eastl::vector<IoHash> m_Cids; }; std::string @@ -1455,15 +1457,15 @@ FileCasStrategy::CreateReferencePruner(GcCtx& Ctx, GcReferenceStoreStats&) auto Log = [&Ctx]() { return Ctx.Logger; }; - Stopwatch Timer; - const auto _ = MakeGuard([&] { - if (!Ctx.Settings.Verbose) - { - return; - } - ZEN_INFO("GCV2: filecas [CREATE PRUNER] '{}' in {}", m_RootDirectory, NiceTimeSpanMs(Timer.GetElapsedTimeMs())); - }); - std::vector<IoHash> CidsToCheck; + Stopwatch Timer; + const auto _ = MakeGuard([&] { + if (!Ctx.Settings.Verbose) + { + return; + } + ZEN_INFO("GCV2: filecas [CREATE PRUNER] '{}' in {}", m_RootDirectory, NiceTimeSpanMs(Timer.GetElapsedTimeMs())); + }); + eastl::vector<IoHash> CidsToCheck; { RwLock::SharedLockScope __(m_Lock); if (m_Index.empty()) @@ -1740,7 +1742,7 @@ TEST_CASE("cas.file.move") # if 0 SUBCASE("stresstest") { - std::vector<IoHash> PayloadHashes; + eastl::vector<IoHash> PayloadHashes; const int kWorkers = 64; const int kItemCount = 128; @@ -1761,7 +1763,7 @@ TEST_CASE("cas.file.move") std::barrier Sync{kWorkers}; auto PopulateAll = [&](int w) { - std::vector<IoBuffer> Buffers; + eastl::vector<IoBuffer> Buffers; for (int i = 0; i < kItemCount; ++i) { @@ -1773,7 +1775,7 @@ TEST_CASE("cas.file.move") } }; - std::vector<std::jthread> Threads; + eastl::vector<std::jthread> Threads; for (int i = 0; i < kWorkers; ++i) { |