blob: dda8af6b209136ad647e7a3e10c6b90eac4ea492 [file] [log] [blame] [edit]
// Copyright 2022 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "src/storage/blobfs/metrics/compression_metrics.h"
#include <lib/inspect/cpp/vmo/types.h>
#include "src/storage/blobfs/format.h"
#include "src/storage/blobfs/node_finder.h"
namespace blobfs {
void CompressionMetrics::Update(const InodePtr& inode) {
static_assert(kBlobFlagMaskAnyCompression == kBlobFlagChunkCompressed,
"Need to update compression stats to handle multiple formats.");
if (inode->header.IsCompressedZstdChunked()) {
zstd_chunked_bytes_ += inode->blob_size;
} else {
uncompressed_bytes_ += inode->blob_size;
}
}
CompressionMetrics::Properties CompressionMetrics::Attach(inspect::Node& node) const {
return CompressionMetrics::Properties{
.uncompressed_bytes = node.CreateUint("uncompressed_bytes", uncompressed_bytes_),
.zstd_chunked_bytes = node.CreateUint("zstd_chunked_bytes", zstd_chunked_bytes_),
};
}
} // namespace blobfs