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

@@ -21,7 +21,9 @@ pub fn from_str(str: &str) -> Result<usize> {
#[inline]
#[must_use]
pub fn pretty(bytes: usize) -> String {
let bytes: u64 = bytes.try_into().expect("failed to convert usize to u64");
let bytes: u64 = bytes
.try_into()
.expect("failed to convert usize to u64");
ByteSize::b(bytes).display().iec().to_string()
}

View File

@@ -73,7 +73,9 @@ where
Ok(Guard::<Key, Val> {
map: Arc::clone(&self.map),
val: val.try_lock_owned().map_err(|_| err!("would yield"))?,
val: val
.try_lock_owned()
.map_err(|_| err!("would yield"))?,
})
}
@@ -97,7 +99,9 @@ where
Ok(Guard::<Key, Val> {
map: Arc::clone(&self.map),
val: val.try_lock_owned().map_err(|_| err!("would yield"))?,
val: val
.try_lock_owned()
.map_err(|_| err!("would yield"))?,
})
}

View File

@@ -12,6 +12,9 @@ impl<T> UnwrapInfallible<T> for Result<T, Infallible> {
fn unwrap_infallible(self) -> T {
// SAFETY: Branchless unwrap for errors that can never happen. In debug
// mode this is asserted.
unsafe { self.debug_inspect_err(error::infallible).unwrap_unchecked() }
unsafe {
self.debug_inspect_err(error::infallible)
.unwrap_unchecked()
}
}
}

View File

@@ -68,7 +68,11 @@ where
a.map(move |ai| (ai, b.clone()))
.filter_map(|(ai, b)| async move {
let mut lock = b.lock().await;
while let Some(bi) = Pin::new(&mut *lock).next_if(|bi| *bi <= ai).await.as_ref() {
while let Some(bi) = Pin::new(&mut *lock)
.next_if(|bi| *bi <= ai)
.await
.as_ref()
{
if ai == *bi {
return Some(ai);
}

View File

@@ -65,7 +65,11 @@ where
let h = h.into().unwrap_or_else(runtime::Handle::current);
self.broadn_and_then(n, move |val| {
let (h, f) = (h.clone(), f.clone());
async move { h.spawn_blocking(move || f(val)).map_err(E::from).await? }
async move {
h.spawn_blocking(move || f(val))
.map_err(E::from)
.await?
}
})
}
}

View File

@@ -27,7 +27,8 @@ impl<'a> Unquote<'a> for &'a str {
#[inline]
fn unquote(&self) -> Option<&'a str> {
self.strip_prefix(QUOTE).and_then(|s| s.strip_suffix(QUOTE))
self.strip_prefix(QUOTE)
.and_then(|s| s.strip_suffix(QUOTE))
}
#[inline]

View File

@@ -51,6 +51,8 @@ pub unsafe fn current_exe() -> Result<PathBuf> {
/// accurate on all platforms; defaults to false.
#[must_use]
pub fn current_exe_deleted() -> bool {
std::env::current_exe()
.is_ok_and(|exe| exe.to_str().is_some_and(|exe| exe.ends_with(" (deleted)")))
std::env::current_exe().is_ok_and(|exe| {
exe.to_str()
.is_some_and(|exe| exe.ends_with(" (deleted)"))
})
}

View File

@@ -70,7 +70,9 @@ pub fn get_affinity() -> impl Iterator<Item = Id> { from_mask(CORE_AFFINITY.get(
/// List the cores sharing SMT-tier resources
pub fn smt_siblings() -> impl Iterator<Item = Id> {
from_mask(get_affinity().fold(0_u128, |mask, id| {
mask | SMT_TOPOLOGY.get(id).expect("ID must not exceed max cpus")
mask | SMT_TOPOLOGY
.get(id)
.expect("ID must not exceed max cpus")
}))
}
@@ -78,20 +80,30 @@ pub fn smt_siblings() -> impl Iterator<Item = Id> {
/// affinity.
pub fn node_siblings() -> impl Iterator<Item = Id> {
from_mask(get_affinity().fold(0_u128, |mask, id| {
mask | NODE_TOPOLOGY.get(id).expect("Id must not exceed max cpus")
mask | NODE_TOPOLOGY
.get(id)
.expect("Id must not exceed max cpus")
}))
}
/// Get the cores sharing SMT resources relative to id.
#[inline]
pub fn smt_affinity(id: Id) -> impl Iterator<Item = Id> {
from_mask(*SMT_TOPOLOGY.get(id).expect("ID must not exceed max cpus"))
from_mask(
*SMT_TOPOLOGY
.get(id)
.expect("ID must not exceed max cpus"),
)
}
/// Get the cores sharing Node resources relative to id.
#[inline]
pub fn node_affinity(id: Id) -> impl Iterator<Item = Id> {
from_mask(*NODE_TOPOLOGY.get(id).expect("ID must not exceed max cpus"))
from_mask(
*NODE_TOPOLOGY
.get(id)
.expect("ID must not exceed max cpus"),
)
}
/// Get the number of threads which could execute in parallel based on hardware

View File

@@ -42,7 +42,9 @@ pub struct Queue {
/// Get device characteristics useful for random access throughput by name.
#[must_use]
pub fn parallelism(path: &Path) -> Parallelism {
let dev_id = dev_from_path(path).log_debug_err().unwrap_or_default();
let dev_id = dev_from_path(path)
.log_debug_err()
.unwrap_or_default();
let mq_path = block_path(dev_id).join("mq/");
@@ -60,7 +62,12 @@ pub fn parallelism(path: &Path) -> Parallelism {
.into_iter()
.flat_map(IntoIterator::into_iter)
.filter_map(Result::ok)
.filter(|entry| entry.file_type().as_ref().is_ok_and(FileType::is_dir))
.filter(|entry| {
entry
.file_type()
.as_ref()
.is_ok_and(FileType::is_dir)
})
.map(|dir| queue_parallelism(&dir.path()))
.collect(),
}