aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2025-03-04 12:43:05 +0100
committerGitHub Enterprise <[email protected]>2025-03-04 12:43:05 +0100
commit5867d04117645cfd8e558ad6d7888e929ca6e816 (patch)
tree9e1046a7798afc38d0c699c196c33598bbe903af /src
parentstream decompress (#293) (diff)
downloadzen-5867d04117645cfd8e558ad6d7888e929ca6e816.tar.xz
zen-5867d04117645cfd8e558ad6d7888e929ca6e816.zip
do direct update of stats numbers (#294)
Diffstat (limited to 'src')
-rw-r--r--src/zen/cmds/builds_cmd.cpp37
1 files changed, 13 insertions, 24 deletions
diff --git a/src/zen/cmds/builds_cmd.cpp b/src/zen/cmds/builds_cmd.cpp
index a9852151f..132f5db86 100644
--- a/src/zen/cmds/builds_cmd.cpp
+++ b/src/zen/cmds/builds_cmd.cpp
@@ -3288,8 +3288,8 @@ namespace {
const CompositeBuffer& DecompressedBlockBuffer,
const ChunkedContentLookup& Lookup,
std::atomic<bool>* RemoteChunkIndexNeedsCopyFromSourceFlags,
- uint32_t& OutChunksComplete,
- uint64_t& OutBytesWritten)
+ std::atomic<uint32_t>& OutChunksComplete,
+ std::atomic<uint64_t>& OutBytesWritten)
{
std::vector<CompositeBuffer> ChunkBuffers;
struct WriteOpData
@@ -3447,7 +3447,7 @@ namespace {
std::span<const ChunkedContentLookup::ChunkSequenceLocation* const> ChunkTargets,
const CompositeBuffer& ChunkData,
WriteFileCache& OpenFileCache,
- uint64_t& OutBytesWritten)
+ std::atomic<uint64_t>& OutBytesWritten)
{
for (const ChunkedContentLookup::ChunkSequenceLocation* TargetPtr : ChunkTargets)
{
@@ -3639,16 +3639,14 @@ namespace {
{
WriteFileCache OpenFileCache;
- uint64_t TotalBytesWritten = 0;
WriteChunkToDisk(CacheFolderPath,
RemoteContent,
RemoteLookup,
ChunkTargetPtrs,
CompositeBuffer(Chunk),
OpenFileCache,
- TotalBytesWritten);
+ WriteToDiskBytes);
ChunksComplete++;
- WriteToDiskBytes += TotalBytesWritten;
}
}
@@ -3964,7 +3962,6 @@ namespace {
}
else
{
- uint64_t TotalBytesWritten = 0;
SharedBuffer Chunk =
Decompress(CompressedPart,
ChunkHash,
@@ -3978,9 +3975,8 @@ namespace {
ChunkTargetPtrs,
CompositeBuffer(Chunk),
OpenFileCache,
- TotalBytesWritten);
+ WriteToDiskBytes);
ChunkCountWritten++;
- WriteToDiskBytes += TotalBytesWritten;
}
}
if (!AbortFlag)
@@ -4240,21 +4236,14 @@ namespace {
ZEN_ASSERT_SLOW(BlockDescriptions[BlockIndex].BlockHash ==
IoHash::HashBuffer(DecompressedBlockBuffer));
- uint64_t BytesWrittenToDisk = 0;
- uint32_t ChunksReadFromBlock = 0;
- if (WriteBlockToDisk(CacheFolderPath,
- RemoteContent,
- SequenceIndexChunksLeftToWriteCounters,
- DecompressedBlockBuffer,
- RemoteLookup,
- RemoteChunkIndexNeedsCopyFromSourceFlags.data(),
- ChunksReadFromBlock,
- BytesWrittenToDisk))
- {
- WriteToDiskBytes += BytesWrittenToDisk;
- ChunkCountWritten += ChunksReadFromBlock;
- }
- else
+ if (!WriteBlockToDisk(CacheFolderPath,
+ RemoteContent,
+ SequenceIndexChunksLeftToWriteCounters,
+ DecompressedBlockBuffer,
+ RemoteLookup,
+ RemoteChunkIndexNeedsCopyFromSourceFlags.data(),
+ ChunkCountWritten,
+ WriteToDiskBytes))
{
throw std::runtime_error(
fmt::format("Block {} is malformed", BlockDescriptions[BlockIndex].BlockHash));