mirror of https://github.com/fafhrd91/actix-net
use max_blocking_threads to customize tokio_uring's ring size
This commit is contained in:
parent
045cf3f3e8
commit
1bd7f3193b
|
@ -250,7 +250,11 @@ pub(crate) struct ServerWorkerConfig {
|
||||||
impl Default for ServerWorkerConfig {
|
impl Default for ServerWorkerConfig {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
// 512 is the default max blocking thread count of tokio runtime.
|
// 512 is the default max blocking thread count of tokio runtime.
|
||||||
|
#[cfg(not(all(target_os = "linux", feature = "io-uring")))]
|
||||||
let max_blocking_threads = std::cmp::max(512 / num_cpus::get_physical(), 1);
|
let max_blocking_threads = std::cmp::max(512 / num_cpus::get_physical(), 1);
|
||||||
|
// 256 is default sq & cq size used by tokio_uring
|
||||||
|
#[cfg(all(target_os = "linux", feature = "io-uring"))]
|
||||||
|
let max_blocking_threads = 256;
|
||||||
Self {
|
Self {
|
||||||
shutdown_timeout: Duration::from_secs(30),
|
shutdown_timeout: Duration::from_secs(30),
|
||||||
max_blocking_threads,
|
max_blocking_threads,
|
||||||
|
@ -385,10 +389,12 @@ impl ServerWorker {
|
||||||
|
|
||||||
#[cfg(all(target_os = "linux", feature = "io-uring"))]
|
#[cfg(all(target_os = "linux", feature = "io-uring"))]
|
||||||
{
|
{
|
||||||
// TODO: pass max blocking thread config when tokio-uring enable configuration
|
// passing `max_blocking_threads` as submission queue & completion queue
|
||||||
// on building runtime.
|
// should be useful than let it sit here
|
||||||
let _ = config.max_blocking_threads;
|
let queue_size = config.max_blocking_threads.clamp(1,u32::MAX as usize) as u32;
|
||||||
tokio_uring::start(worker_fut);
|
let mut builder = tokio_uring::builder();
|
||||||
|
builder.entries(queue_size);
|
||||||
|
builder.start(worker_fut);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(all(target_os = "linux", feature = "io-uring")))]
|
#[cfg(not(all(target_os = "linux", feature = "io-uring")))]
|
||||||
|
|
Loading…
Reference in New Issue