add LIFO scheduling for database frontend pool workers
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
6458f4b195
commit
74eb30c106
3 changed files with 17 additions and 6 deletions
6
Cargo.lock
generated
6
Cargo.lock
generated
|
@ -95,8 +95,7 @@ checksum = "5f093eed78becd229346bf859eec0aa4dd7ddde0757287b2b4107a1f09c80002"
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "async-channel"
|
name = "async-channel"
|
||||||
version = "2.3.1"
|
version = "2.3.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "git+https://github.com/jevolk/async-channel?rev=fefa543ca5eddf21237d75776fce98b7e09e924a#fefa543ca5eddf21237d75776fce98b7e09e924a"
|
||||||
checksum = "89b47800b0be77592da0afd425cc03468052844aff33b84e33cc696f64e77b6a"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"concurrent-queue",
|
"concurrent-queue",
|
||||||
"event-listener-strategy",
|
"event-listener-strategy",
|
||||||
|
@ -1259,8 +1258,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "event-listener"
|
name = "event-listener"
|
||||||
version = "5.3.1"
|
version = "5.3.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "git+https://github.com/jevolk/event-listener?rev=96d7e0fc026d8f708b19bc9267a382676a50354c#96d7e0fc026d8f708b19bc9267a382676a50354c"
|
||||||
checksum = "6032be9bd27023a771701cc49f9f053c751055f71efb2e0ae5c15809093675ba"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"concurrent-queue",
|
"concurrent-queue",
|
||||||
"parking",
|
"parking",
|
||||||
|
|
|
@ -529,6 +529,14 @@ rev = "ccc4fbd8238c2d5ba354e61ec17ac610af11401d"
|
||||||
git = "https://github.com/girlbossceo/rustyline-async"
|
git = "https://github.com/girlbossceo/rustyline-async"
|
||||||
rev = "deaeb0694e2083f53d363b648da06e10fc13900c"
|
rev = "deaeb0694e2083f53d363b648da06e10fc13900c"
|
||||||
|
|
||||||
|
# adds LIFO queue scheduling; this should be updated with PR progress.
|
||||||
|
[patch.crates-io.event-listener]
|
||||||
|
git = "https://github.com/jevolk/event-listener"
|
||||||
|
rev = "96d7e0fc026d8f708b19bc9267a382676a50354c"
|
||||||
|
[patch.crates-io.async-channel]
|
||||||
|
git = "https://github.com/jevolk/async-channel"
|
||||||
|
rev = "fefa543ca5eddf21237d75776fce98b7e09e924a"
|
||||||
|
|
||||||
#
|
#
|
||||||
# Our crates
|
# Our crates
|
||||||
#
|
#
|
||||||
|
|
|
@ -8,7 +8,7 @@ use std::{
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
use async_channel::{Receiver, RecvError, Sender};
|
use async_channel::{Receiver, RecvError, Sched, Sender};
|
||||||
use conduwuit::{
|
use conduwuit::{
|
||||||
debug, debug_warn, defer, err, implement,
|
debug, debug_warn, defer, err, implement,
|
||||||
result::DebugInspect,
|
result::DebugInspect,
|
||||||
|
@ -65,9 +65,14 @@ const QUEUE_LIMIT: (usize, usize) = (1, 2048);
|
||||||
|
|
||||||
#[implement(Pool)]
|
#[implement(Pool)]
|
||||||
pub(crate) async fn new(server: &Arc<Server>) -> Result<Arc<Self>> {
|
pub(crate) async fn new(server: &Arc<Server>) -> Result<Arc<Self>> {
|
||||||
|
const CHAN_SCHED: (Sched, Sched) = (Sched::Fifo, Sched::Lifo);
|
||||||
|
|
||||||
let (total_workers, queue_sizes, topology) = configure(server);
|
let (total_workers, queue_sizes, topology) = configure(server);
|
||||||
|
|
||||||
let (senders, receivers) = queue_sizes.into_iter().map(async_channel::bounded).unzip();
|
let (senders, receivers) = queue_sizes
|
||||||
|
.into_iter()
|
||||||
|
.map(|cap| async_channel::bounded_with_sched(cap, CHAN_SCHED))
|
||||||
|
.unzip();
|
||||||
|
|
||||||
let pool = Arc::new(Self {
|
let pool = Arc::new(Self {
|
||||||
server: server.clone(),
|
server: server.clone(),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue