2026-01-25 13:38:34 +00:00
|
|
|
pub mod actor;
|
2026-01-23 05:00:57 +00:00
|
|
|
|
feat: Stress tests, benchmarking, and non-failing queues and inboxes #3
Adds some basic benchmarking, stress tests. They still need to be properly examined to ensure they are testing the correct properties, but fit for "good enough". Implements the HybridChannel type, which features a channel buffer that can withstand overflows. It does so by providing a dequeue behind a mutex. Without overflow, will push messages into the lock free ArrayQueue implemented by crossbeam_queue; when that buffer fills, will use the locking portion provided by the Mutex<VecDequeue>.
In the future we can even further optimize this, perhaps with some linked list implementations of lock-free channels, but, like the benchmarks, this fits the "good enough" bar for now.
Signed-off-by: Zachery Aaron Shores-Chmielewski <zacheryasc@gmail.com>
2026-01-26 07:14:00 +00:00
|
|
|
mod channel;
|
2026-01-25 13:38:34 +00:00
|
|
|
pub(crate) mod error;
|
|
|
|
|
pub use error::Error;
|
2026-01-23 05:00:57 +00:00
|
|
|
|
2026-01-25 13:38:34 +00:00
|
|
|
mod router;
|
|
|
|
|
pub mod runtime;
|
2025-11-25 00:39:17 +00:00
|
|
|
|
2026-01-23 05:00:57 +00:00
|
|
|
#[cfg(feature = "getrandom")]
|
2026-01-25 13:38:34 +00:00
|
|
|
pub(crate) fn get_random(buf: &mut [u8]) {
|
2026-01-23 05:00:57 +00:00
|
|
|
getrandom::getrandom(buf).unwrap()
|
|
|
|
|
}
|
2025-11-25 00:39:17 +00:00
|
|
|
|
feat: Stress tests, benchmarking, and non-failing queues and inboxes #3
Adds some basic benchmarking, stress tests. They still need to be properly examined to ensure they are testing the correct properties, but fit for "good enough". Implements the HybridChannel type, which features a channel buffer that can withstand overflows. It does so by providing a dequeue behind a mutex. Without overflow, will push messages into the lock free ArrayQueue implemented by crossbeam_queue; when that buffer fills, will use the locking portion provided by the Mutex<VecDequeue>.
In the future we can even further optimize this, perhaps with some linked list implementations of lock-free channels, but, like the benchmarks, this fits the "good enough" bar for now.
Signed-off-by: Zachery Aaron Shores-Chmielewski <zacheryasc@gmail.com>
2026-01-26 07:14:00 +00:00
|
|
|
#[cfg(feature = "no_random")]
|
|
|
|
|
pub(crate) fn get_random(buf: &mut [u8]) {
|
|
|
|
|
use core::sync::atomic::{AtomicUsize, Ordering};
|
|
|
|
|
|
|
|
|
|
static COUNTER: AtomicUsize = AtomicUsize::new(0);
|
|
|
|
|
|
|
|
|
|
let value = COUNTER.fetch_add(1, Ordering::Relaxed);
|
|
|
|
|
let bytes = value.to_ne_bytes();
|
|
|
|
|
|
|
|
|
|
for (i, byte) in buf.iter_mut().enumerate() {
|
|
|
|
|
*byte = bytes[i % core::mem::size_of::<usize>()];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-25 13:38:34 +00:00
|
|
|
/// FIXME: remove hard coded defaults
|
2026-01-23 05:00:57 +00:00
|
|
|
/// The strategy for message processing is such:
|
2026-01-25 13:38:34 +00:00
|
|
|
///
|
|
|
|
|
/// ```ignore
|
2026-01-23 05:00:57 +00:00
|
|
|
/// if total_messages < WATERLEVEL:
|
|
|
|
|
/// process all
|
|
|
|
|
/// else
|
2026-01-25 13:38:34 +00:00
|
|
|
/// process total_messages >> 1
|
|
|
|
|
/// ```
|
2026-01-23 05:00:57 +00:00
|
|
|
const WATERLEVEL: usize = 10;
|