aboutsummaryrefslogtreecommitdiff
path: root/src/zenstore/filecas.cpp
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2023-09-15 07:36:58 -0400
committerGitHub <[email protected]>2023-09-15 13:36:58 +0200
commit6163987f858597e92e68a61ed35be35bd4e7a552 (patch)
tree94e78c3865f7f288df041636f9471b5a1511792b /src/zenstore/filecas.cpp
parentupdated CHANGELOG.md release versions (diff)
downloadzen-6163987f858597e92e68a61ed35be35bd4e7a552.tar.xz
zen-6163987f858597e92e68a61ed35be35bd4e7a552.zip
add more trace scopes (#362)
* more trace scopes * Make sure ReplayLogEntries uses the correct size for oplog buffer * changelog
Diffstat (limited to 'src/zenstore/filecas.cpp')
-rw-r--r--src/zenstore/filecas.cpp55
1 files changed, 32 insertions, 23 deletions
diff --git a/src/zenstore/filecas.cpp b/src/zenstore/filecas.cpp
index 56a840701..ce0dd7ce6 100644
--- a/src/zenstore/filecas.cpp
+++ b/src/zenstore/filecas.cpp
@@ -241,7 +241,7 @@ FileCasStrategy::InsertChunk(IoBuffer Chunk, const IoHash& ChunkHash, CasStore::
return CasStore::InsertResult{.New = false};
}
}
- return InsertChunk(Chunk.Data(), Chunk.Size(), ChunkHash);
+ return InsertChunkData(Chunk.Data(), Chunk.Size(), ChunkHash);
}
// File-based chunks have special case handling whereby we move the file into
@@ -251,6 +251,8 @@ FileCasStrategy::InsertChunk(IoBuffer Chunk, const IoHash& ChunkHash, CasStore::
bool IsWholeFile = Chunk.IsWholeFile();
if (IsWholeFile && Chunk.GetFileReference(/* out */ FileRef))
{
+ ZEN_TRACE_CPU("FileCas::InsertChunk::Move");
+
{
bool Exists = true;
{
@@ -271,6 +273,8 @@ FileCasStrategy::InsertChunk(IoBuffer Chunk, const IoHash& ChunkHash, CasStore::
const HANDLE ChunkFileHandle = FileRef.FileHandle;
// See if file already exists
{
+ ZEN_TRACE_CPU("FileCas::InsertChunk::Exists");
+
windows::FileHandle PayloadFile;
if (HRESULT hRes = PayloadFile.Create(Name.ShardedPath.c_str(), GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING); SUCCEEDED(hRes))
@@ -486,11 +490,11 @@ FileCasStrategy::InsertChunk(IoBuffer Chunk, const IoHash& ChunkHash, CasStore::
#endif // ZEN_PLATFORM_*
}
- return InsertChunk(Chunk.Data(), Chunk.Size(), ChunkHash);
+ return InsertChunkData(Chunk.Data(), Chunk.Size(), ChunkHash);
}
CasStore::InsertResult
-FileCasStrategy::InsertChunk(const void* const ChunkData, const size_t ChunkSize, const IoHash& ChunkHash)
+FileCasStrategy::InsertChunkData(const void* const ChunkData, const size_t ChunkSize, const IoHash& ChunkHash)
{
ZEN_TRACE_CPU("FileCas::InsertChunkData");
@@ -504,6 +508,8 @@ FileCasStrategy::InsertChunk(const void* const ChunkData, const size_t ChunkSize
}
}
+ ZEN_TRACE_CPU("FileCas::InsertChunkData::Write");
+
ShardingHelper Name(m_RootDirectory.c_str(), ChunkHash);
// See if file already exists
@@ -696,6 +702,8 @@ FileCasStrategy::InsertChunk(const void* const ChunkData, const size_t ChunkSize
IoBuffer
FileCasStrategy::FindChunk(const IoHash& ChunkHash)
{
+ ZEN_TRACE_CPU("FileCas::FindChunk");
+
ZEN_ASSERT(m_IsInitialized);
{
@@ -706,8 +714,6 @@ FileCasStrategy::FindChunk(const IoHash& ChunkHash)
}
}
- ZEN_TRACE_CPU("FileCas::FindChunk");
-
ShardingHelper Name(m_RootDirectory.c_str(), ChunkHash);
RwLock::SharedLockScope _(LockForHash(ChunkHash));
@@ -914,25 +920,28 @@ FileCasStrategy::CollectGarbage(GcContext& GcCtx)
NiceBytes(OldTotalSize));
});
- IterateChunks([&](const IoHash& Hash, IoBuffer&& Payload) {
- bool KeepThis = false;
- CandidateCas[0] = Hash;
- GcCtx.FilterCids(CandidateCas, [&](const IoHash& Hash) {
- ZEN_UNUSED(Hash);
- KeepThis = true;
- });
-
- const uint64_t FileSize = Payload.GetSize();
-
- if (!KeepThis)
- {
- ChunksToDelete.push_back(Hash);
- ChunksToDeleteBytes.fetch_add(FileSize);
- }
+ {
+ ZEN_TRACE_CPU("FileCas::CollectGarbage::Filter");
+ IterateChunks([&](const IoHash& Hash, IoBuffer&& Payload) {
+ bool KeepThis = false;
+ CandidateCas[0] = Hash;
+ GcCtx.FilterCids(CandidateCas, [&](const IoHash& Hash) {
+ ZEN_UNUSED(Hash);
+ KeepThis = true;
+ });
+
+ const uint64_t FileSize = Payload.GetSize();
+
+ if (!KeepThis)
+ {
+ ChunksToDelete.push_back(Hash);
+ ChunksToDeleteBytes.fetch_add(FileSize);
+ }
- ++ChunkCount;
- ChunkBytes.fetch_add(FileSize);
- });
+ ++ChunkCount;
+ ChunkBytes.fetch_add(FileSize);
+ });
+ }
// TODO, any entires we did not encounter during our IterateChunks should be removed from the index