Skip to content

Commit

Permalink
Support new experimental parallel ledger close config
Browse files Browse the repository at this point in the history
  • Loading branch information
marta-lokhova committed Jan 3, 2025
1 parent 428ced3 commit 483b558
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 1 deletion.
34 changes: 33 additions & 1 deletion src/main/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ static const std::unordered_set<std::string> TESTING_ONLY_OPTIONS = {
"ARTIFICIALLY_SET_SURVEY_PHASE_DURATION_FOR_TESTING",
"ARTIFICIALLY_DELAY_BUCKET_APPLICATION_FOR_TESTING",
"ARTIFICIALLY_SLEEP_MAIN_THREAD_FOR_TESTING",
"ARTIFICIALLY_SKIP_CONNECTION_ADJUSTMENT_FOR_TESTING"};
"ARTIFICIALLY_SKIP_CONNECTION_ADJUSTMENT_FOR_TESTING",
"ARTIFICIALLY_DELAY_LEDGER_CLOSE_FOR_TESTING"};

// Options that should only be used for testing
static const std::unordered_set<std::string> TESTING_SUGGESTED_OPTIONS = {
Expand Down Expand Up @@ -156,6 +157,7 @@ Config::Config() : NODE_SEED(SecretKey::random())
CATCHUP_COMPLETE = false;
CATCHUP_RECENT = 0;
BACKGROUND_OVERLAY_PROCESSING = true;
EXPERIMENTAL_PARALLEL_LEDGER_CLOSE = false;
BUCKETLIST_DB_INDEX_PAGE_SIZE_EXPONENT = 14; // 2^14 == 16 kb
BUCKETLIST_DB_INDEX_CUTOFF = 20; // 20 mb
BUCKETLIST_DB_PERSIST_INDEX = true;
Expand All @@ -181,6 +183,7 @@ Config::Config() : NODE_SEED(SecretKey::random())
ARTIFICIALLY_REPLAY_WITH_NEWEST_BUCKET_LOGIC_FOR_TESTING = false;
ARTIFICIALLY_DELAY_BUCKET_APPLICATION_FOR_TESTING =
std::chrono::seconds::zero();
ARTIFICIALLY_DELAY_LEDGER_CLOSE_FOR_TESTING = std::chrono::milliseconds(0);
ALLOW_LOCALHOST_FOR_TESTING = false;
USE_CONFIG_FOR_GENESIS = false;
FAILURE_SAFETY = -1;
Expand Down Expand Up @@ -1063,6 +1066,15 @@ Config::processConfig(std::shared_ptr<cpptoml::table> t)
}},
{"BACKGROUND_OVERLAY_PROCESSING",
[&]() { BACKGROUND_OVERLAY_PROCESSING = readBool(item); }},
{"EXPERIMENTAL_PARALLEL_LEDGER_CLOSE",
[&]() {
EXPERIMENTAL_PARALLEL_LEDGER_CLOSE = readBool(item);
}},
{"ARTIFICIALLY_DELAY_LEDGER_CLOSE_FOR_TESTING",
[&]() {
ARTIFICIALLY_DELAY_LEDGER_CLOSE_FOR_TESTING =
std::chrono::milliseconds(readInt<uint32_t>(item));
}},
// https://github.com/stellar/stellar-core/issues/4581
{"BACKGROUND_EVICTION_SCAN",
[&]() {
Expand Down Expand Up @@ -1767,6 +1779,15 @@ Config::processConfig(std::shared_ptr<cpptoml::table> t)
throw std::runtime_error(msg);
}

if (EXPERIMENTAL_PARALLEL_LEDGER_CLOSE && !parallelLedgerClose())
{
std::string msg =
"Invalid configuration: EXPERIMENTAL_PARALLEL_LEDGER_CLOSE "
"does not support SQLite. Either switch to Postgres or set "
"EXPERIMENTAL_PARALLEL_LEDGER_CLOSE=false";
throw std::runtime_error(msg);
}

// Check all loadgen distributions
verifyLoadGenOpCountForTestingConfigs();
verifyLoadGenDistribution(
Expand Down Expand Up @@ -2069,6 +2090,10 @@ Config::logBasicInfo() const
"BACKGROUND_OVERLAY_PROCESSING="
"{}",
BACKGROUND_OVERLAY_PROCESSING ? "true" : "false");
LOG_INFO(DEFAULT_LOG,
"EXPERIMENTAL_PARALLEL_LEDGER_CLOSE="
"{}",
EXPERIMENTAL_PARALLEL_LEDGER_CLOSE ? "true" : "false");
}

void
Expand Down Expand Up @@ -2363,6 +2388,13 @@ Config::modeStoresAnyHistory() const
return MODE_STORES_HISTORY_LEDGERHEADERS || MODE_STORES_HISTORY_MISC;
}

bool
Config::parallelLedgerClose() const
{
return EXPERIMENTAL_PARALLEL_LEDGER_CLOSE &&
!(DATABASE.value.find("sqlite3://") != std::string::npos);
}

void
Config::setNoListen()
{
Expand Down
10 changes: 10 additions & 0 deletions src/main/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ class Config : public std::enable_shared_from_this<Config>
#endif
TESTDB_BUCKET_DB_VOLATILE,
TESTDB_BUCKET_DB_PERSISTENT,
TESTDB_BUCKET_DB_PERSISTENT_POSTGRES,
TESTDB_MODES
};

Expand Down Expand Up @@ -262,6 +263,11 @@ class Config : public std::enable_shared_from_this<Config>
// This config should only be enabled when testing.
std::chrono::microseconds ARTIFICIALLY_SLEEP_MAIN_THREAD_FOR_TESTING;

// A config parameter that forces stellar-core to sleep every time it closes
// a ledger if order to simulate slow application. This config should only
// be enabled when testing.
std::chrono::milliseconds ARTIFICIALLY_DELAY_LEDGER_CLOSE_FOR_TESTING;

// Timeout before publishing externalized values to archive
std::chrono::seconds PUBLISH_TO_ARCHIVE_DELAY;

Expand Down Expand Up @@ -457,6 +463,9 @@ class Config : public std::enable_shared_from_this<Config>
// Enable parallel processing of overlay operations (experimental)
bool BACKGROUND_OVERLAY_PROCESSING;

// Enable parallel block application (experimental)
bool EXPERIMENTAL_PARALLEL_LEDGER_CLOSE;

// When set to true, BucketListDB indexes are persisted on-disk so that the
// BucketList does not need to be reindexed on startup. Defaults to true.
// This should only be set to false for testing purposes
Expand Down Expand Up @@ -785,6 +794,7 @@ class Config : public std::enable_shared_from_this<Config>
bool modeStoresAllHistory() const;
bool modeStoresAnyHistory() const;
void logBasicInfo() const;
bool parallelLedgerClose() const;
void setNoListen();
void setNoPublish();

Expand Down
4 changes: 4 additions & 0 deletions src/test/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,10 @@ getTestConfig(int instanceNumber, Config::TestDbMode mode)
thisConfig.DISABLE_XDR_FSYNC = false;
break;
#ifdef USE_POSTGRES
case Config::TESTDB_BUCKET_DB_PERSISTENT_POSTGRES:
dbname << "postgresql://dbname=test" << instanceNumber;
thisConfig.DISABLE_XDR_FSYNC = false;
break;
case Config::TESTDB_POSTGRESQL:
dbname << "postgresql://dbname=test" << instanceNumber;
thisConfig.DISABLE_XDR_FSYNC = false;
Expand Down

0 comments on commit 483b558

Please sign in to comment.