Adjust default number of threads for JobQueue:

The existing calculation would limit the maximum number of threads
that would be created by default to at most 6; this may have been
reasonable a few years ago, but given both the load on the network
as of today and the increase in the number of CPU cores, the value
should be revisited.

This commit, if merged, changes the default calculation for nodes
that are configured as `large` or `huge` to allow for up to twelve
threads.
This commit is contained in:
Nik Bougalis
2021-11-09 02:04:34 -08:00
parent eaff0d30fb
commit eb6b79bed7
8 changed files with 90 additions and 57 deletions

View File

@@ -28,6 +28,7 @@ struct Transaction_ordering_test : public beast::unit_test::suite
testCorrectOrder()
{
using namespace jtx;
testcase("Correct Order");
Env env(*this);
auto const alice = Account("alice");
@@ -69,8 +70,13 @@ struct Transaction_ordering_test : public beast::unit_test::suite
{
using namespace jtx;
Env env(*this);
env.app().getJobQueue().setThreadCount(0, false);
testcase("Incorrect order");
Env env(*this, envconfig([](std::unique_ptr<Config> cfg) {
cfg->FORCE_MULTI_THREAD = false;
return cfg;
}));
auto const alice = Account("alice");
env.fund(XRP(1000), noripple(alice));
@@ -109,8 +115,13 @@ struct Transaction_ordering_test : public beast::unit_test::suite
{
using namespace jtx;
Env env(*this);
env.app().getJobQueue().setThreadCount(0, false);
testcase("Incorrect order multiple intermediaries");
Env env(*this, envconfig([](std::unique_ptr<Config> cfg) {
cfg->FORCE_MULTI_THREAD = true;
return cfg;
}));
auto const alice = Account("alice");
env.fund(XRP(1000), noripple(alice));

View File

@@ -63,17 +63,23 @@ public:
{
using namespace std::chrono_literals;
using namespace jtx;
Env env(*this);
auto& jq = env.app().getJobQueue();
jq.setThreadCount(0, false);
testcase("correct order");
Env env(*this, envconfig([](std::unique_ptr<Config> cfg) {
cfg->FORCE_MULTI_THREAD = true;
return cfg;
}));
gate g1, g2;
std::shared_ptr<JobQueue::Coro> c;
jq.postCoro(jtCLIENT, "Coroutine-Test", [&](auto const& cr) {
c = cr;
g1.signal();
c->yield();
g2.signal();
});
env.app().getJobQueue().postCoro(
jtCLIENT, "Coroutine-Test", [&](auto const& cr) {
c = cr;
g1.signal();
c->yield();
g2.signal();
});
BEAST_EXPECT(g1.wait_for(5s));
c->join();
c->post();
@@ -85,15 +91,21 @@ public:
{
using namespace std::chrono_literals;
using namespace jtx;
Env env(*this);
auto& jq = env.app().getJobQueue();
jq.setThreadCount(0, false);
testcase("incorrect order");
Env env(*this, envconfig([](std::unique_ptr<Config> cfg) {
cfg->FORCE_MULTI_THREAD = true;
return cfg;
}));
gate g;
jq.postCoro(jtCLIENT, "Coroutine-Test", [&](auto const& c) {
c->post();
c->yield();
g.signal();
});
env.app().getJobQueue().postCoro(
jtCLIENT, "Coroutine-Test", [&](auto const& c) {
c->post();
c->yield();
g.signal();
});
BEAST_EXPECT(g.wait_for(5s));
}
@@ -102,9 +114,12 @@ public:
{
using namespace std::chrono_literals;
using namespace jtx;
testcase("thread specific storage");
Env env(*this);
auto& jq = env.app().getJobQueue();
jq.setThreadCount(0, true);
static int const N = 4;
std::array<std::shared_ptr<JobQueue::Coro>, N> a;