Skip to content

Commit

Permalink
add queries count metric per backend
Browse files Browse the repository at this point in the history
Summary: add queries count metric per backend

Reviewed By: lmvasquezg

Differential Revision: D64405723

fbshipit-source-id: 9cc7f3b4beb3ee0fb5cf693ce0906b594f1bb10f
  • Loading branch information
Liubov Dmitrieva authored and facebook-github-bot committed Oct 17, 2024
1 parent 5bf6cb8 commit 9a3efde
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 4 deletions.
8 changes: 4 additions & 4 deletions eden/scm/lib/cas-client/re-cas-common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ macro_rules! re_client {
let mut stats = CasFetchedStats::default();
for (backend, dstats) in download_stats_map {
match backend {
TStorageBackendType::ZDB => stats.total_bytes_zdb += dstats.bytes as u64,
TStorageBackendType::ZGATEWAY => stats.total_bytes_zgw += dstats.bytes as u64,
TStorageBackendType::MANIFOLD => stats.total_bytes_manifold += dstats.bytes as u64,
TStorageBackendType::HEDWIG => stats.total_bytes_hedwig += dstats.bytes as u64,
TStorageBackendType::ZDB => {stats.total_bytes_zdb += dstats.bytes as u64; stats.queries_zdb += dstats.queries_count as u64}
TStorageBackendType::ZGATEWAY => {stats.total_bytes_zgw += dstats.bytes as u64; stats.queries_zgw += dstats.queries_count as u64}
TStorageBackendType::MANIFOLD => {stats.total_bytes_manifold += dstats.bytes as u64; stats.queries_manifold += dstats.queries_count as u64}
TStorageBackendType::HEDWIG => {stats.total_bytes_hedwig += dstats.bytes as u64; stats.queries_hedwig += dstats.queries_count as u64 }
_ => {}
}
}
Expand Down
12 changes: 12 additions & 0 deletions eden/scm/lib/revisionstore/src/scmstore/file/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -835,6 +835,18 @@ impl FetchState {
self.metrics
.cas_backend
.hedwig_bytes(total_stats.total_bytes_hedwig);
self.metrics
.cas_backend
.zdb_queries(total_stats.queries_zdb);
self.metrics
.cas_backend
.zgw_queries(total_stats.queries_zgw);
self.metrics
.cas_backend
.manifold_queries(total_stats.queries_manifold);
self.metrics
.cas_backend
.hedwig_queries(total_stats.queries_hedwig);
}

pub(crate) fn fetch_lfs_remote(
Expand Down
32 changes: 32 additions & 0 deletions eden/scm/lib/revisionstore/src/scmstore/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,35 +227,63 @@ pub struct CasBackendMetrics {
/// Total number of bytes fetched from the CAS ZippyDb backend
zdb_bytes: u64,

/// Total number of queries to the CAS ZippyDb backend
zdb_queries: u64,

/// Total number of bytes fetched from the CAS ZGW backend
zgw_bytes: u64,

/// Total number of queries to the CAS ZGW backend
zgw_queries: u64,

/// Total number of bytes fetched from the CAS Manifold backend
manifold_bytes: u64,

/// Total number of queries to the CAS Manifold backend
manifold_queries: u64,

/// Total number of bytes fetched from the CAS Hedwig backend
hedwig_bytes: u64,

/// Total number of queries to the CAS Hedwig backend
hedwig_queries: u64,
}

impl CasBackendMetrics {
pub(crate) fn zdb_bytes(&mut self, bytes: u64) {
self.zdb_bytes += bytes;
}
pub(crate) fn zdb_queries(&mut self, queries: u64) {
self.zdb_queries += queries;
}
pub(crate) fn zgw_bytes(&mut self, bytes: u64) {
self.zgw_bytes += bytes;
}
pub(crate) fn zgw_queries(&mut self, queries: u64) {
self.zgw_queries += queries;
}
pub(crate) fn manifold_bytes(&mut self, bytes: u64) {
self.manifold_bytes += bytes;
}
pub(crate) fn manifold_queries(&mut self, queries: u64) {
self.manifold_queries += queries;
}
pub(crate) fn hedwig_bytes(&mut self, bytes: u64) {
self.hedwig_bytes += bytes;
}
pub(crate) fn hedwig_queries(&mut self, queries: u64) {
self.hedwig_queries += queries;
}
pub(crate) fn metrics(&self) -> impl Iterator<Item = (&'static str, usize)> {
[
("zdb.bytes", self.zdb_bytes as usize),
("zgw.bytes", self.zgw_bytes as usize),
("manifold.bytes", self.manifold_bytes as usize),
("hedwig.bytes", self.hedwig_bytes as usize),
("zdb.queries", self.zdb_queries as usize),
("zgw.queries", self.zgw_queries as usize),
("manifold.queries", self.manifold_queries as usize),
("hedwig.queries", self.hedwig_queries as usize),
]
.into_iter()
.filter(|&(_, v)| v != 0)
Expand All @@ -268,5 +296,9 @@ impl AddAssign for CasBackendMetrics {
self.zgw_bytes += rhs.zgw_bytes;
self.manifold_bytes += rhs.manifold_bytes;
self.hedwig_bytes += rhs.hedwig_bytes;
self.zdb_queries += rhs.zdb_queries;
self.zgw_queries += rhs.zgw_queries;
self.manifold_queries += rhs.manifold_queries;
self.hedwig_queries += rhs.hedwig_queries;
}
}
12 changes: 12 additions & 0 deletions eden/scm/lib/revisionstore/src/scmstore/tree/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,18 @@ impl FetchState {
self.metrics
.cas_backend
.hedwig_bytes(total_stats.total_bytes_hedwig);
self.metrics
.cas_backend
.zdb_queries(total_stats.queries_zdb);
self.metrics
.cas_backend
.zgw_queries(total_stats.queries_zgw);
self.metrics
.cas_backend
.manifold_queries(total_stats.queries_manifold);
self.metrics
.cas_backend
.hedwig_queries(total_stats.queries_hedwig);
}
}

Expand Down
8 changes: 8 additions & 0 deletions eden/scm/lib/types/src/cas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ pub struct CasFetchedStats {
pub total_bytes_zgw: u64,
pub total_bytes_manifold: u64,
pub total_bytes_hedwig: u64,
pub queries_zdb: u64,
pub queries_zgw: u64,
pub queries_manifold: u64,
pub queries_hedwig: u64,
}

impl CasFetchedStats {
Expand All @@ -47,5 +51,9 @@ impl CasFetchedStats {
self.total_bytes_zgw += other.total_bytes_zgw;
self.total_bytes_manifold += other.total_bytes_manifold;
self.total_bytes_hedwig += other.total_bytes_hedwig;
self.queries_zdb += other.queries_zdb;
self.queries_zgw += other.queries_zgw;
self.queries_manifold += other.queries_manifold;
self.queries_hedwig += other.queries_hedwig;
}
}

0 comments on commit 9a3efde

Please sign in to comment.