Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Config options to specify IO and prefetch worker count #3994

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions cfg/rippled-example.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -769,6 +769,14 @@
# number of processor threads plus 2 for networked nodes. Nodes running in
# stand alone mode default to 1 worker.
#
# [io_workers]
#
# Configures the number of threads for processing raw inbound and outbound IO.
#
# [prefetch_workers]
#
# Configures the number of threads for performing nodestore prefetching.
#
#
#
# [network_id]
Expand Down
7 changes: 6 additions & 1 deletion src/ripple/app/main/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,10 @@ class ApplicationImp : public Application, public BasicApp
#if RIPPLE_SINGLE_IO_SERVICE_THREAD
return 1;
#else

if (config.IO_WORKERS > 0)
return config.IO_WORKERS;

auto const cores = std::thread::hardware_concurrency();

// Use a single thread when running on under-provisioned systems
Expand Down Expand Up @@ -342,7 +346,8 @@ class ApplicationImp : public Application, public BasicApp
m_collectorManager->collector(),
logs_->journal("Resource")))

, m_nodeStore(m_shaMapStore->makeNodeStore(4))
, m_nodeStore(m_shaMapStore->makeNodeStore(
config_->PREFETCH_WORKERS > 0 ? config_->PREFETCH_WORKERS : 4))

, nodeFamily_(*this, *m_collectorManager)

Expand Down
7 changes: 5 additions & 2 deletions src/ripple/core/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,11 @@ class Config : public BasicConfig
// Amendment majority time
std::chrono::seconds AMENDMENT_MAJORITY_TIME = defaultAmendmentMajorityTime;

// Thread pool configuration
int WORKERS = 0;
// Thread pool configuration (0 = choose for me)
int WORKERS = 0; // jobqueue thread count. default: upto 6
int IO_WORKERS = 0; // io svc thread count. default: 2
int PREFETCH_WORKERS = 0; // prefetch thread count. default: 4

// Can only be set in code, specifically unit tests
bool FORCE_MULTI_THREAD = false;

Expand Down
2 changes: 2 additions & 0 deletions src/ripple/core/ConfigSections.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ struct ConfigSection
#define SECTION_VALIDATOR_TOKEN "validator_token"
#define SECTION_VETO_AMENDMENTS "veto_amendments"
#define SECTION_WORKERS "workers"
#define SECTION_IO_WORKERS "io_workers"
#define SECTION_PREFETCH_WORKERS "prefetch_workers"
#define SECTION_LEDGER_REPLAY "ledger_replay"
#define SECTION_BETA_RPC_API "beta_rpc_api"
#define SECTION_SWEEP_INTERVAL "sweep_interval"
Expand Down
20 changes: 20 additions & 0 deletions src/ripple/core/impl/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,26 @@ Config::loadFromString(std::string const& fileContents)
": must be between 1 and 1024 inclusive.");
}

if (getSingleSection(secConfig, SECTION_IO_WORKERS, strTemp, j_))
{
IO_WORKERS = beast::lexicalCastThrow<int>(strTemp);

if (IO_WORKERS < 1 || IO_WORKERS > 1024)
Throw<std::runtime_error>(
"Invalid " SECTION_IO_WORKERS
": must be between 1 and 1024 inclusive.");
}

if (getSingleSection(secConfig, SECTION_PREFETCH_WORKERS, strTemp, j_))
{
PREFETCH_WORKERS = beast::lexicalCastThrow<int>(strTemp);

if (PREFETCH_WORKERS < 1 || PREFETCH_WORKERS > 1024)
Throw<std::runtime_error>(
"Invalid " SECTION_PREFETCH_WORKERS
": must be between 1 and 1024 inclusive.");
}

if (getSingleSection(secConfig, SECTION_COMPRESSION, strTemp, j_))
COMPRESSION = beast::lexicalCastThrow<bool>(strTemp);

Expand Down