Make background tranquility a configurable parameter

This commit is contained in:
Alex Auvolat
2022-03-15 12:31:23 +01:00
parent 8fd6745745
commit e480aaf338
4 changed files with 25 additions and 16 deletions
+6 -5
View File
@@ -29,15 +29,13 @@ use garage_rpc::*;
use garage_table::replication::{TableReplication, TableShardedReplication};
use crate::metrics::*;
use crate::block::*;
use crate::metrics::*;
use crate::rc::*;
/// Size under which data will be stored inlined in database instead of as files
pub const INLINE_THRESHOLD: usize = 3072;
pub const BACKGROUND_TRANQUILITY: u32 = 2;
// Timeout for RPCs that read and write blocks to remote nodes
const BLOCK_RW_TIMEOUT: Duration = Duration::from_secs(30);
// Timeout for RPCs that ask other nodes whether they need a copy
@@ -82,8 +80,9 @@ pub struct BlockManager {
pub replication: TableShardedReplication,
/// Directory in which block are stored
pub data_dir: PathBuf,
/// Zstd compression level
compression_level: Option<i32>,
background_tranquility: u32,
mutation_lock: Mutex<BlockManagerLocked>,
@@ -109,6 +108,7 @@ impl BlockManager {
db: &sled::Db,
data_dir: PathBuf,
compression_level: Option<i32>,
background_tranquility: u32,
replication: TableShardedReplication,
system: Arc<System>,
) -> Arc<Self> {
@@ -139,6 +139,7 @@ impl BlockManager {
replication,
data_dir,
compression_level,
background_tranquility,
mutation_lock: Mutex::new(manager_locked),
rc,
resync_queue,
@@ -440,7 +441,7 @@ impl BlockManager {
while !*must_exit.borrow() {
match self.resync_iter(&mut must_exit).await {
Ok(true) => {
tranquilizer.tranquilize(BACKGROUND_TRANQUILITY).await;
tranquilizer.tranquilize(self.background_tranquility).await;
}
Ok(false) => {
tranquilizer.reset();
+3 -5
View File
@@ -1,7 +1,7 @@
use std::convert::TryInto;
use garage_util::error::*;
use garage_util::data::*;
use garage_util::error::*;
use garage_util::time::*;
use crate::manager::BLOCK_GC_DELAY;
@@ -12,9 +12,7 @@ pub struct BlockRc {
impl BlockRc {
pub(crate) fn new(rc: sled::Tree) -> Self {
Self {
rc
}
Self { rc }
}
/// Increment the reference counter associated to a hash.
@@ -34,7 +32,7 @@ impl BlockRc {
.rc
.update_and_fetch(&hash, |old| RcEntry::parse_opt(old).decrement().serialize())?;
let new_rc = RcEntry::parse_opt(new_rc);
Ok(matches!(new_rc, RcEntry::Deletable {..}))
Ok(matches!(new_rc, RcEntry::Deletable { .. }))
}
/// Read a block's reference count