Skip to content

Commit 0857d6b

Browse files
Clara Rullmeta-codesync[bot]
authored andcommitted
Remove low-value per-repo counters
Summary: Remove dynamic per-repo counters that are unused, misleading, or duplicated by better request-scoped signals. Keep the file-history perf counter and MononokeApiStats missing-bookmark events. Reviewed By: lmvasquezg Differential Revision: D115719733 fbshipit-source-id: adf01b1a6ed8fd7200dc6c35695db6ed45997246
1 parent 3141e94 commit 0857d6b

7 files changed

Lines changed: 9 additions & 76 deletions

File tree

eden/mononoke/blobrepo/BUCK

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ rust_library(
109109
"fbsource//third-party/rust:thiserror",
110110
"fbsource//third-party/rust:tracing",
111111
"//common/rust/shed/cloned:cloned",
112-
"//common/rust/shed/stats:stats",
113112
"//eden/mononoke/blobstore:blobstore",
114113
"//eden/mononoke/manifest:manifest",
115114
"//eden/mononoke/mercurial:mercurial_types",

eden/mononoke/blobrepo/common/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ mercurial_types = { version = "0.1.0", path = "../../mercurial/types" }
2222
mononoke_types = { version = "0.1.0", path = "../../mononoke_types" }
2323
repo_blobstore = { version = "0.1.0", path = "../../repo_attributes/repo_blobstore" }
2424
repo_identity = { version = "0.1.0", path = "../../repo_attributes/repo_identity" }
25-
stats = { version = "0.1.0", git = "https://github.com/facebookexperimental/rust-shed.git", branch = "main" }
2625
thiserror = "2.0.20"
2726
tracing = { version = "0.1.41", features = ["attributes", "valuable"] }
2827

eden/mononoke/blobrepo/common/src/file_history.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ use mercurial_types::RepoPath;
4343
use mononoke_types::ChangesetId;
4444
use repo_blobstore::RepoBlobstoreRef;
4545
use repo_identity::RepoIdentityRef;
46-
use stats::prelude::*;
4746
use thiserror::Error;
4847
use tracing::debug;
4948

@@ -65,11 +64,6 @@ pub enum FilenodesRelatedResult {
6564
SecondAncestorOfFirst,
6665
}
6766

68-
define_stats! {
69-
prefix = "mononoke.file_history";
70-
too_big: dynamic_timeseries("{}.too_big", (repo: String); Rate, Sum),
71-
}
72-
7367
pub trait Repo = RepoIdentityRef
7468
+ RepoBlobstoreRef
7569
+ FilenodesRef
@@ -260,7 +254,6 @@ pub async fn get_file_history(
260254
FilenodeResult::Present(FilenodeRange::TooBig) => {
261255
ctx.perf_counters()
262256
.increment_counter(PerfCounterType::FilenodesTooBigHistory);
263-
STATS::too_big.add_value(1, (repo.repo_identity().name().to_string(),));
264257
let history = get_file_history_using_prefetched(
265258
ctx,
266259
repo,

eden/mononoke/mononoke_api/src/repo.rs

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -207,14 +207,6 @@ define_stats! {
207207
"staleness.secs.{}.{}",
208208
(repoid: ::mononoke_types::RepositoryId, bookmark: String)
209209
),
210-
missing_from_cache: dynamic_singleton_counter(
211-
"missing_from_cache.{}.{}",
212-
(repoid: ::mononoke_types::RepositoryId, bookmark: String)
213-
),
214-
missing_from_repo: dynamic_singleton_counter(
215-
"missing_from_repo.{}.{}",
216-
(repoid: ::mononoke_types::RepositoryId, bookmark: String)
217-
),
218210
}
219211

220212
#[facet::container]
@@ -554,23 +546,13 @@ pub async fn report_monitoring_stats(
554546
Ok(())
555547
}
556548

557-
fn report_bookmark_missing_from_cache(
558-
ctx: &CoreContext,
559-
repo: &impl RepoIdentityRef,
560-
bookmark: &BookmarkKey,
561-
) {
549+
fn report_bookmark_missing_from_cache(repo: &impl RepoIdentityRef, bookmark: &BookmarkKey) {
562550
error!(
563551
"Monitored bookmark does not exist in the cache: {}, repo: {}",
564552
bookmark,
565553
repo.repo_identity().name()
566554
);
567555

568-
STATS::missing_from_cache.set_value(
569-
ctx.fb,
570-
1,
571-
(repo.repo_identity().id(), bookmark.to_string()),
572-
);
573-
574556
#[cfg(fbcode_build)]
575557
API_STATS_INSTRUMENT.observe(MononokeApiStats {
576558
repo: Some(repo.repo_identity().name().to_string()),
@@ -582,22 +564,12 @@ fn report_bookmark_missing_from_cache(
582564
});
583565
}
584566

585-
fn report_bookmark_missing_from_repo(
586-
ctx: &CoreContext,
587-
repo: &impl RepoIdentityRef,
588-
bookmark: &BookmarkKey,
589-
) {
567+
fn report_bookmark_missing_from_repo(repo: &impl RepoIdentityRef, bookmark: &BookmarkKey) {
590568
error!(
591569
"Monitored bookmark does not exist in the repo: {}",
592570
bookmark
593571
);
594572

595-
STATS::missing_from_repo.set_value(
596-
ctx.fb,
597-
1,
598-
(repo.repo_identity().id(), bookmark.to_string()),
599-
);
600-
601573
#[cfg(fbcode_build)]
602574
API_STATS_INSTRUMENT.observe(MononokeApiStats {
603575
repo: Some(repo.repo_identity().name().to_string()),
@@ -653,11 +625,11 @@ async fn report_bookmark_age_difference(
653625
.await?;
654626

655627
if maybe_bcs_id_from_blobrepo.is_none() {
656-
report_bookmark_missing_from_repo(ctx, repo, bookmark);
628+
report_bookmark_missing_from_repo(repo, bookmark);
657629
}
658630

659631
if maybe_bcs_id_from_service.is_none() {
660-
report_bookmark_missing_from_cache(ctx, repo, bookmark);
632+
report_bookmark_missing_from_cache(repo, bookmark);
661633
}
662634

663635
if let (Some(service_bcs_id), Some(blobrepo_bcs_id)) =

eden/mononoke/repo_attributes/bookmarks/src/cache.rs

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -31,23 +31,15 @@ use futures::stream::BoxStream;
3131
use futures::stream::StreamExt;
3232
use futures::stream::TryStreamExt;
3333
use mononoke_types::ChangesetId;
34-
use mononoke_types::RepositoryId;
3534
use shared_error::anyhow::IntoSharedError;
3635
use shared_error::anyhow::SharedError;
37-
use stats::prelude::*;
3836

3937
use crate::Bookmarks;
4038
use crate::log::BookmarkUpdateReason;
4139
use crate::subscription::BookmarksSubscription;
4240
use crate::transaction::BookmarkTransaction;
4341
use crate::transaction::BookmarkTransactionHook;
4442

45-
define_stats! {
46-
prefix = "mononoke.bookmarks.cache";
47-
cached_bookmarks_hits: dynamic_timeseries("{}.hit", (repo: String); Rate, Sum),
48-
cached_bookmarks_misses: dynamic_timeseries("{}.miss", (repo: String); Rate, Sum),
49-
}
50-
5143
type CacheData = BTreeMap<BookmarkKey, (BookmarkKind, ChangesetId)>;
5244

5345
#[derive(Clone)]
@@ -110,7 +102,6 @@ impl Cache {
110102

111103
#[derive(Clone)]
112104
pub struct CachedBookmarks {
113-
repo_id: RepositoryId,
114105
cache: Arc<Mutex<Option<Cache>>>,
115106
bookmarks: Arc<dyn Bookmarks>,
116107
}
@@ -126,9 +117,8 @@ fn ttl() -> Option<Duration> {
126117
}
127118

128119
impl CachedBookmarks {
129-
pub fn new(bookmarks: Arc<dyn Bookmarks>, repo_id: RepositoryId) -> Self {
120+
pub fn new(bookmarks: Arc<dyn Bookmarks>) -> Self {
130121
Self {
131-
repo_id,
132122
bookmarks,
133123
cache: Arc::new(Mutex::new(None)),
134124
}
@@ -142,9 +132,7 @@ impl CachedBookmarks {
142132
Some(ref mut cache) => {
143133
// create new cache if the old one has either expired or failed
144134
let cache_failed = cache.is_failed();
145-
let mut cache_hit = true;
146135
if cache.expires <= now || cache_failed {
147-
cache_hit = false;
148136
*cache = Cache::new(
149137
ctx,
150138
self.bookmarks.clone(),
@@ -165,12 +153,6 @@ impl CachedBookmarks {
165153
);
166154
}
167155

168-
if cache_hit {
169-
STATS::cached_bookmarks_hits.add_value(1, (self.repo_id.id().to_string(),))
170-
} else {
171-
STATS::cached_bookmarks_misses.add_value(1, (self.repo_id.id().to_string(),))
172-
}
173-
174156
cache.clone()
175157
}
176158
None => {
@@ -781,12 +763,10 @@ mod tests {
781763
.build()
782764
.unwrap();
783765
let ctx = CoreContext::test_mock(fb);
784-
let repo_id = RepositoryId::new(0);
785-
786766
let (mock, requests) = MockBookmarks::create();
787767
let requests = requests.into_future();
788768

789-
let bookmarks = CachedBookmarks::new(Arc::new(mock), repo_id);
769+
let bookmarks = CachedBookmarks::new(Arc::new(mock));
790770

791771
let spawn_query = |prefix: &'static str, ttl: Option<i64>, rt: &Runtime| {
792772
let (sender, receiver) = oneshot::channel();
@@ -983,12 +963,10 @@ mod tests {
983963
.build()
984964
.unwrap();
985965
let ctx = CoreContext::test_mock(fb);
986-
let repo_id = RepositoryId::new(0);
987-
988966
let (mock, requests) = MockBookmarks::create();
989967
let requests = requests.into_future();
990968

991-
let store = CachedBookmarks::new(Arc::new(mock), repo_id);
969+
let store = CachedBookmarks::new(Arc::new(mock));
992970

993971
let (sender, receiver) = oneshot::channel();
994972

eden/mononoke/repo_client/src/client.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ define_stats! {
102102
push_success: dynamic_timeseries("push_success.{}", (reponame: String); Rate, Sum),
103103
push_hook_failure: dynamic_timeseries("push_hook_failure.{}.{}", (reponame: String, hook_failure: String); Rate, Sum),
104104
push_conflicts: dynamic_timeseries("push_conflicts.{}", (reponame: String); Rate, Sum),
105-
rate_limits_exceeded: dynamic_timeseries("rate_limits_exceeded.{}", (reponame: String); Rate, Sum),
106105
push_error: dynamic_timeseries("push_error.{}", (reponame: String); Rate, Sum),
107106
}
108107

eden/mononoke/repo_factory/src/lib.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -901,15 +901,8 @@ impl RepoFactory {
901901
Ok(Arc::new(sql_bookmarks))
902902
}
903903

904-
pub fn bookmarks(
905-
&self,
906-
sql_bookmarks: &ArcSqlBookmarks,
907-
repo_identity: &ArcRepoIdentity,
908-
) -> ArcBookmarks {
909-
Arc::new(CachedBookmarks::new(
910-
sql_bookmarks.clone(),
911-
repo_identity.id(),
912-
))
904+
pub fn bookmarks(&self, sql_bookmarks: &ArcSqlBookmarks) -> ArcBookmarks {
905+
Arc::new(CachedBookmarks::new(sql_bookmarks.clone()))
913906
}
914907

915908
pub fn bookmark_update_log(&self, sql_bookmarks: &ArcSqlBookmarks) -> ArcBookmarkUpdateLog {

0 commit comments

Comments
 (0)