Skip to content

Commit

Permalink
scmstore: add counter for indexedlog rotations
Browse files Browse the repository at this point in the history
Summary: Expose a counter for number of indexedlog rotations. We don't want the hgcache logs to rotate too frequently (because that drops all the data in the final log), and this will help us see how often they rotate.

Reviewed By: sggutier

Differential Revision: D66903539

fbshipit-source-id: 1526594e454944b376b943ae84547dcff2aab5de
  • Loading branch information
muirdm authored and facebook-github-bot committed Dec 11, 2024
1 parent 3937878 commit cf4e8a0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
6 changes: 6 additions & 0 deletions eden/scm/lib/indexedlog/src/rotate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ use std::fs;
use std::io;
use std::path::Path;
use std::path::PathBuf;
use std::sync::atomic::AtomicU64;
use std::sync::atomic::AtomicUsize;
use std::sync::atomic::Ordering;
use std::sync::atomic::Ordering::SeqCst;

use minibytes::Bytes;
Expand All @@ -37,6 +39,8 @@ use crate::repair::OpenOptionsRepair;
use crate::repair::RepairMessage;
use crate::utils;

pub static ROTATE_COUNT: AtomicU64 = AtomicU64::new(0);

/// A collection of [`Log`]s that get rotated or deleted automatically when they
/// exceed size or count limits.
///
Expand Down Expand Up @@ -586,6 +590,8 @@ impl RotateLog {
/// callsite makes sure that [`Log`]s are consistent (ex. up-to-date,
/// and do not have dirty entries in non-writable logs).
fn rotate_internal(&mut self, lock: &ScopedDirLock) -> crate::Result<()> {
ROTATE_COUNT.fetch_add(1, Ordering::Relaxed);

let span = debug_span!("RotateLog::rotate", latest = self.latest as u32);
if let Some(dir) = &self.dir {
span.record("dir", dir.to_string_lossy().as_ref());
Expand Down
3 changes: 3 additions & 0 deletions eden/scm/lib/revisionstore/src/scmstore/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ use clientinfo::set_client_request_info_thread_local;
use crossbeam::channel::unbounded;
use indexedlog::log::AUTO_SYNC_COUNT;
use indexedlog::log::SYNC_COUNT;
use indexedlog::rotate::ROTATE_COUNT;
use itertools::Itertools;
use minibytes::Bytes;
use parking_lot::Mutex;
Expand Down Expand Up @@ -140,6 +141,7 @@ macro_rules! try_local_content {
static FILESTORE_FLUSH_COUNT: Counter = Counter::new_counter("scmstore.file.flush");
static INDEXEDLOG_SYNC_COUNT: Counter = Counter::new_counter("scmstore.indexedlog.sync");
static INDEXEDLOG_AUTO_SYNC_COUNT: Counter = Counter::new_counter("scmstore.indexedlog.auto_sync");
static INDEXEDLOG_ROTATE_COUNT: Counter = Counter::new_counter("scmstore.indexedlog.rotate");

impl FileStore {
/// Get the "local content" without going through the heavyweight "fetch" API.
Expand Down Expand Up @@ -329,6 +331,7 @@ impl FileStore {
// These aren't technically filestore specific, but this will keep them updated.
INDEXEDLOG_SYNC_COUNT.add(SYNC_COUNT.swap(0, Ordering::Relaxed) as usize);
INDEXEDLOG_AUTO_SYNC_COUNT.add(AUTO_SYNC_COUNT.swap(0, Ordering::Relaxed) as usize);
INDEXEDLOG_ROTATE_COUNT.add(ROTATE_COUNT.swap(0, Ordering::Relaxed) as usize);

if let Some(activity_logger) = activity_logger {
if let Err(err) = activity_logger.lock().log_file_fetch(
Expand Down
3 changes: 2 additions & 1 deletion eden/scm/tests/test-remotefilelog-prefetch.t
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ Prefetch (and also check we get counters):
scmstore.file.fetch.indexedlog.local.singles: 1
scmstore.file.fetch.indexedlog.local.time: * (glob) (?)
scmstore.file.flush: * (glob)
scmstore.indexedlog.sync: * (glob)
scmstore.indexedlog.rotate: * (glob) (?)
scmstore.indexedlog.sync: * (glob) (?)
scmstore.tree.fetch.edenapi.keys: 1
scmstore.tree.fetch.edenapi.requests: 1
scmstore.tree.fetch.edenapi.singles: 1
Expand Down

0 comments on commit cf4e8a0

Please sign in to comment.