From 8e116e357872634b0126957add47423b96dba014 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Wed, 18 Sep 2019 20:29:18 -0700 Subject: [PATCH] ircd::db::prefetcher: Add yield point. --- ircd/db.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ircd/db.cc b/ircd/db.cc index b16fa3cf2..02edfb7c2 100644 --- a/ircd/db.cc +++ b/ircd/db.cc @@ -3866,7 +3866,6 @@ ircd::db::prefetcher::operator()(column &c, return false; } - const ctx::critical_assertion ca; queue.emplace_back(d, c, key); queue.back().snd = now(); ++request_counter; @@ -3879,9 +3878,19 @@ ircd::db::prefetcher::operator()(column &c, if(db::request.wouldblock()) { dock.notify_one(); + + // If the user sets NO_BLOCKING we honor their request to not + // context switch for a prefetch. However by default we want to + // control queue growth, so we insert voluntary yield here to allow + // prefetch operations to at least be processed before returning to + // the user submitting more prefetches. + if(likely(!test(opts, db::get::NO_BLOCKING))) + ctx::yield(); + return true; } + const ctx::critical_assertion ca; ++directs_counter; this->handle(); return true;