diff --git a/include/ircd/ctx/ctx.h b/include/ircd/ctx/ctx.h index dd06d6bf6..23c97d67c 100644 --- a/include/ircd/ctx/ctx.h +++ b/include/ircd/ctx/ctx.h @@ -50,6 +50,8 @@ namespace ircd::ctx const int32_t ¬es(const ctx &) noexcept; // Peeks at internal semaphore count const uint64_t &epoch(const ctx &) noexcept; // Context switching counter const ulong &cycles(const ctx &) noexcept; // Accumulated tsc (not counting cur slice) + const int8_t &ionice(const ctx &) noexcept; // IO priority nice-value + const int8_t &nice(const ctx &) noexcept; // Scheduling priority nice-value bool interruptible(const ctx &) noexcept; // Context can throw at interruption point bool interruption(const ctx &) noexcept; // Context was marked for interruption bool termination(const ctx &) noexcept; // Context was marked for termination @@ -59,6 +61,8 @@ namespace ircd::ctx bool waiting(const ctx &) noexcept; // started() && !finished() && !running() bool queued(const ctx &) noexcept; // !running() && notes() > 0 + int8_t ionice(ctx &, const int8_t &); // IO priority nice-value + int8_t nice(ctx &, const int8_t &); // Scheduling priority nice-value void interruptible(ctx &, const bool &); // False for interrupt suppression. void interrupt(ctx &); // Interrupt the context. void terminate(ctx &); // Interrupt for termination. diff --git a/ircd/ctx.cc b/ircd/ctx.cc index c4400f264..7a8daa7dd 100644 --- a/ircd/ctx.cc +++ b/ircd/ctx.cc @@ -512,6 +512,22 @@ ircd::ctx::interruptible(ctx &ctx, ctx.flags |= context::NOINTERRUPT; } +int8_t +ircd::ctx::nice(ctx &ctx, + const int8_t &val) +{ + ctx.nice = val; + return ctx.nice; +} + +int8_t +ircd::ctx::ionice(ctx &ctx, + const int8_t &val) +{ + ctx.ionice = val; + return ctx.ionice; +} + /// !running() && notes > 0 [[gnu::hot]] bool @@ -593,6 +609,24 @@ noexcept return prof::get(ctx, prof::event::CYCLES); } +/// Returns the IO priority nice-value +[[gnu::hot]] +const int8_t & +ircd::ctx::ionice(const ctx &ctx) +noexcept +{ + return ctx.ionice; +} + +/// Returns the context scheduling priority nice-value +[[gnu::hot]] +const int8_t & +ircd::ctx::nice(const ctx &ctx) +noexcept +{ + return ctx.nice; +} + /// Returns the yield count for `ctx` [[gnu::hot]] const uint64_t & diff --git a/ircd/ctx.h b/ircd/ctx.h index 3f4be170f..2940ce8e6 100644 --- a/ircd/ctx.h +++ b/ircd/ctx.h @@ -52,6 +52,8 @@ struct ircd::ctx::ctx uint64_t id {++id_ctr}; // Unique runtime ID string_view name; // User given name (optional) context::flags flags; // User given flags + int8_t nice {0}; // Scheduling priority nice-value + int8_t ionice {0}; // IO priority nice-value (defaults for fs::opts) int32_t notes {0}; // norm: 0 = asleep; 1 = awake; inc by others; dec by self boost::asio::io_service::strand strand; // mutex/serializer boost::asio::deadline_timer alarm; // acting semaphore (64B) diff --git a/ircd/db_env.cc b/ircd/db_env.cc index 2f8c44688..61510b44e 100644 --- a/ircd/db_env.cc +++ b/ircd/db_env.cc @@ -3987,6 +3987,8 @@ ircd::db::database::env::state::pool::pool(database &d, { pri == Priority::HIGH? IOPriority::IO_HIGH: + pri == Priority::BOTTOM? + IOPriority::IO_LOW: IOPriority::IO_LOW } ,name @@ -4002,6 +4004,10 @@ ircd::db::database::env::state::pool::pool(database &d, 0, // initial workers -1, // queue hard limit -1, // queue soft limit + true, // queue_max_blocking + true, // queue_max_dwarning + make_nice(iopri), // ionice + make_nice(this->pri), // nice } ,p {