ircd::ctx::pool: Add option for dispatch strategy; behavior changed by default.

This commit is contained in:
Jason Volk 2023-02-20 12:19:12 -08:00
parent ea92976369
commit 34bd1e0709
3 changed files with 13 additions and 1 deletions

View File

@ -115,6 +115,12 @@ struct ircd::ctx::pool::opts
/// Scheduler priority nice value for contexts in this pool.
int8_t nice {0};
/// Worker dispatch strategy.
/// - FIFO: Dispatch fairly (round-robin).
/// - LIFO: Dispatch the last to finish.
/// - SORT: Like LIFO but lower ID's are given partial precedence.
dock::opts dispatch {dock::opts::LIFO};
};
template<class F,

View File

@ -90,6 +90,7 @@ ircd::client::pool_opts
{
.stack_size = size_t(settings.stack_size),
.initial_ctxs = size_t(settings.pool_size),
.dispatch = ctx::dock::opts::SORT,
};
/// The pool of request contexts. When a client makes a request it does so by acquiring

View File

@ -1589,9 +1589,14 @@ void
ircd::ctx::pool::work()
try
{
const auto pop_opts
{
opt->dispatch
};
const auto func
{
q.pop()
q.pop(pop_opts)
};
const scope_notify notify