chain_width to 50

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk
2025-04-22 04:42:26 +00:00
parent 9b658d86b2
commit 76509830e6
190 changed files with 3469 additions and 930 deletions

View File

@@ -77,7 +77,11 @@ impl Engine {
sequence = ?self.current_sequence(),
),
)]
pub fn update(&self) -> Result { self.db.try_catch_up_with_primary().map_err(map_err) }
pub fn update(&self) -> Result {
self.db
.try_catch_up_with_primary()
.map_err(map_err)
}
#[tracing::instrument(level = "info", skip_all)]
pub fn sync(&self) -> Result { result(DBCommon::flush_wal(&self.db, true)) }

View File

@@ -20,7 +20,9 @@ pub fn backup(&self) -> Result {
.map_err(map_err)?;
let engine_info = engine.get_backup_info();
let info = &engine_info.last().expect("backup engine info is not empty");
let info = &engine_info
.last()
.expect("backup engine info is not empty");
info!(
"Created database backup #{} using {} bytes in {} files",
info.backup_id, info.size, info.num_files,

View File

@@ -105,7 +105,8 @@ fn set_table_options(opts: &mut Options, desc: &Descriptor, cache: Option<&Cache
prepopulate,
);
opts.set_options_from_string(&string).map_err(map_err)?;
opts.set_options_from_string(&string)
.map_err(map_err)?;
opts.set_block_based_table_factory(&table);

View File

@@ -78,7 +78,9 @@ fn configure_cfds(
let path = &config.database_path;
let existing = Self::discover_cfs(path, db_opts);
let creating = desc.iter().filter(|desc| !existing.contains(desc.name));
let creating = desc
.iter()
.filter(|desc| !existing.contains(desc.name));
let missing = existing
.iter()

View File

@@ -14,7 +14,10 @@ use crate::keyval::Key;
#[implement(super::Map)]
#[tracing::instrument(level = "trace")]
pub async fn clear(self: &Arc<Self>) {
self.for_clear().ignore_err().ready_for_each(|_| ()).await;
self.for_clear()
.ignore_err()
.ready_for_each(|_| ())
.await;
}
/// Delete all data stored in this map. !!! USE WITH CAUTION !!!

View File

@@ -77,7 +77,9 @@ fn get_blocking_opts<K>(
where
K: AsRef<[u8]> + ?Sized,
{
self.db.db.get_pinned_cf_opt(&self.cf(), key, read_options)
self.db
.db
.get_pinned_cf_opt(&self.cf(), key, read_options)
}
#[inline]

View File

@@ -50,7 +50,11 @@ where
.widen_then(automatic_width(), |chunk| {
self.db.pool.execute_get(Get {
map: self.clone(),
key: chunk.iter().map(AsRef::as_ref).map(Into::into).collect(),
key: chunk
.iter()
.map(AsRef::as_ref)
.map(Into::into)
.collect(),
res: None,
})
})

View File

@@ -14,7 +14,8 @@ pub fn keys<'a, K>(self: &'a Arc<Self>) -> impl Stream<Item = Result<Key<'_, K>>
where
K: Deserialize<'a> + Send,
{
self.raw_keys().map(keyval::result_deserialize_key::<K>)
self.raw_keys()
.map(keyval::result_deserialize_key::<K>)
}
#[implement(super::Map)]

View File

@@ -20,7 +20,8 @@ where
P: Serialize + ?Sized + Debug,
K: Deserialize<'a> + Send,
{
self.keys_from_raw(from).map(result_deserialize_key::<K>)
self.keys_from_raw(from)
.map(result_deserialize_key::<K>)
}
#[implement(super::Map)]
@@ -45,7 +46,8 @@ where
P: AsRef<[u8]> + ?Sized + Debug + Sync,
K: Deserialize<'a> + Send,
{
self.raw_keys_from(from).map(result_deserialize_key::<K>)
self.raw_keys_from(from)
.map(result_deserialize_key::<K>)
}
#[implement(super::Map)]

View File

@@ -14,7 +14,8 @@ pub fn rev_keys<'a, K>(self: &'a Arc<Self>) -> impl Stream<Item = Result<Key<'_,
where
K: Deserialize<'a> + Send,
{
self.rev_raw_keys().map(keyval::result_deserialize_key::<K>)
self.rev_raw_keys()
.map(keyval::result_deserialize_key::<K>)
}
#[implement(super::Map)]

View File

@@ -19,7 +19,8 @@ where
K: Deserialize<'a> + Send,
V: Deserialize<'a> + Send,
{
self.raw_stream().map(keyval::result_deserialize::<K, V>)
self.raw_stream()
.map(keyval::result_deserialize::<K, V>)
}
/// Iterate key-value entries in the map from the beginning.

View File

@@ -25,7 +25,8 @@ where
K: Deserialize<'a> + Send,
V: Deserialize<'a> + Send,
{
self.stream_from_raw(from).map(result_deserialize::<K, V>)
self.stream_from_raw(from)
.map(result_deserialize::<K, V>)
}
/// Iterate key-value entries in the map starting from lower-bound.
@@ -59,7 +60,8 @@ where
K: Deserialize<'a> + Send,
V: Deserialize<'a> + Send,
{
self.raw_stream_from(from).map(result_deserialize::<K, V>)
self.raw_stream_from(from)
.map(result_deserialize::<K, V>)
}
/// Iterate key-value entries in the map starting from lower-bound.

View File

@@ -117,7 +117,11 @@ impl Drop for Pool {
pub(crate) fn close(&self) {
let workers = take(&mut *self.workers.lock().expect("locked"));
let senders = self.queues.iter().map(Sender::sender_count).sum::<usize>();
let senders = self
.queues
.iter()
.map(Sender::sender_count)
.sum::<usize>();
let receivers = self
.queues
@@ -225,7 +229,9 @@ pub(crate) async fn execute_iter(self: &Arc<Self>, mut cmd: Seek) -> Result<stre
fn select_queue(&self) -> &Sender<Cmd> {
let core_id = get_affinity().next().unwrap_or(0);
let chan_id = self.topology[core_id];
self.queues.get(chan_id).unwrap_or_else(|| &self.queues[0])
self.queues
.get(chan_id)
.unwrap_or_else(|| &self.queues[0])
}
#[implement(Pool)]
@@ -242,7 +248,8 @@ fn select_queue(&self) -> &Sender<Cmd> {
)]
async fn execute(&self, queue: &Sender<Cmd>, cmd: Cmd) -> Result {
if cfg!(debug_assertions) {
self.queued_max.fetch_max(queue.len(), Ordering::Relaxed);
self.queued_max
.fetch_max(queue.len(), Ordering::Relaxed);
}
queue

View File

@@ -18,11 +18,16 @@ pub(super) fn configure(server: &Arc<Server>) -> (usize, Vec<usize>, Vec<usize>)
// This finds the block device and gathers all the properties we need.
let path: PathBuf = config.database_path.clone();
let device_name = storage::name_from_path(&path).log_debug_err().ok();
let device_name = storage::name_from_path(&path)
.log_debug_err()
.ok();
let device_prop = storage::parallelism(&path);
// The default worker count is masked-on if we didn't find better information.
let default_worker_count = device_prop.mq.is_empty().then_some(config.db_pool_workers);
let default_worker_count = device_prop
.mq
.is_empty()
.then_some(config.db_pool_workers);
// Determine the worker groupings. Each indice represents a hardware queue and
// contains the number of workers which will service it.
@@ -38,9 +43,13 @@ pub(super) fn configure(server: &Arc<Server>) -> (usize, Vec<usize>, Vec<usize>)
.count()
.max(1);
let limit = config.db_pool_workers_limit.saturating_mul(shares);
let limit = config
.db_pool_workers_limit
.saturating_mul(shares);
let limit = device_prop.nr_requests.map_or(limit, |nr| nr.min(limit));
let limit = device_prop
.nr_requests
.map_or(limit, |nr| nr.min(limit));
mq.nr_tags.unwrap_or(WORKER_LIMIT.0).min(limit)
})

View File

@@ -19,7 +19,12 @@ impl Watchers {
&'a self,
prefix: &[u8],
) -> Pin<Box<dyn Future<Output = ()> + Send + 'a>> {
let mut rx = match self.watchers.write().unwrap().entry(prefix.to_vec()) {
let mut rx = match self
.watchers
.write()
.unwrap()
.entry(prefix.to_vec())
{
| hash_map::Entry::Occupied(o) => o.get().1.clone(),
| hash_map::Entry::Vacant(v) => {
let (tx, rx) = watch::channel(());
@@ -50,7 +55,8 @@ impl Watchers {
let mut watchers = self.watchers.write().unwrap();
for prefix in triggered {
if let Some(tx) = watchers.remove(prefix) {
tx.0.send(()).expect("channel should still be open");
tx.0.send(())
.expect("channel should still be open");
}
}
}