Skip to content

Commit

Permalink
scmstore: don't update ODS counters for every fetch
Browse files Browse the repository at this point in the history
Summary:
Instead, update ODS counters during flush() (where the regular Sapling counters get updated). EdenFS calls flush() on its backing stores every 1 minute, so they should get updated regularly.

I'm doing this because the scmstore metrics weren't "designed" to be logged for every fetch. Getting the list of metrics allocates a ton of Strings, so calling for every fetch (which can often be a fetch of a single file or directory), is wasteful (didn't profile - could be neglible amount of waste).

Reviewed By: sggutier

Differential Revision: D66731805

fbshipit-source-id: 46578e2d18a6534c956ec71054b4bc2016e4c669
  • Loading branch information
muirdm authored and facebook-github-bot committed Dec 4, 2024
1 parent 2a156fb commit 14609c4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
9 changes: 4 additions & 5 deletions eden/scm/lib/revisionstore/src/scmstore/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,9 +339,6 @@ impl FileStore {
state.derive_computable(aux_cache.as_ref().map(|s| s.as_ref()));

metrics.write().fetch += state.metrics().clone();
if let Err(err) = state.metrics().update_ods() {
tracing::error!("Error updating ods fetch metrics: {}", err);
}
state.finish();

if let Some(activity_logger) = activity_logger {
Expand Down Expand Up @@ -482,11 +479,13 @@ impl FileStore {
aux_cache.flush().map_err(&mut handle_error);
}

let mut metrics = self.metrics.write();
let metrics = std::mem::take(&mut *self.metrics.write());
for (k, v) in metrics.metrics() {
hg_metrics::increment_counter(k, v as u64);
}
*metrics = Default::default();
if let Err(err) = metrics.fetch.update_ods() {
tracing::error!("Error updating ods fetch metrics: {}", err);
}

result
}
Expand Down
12 changes: 5 additions & 7 deletions eden/scm/lib/revisionstore/src/scmstore/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -388,11 +388,6 @@ impl TreeStore {

// TODO(meyer): Report incomplete / not found, handle errors better instead of just always failing the batch, etc
state.common.results(state.errors);

if let Err(err) = state.metrics.update_ods() {
tracing::error!(?err, "error updating tree ods counters");
}

store_metrics.write().fetch += state.metrics;

Ok(())
Expand Down Expand Up @@ -477,11 +472,14 @@ impl TreeStore {
historystore_cache.flush().map_err(&mut handle_error);
}

let mut metrics = self.metrics.write();
let metrics = std::mem::take(&mut *self.metrics.write());
for (k, v) in metrics.metrics() {
hg_metrics::increment_counter(k, v as u64);
}
*metrics = Default::default();

if let Err(err) = metrics.fetch.update_ods() {
tracing::error!(?err, "error updating tree ods counters");
}

result
}
Expand Down

0 comments on commit 14609c4

Please sign in to comment.