-
Notifications
You must be signed in to change notification settings - Fork 285
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
scmstore: instrument tree store with counters
Summary: Add basic counters for tree fetch counts and times. I didn't add anything specific for the aux data prefetching yet since that didn't fit well into the existing counters. Reviewed By: zzl0 Differential Revision: D55372723 fbshipit-source-id: 2908327963a6fecc90a09de64aec8b180ae37b12
- Loading branch information
1 parent
35c52ca
commit 096343c
Showing
4 changed files
with
155 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This software may be used and distributed according to the terms of the | ||
* GNU General Public License version 2. | ||
*/ | ||
|
||
use std::ops::AddAssign; | ||
use std::sync::Arc; | ||
|
||
use parking_lot::RwLock; | ||
#[cfg(feature = "ods")] | ||
use stats::prelude::*; | ||
|
||
use crate::scmstore::metrics::namespaced; | ||
use crate::scmstore::metrics::FetchMetrics; | ||
use crate::scmstore::metrics::LocalAndCacheFetchMetrics; | ||
|
||
#[derive(Clone, Debug, Default)] | ||
pub struct TreeStoreFetchMetrics { | ||
pub(crate) indexedlog: LocalAndCacheFetchMetrics, | ||
pub(crate) aux: LocalAndCacheFetchMetrics, | ||
pub(crate) edenapi: FetchMetrics, | ||
} | ||
|
||
impl AddAssign for TreeStoreFetchMetrics { | ||
fn add_assign(&mut self, rhs: Self) { | ||
self.indexedlog += rhs.indexedlog; | ||
self.aux += rhs.aux; | ||
self.edenapi += rhs.edenapi; | ||
} | ||
} | ||
|
||
impl TreeStoreFetchMetrics { | ||
fn metrics(&self) -> impl Iterator<Item = (String, usize)> { | ||
namespaced("indexedlog", self.indexedlog.metrics()) | ||
.chain(namespaced("aux", self.aux.metrics())) | ||
.chain(namespaced("edenapi", self.edenapi.metrics())) | ||
} | ||
|
||
/// Update ODS stats. | ||
/// This assumes that fbinit was called higher up the stack. | ||
/// It is meant to be used when called from eden which uses the `revisionstore` with | ||
/// the `ods` feature flag. | ||
#[cfg(feature = "ods")] | ||
pub(crate) fn update_ods(&self) -> anyhow::Result<()> { | ||
for (metric, value) in self.metrics() { | ||
// SAFETY: this is called from C++ and was init'd there | ||
unsafe { | ||
let fb = fbinit::assume_init(); | ||
STATS::fetch.increment_value(fb, value.try_into()?, (metric,)); | ||
} | ||
} | ||
Ok(()) | ||
} | ||
|
||
#[cfg(not(feature = "ods"))] | ||
pub(crate) fn update_ods(&self) -> anyhow::Result<()> { | ||
Ok(()) | ||
} | ||
} | ||
|
||
#[derive(Debug, Default, Clone)] | ||
pub struct TreeStoreMetrics { | ||
pub(crate) fetch: TreeStoreFetchMetrics, | ||
} | ||
|
||
impl TreeStoreMetrics { | ||
pub fn new() -> Arc<RwLock<Self>> { | ||
Arc::new(RwLock::new(TreeStoreMetrics::default())) | ||
} | ||
|
||
pub fn metrics(&self) -> impl Iterator<Item = (String, usize)> { | ||
namespaced("scmstore.tree", namespaced("fetch", self.fetch.metrics())) | ||
} | ||
} | ||
|
||
#[cfg(feature = "ods")] | ||
define_stats! { | ||
prefix = "scmstore.tree"; | ||
fetch: dynamic_singleton_counter("fetch.{}", (specific_counter: String)), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters