mirror of
https://github.com/apple/foundationdb.git
synced 2025-05-15 02:18:39 +08:00
Merge pull request #6000 from sfc-gh-tclinkenbeard/setup-flow-knobs
Setup global flow knobs in `setupNetwork`
This commit is contained in:
commit
3d0ed2083c
@ -3762,35 +3762,6 @@ int main(int argc, char* argv[]) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IKnobCollection::setGlobalKnobCollection(IKnobCollection::Type::CLIENT, Randomize::False, IsSimulated::False);
|
|
||||||
auto& g_knobs = IKnobCollection::getMutableGlobalKnobCollection();
|
|
||||||
for (const auto& [knobName, knobValueString] : knobs) {
|
|
||||||
try {
|
|
||||||
auto knobValue = g_knobs.parseKnobValue(knobName, knobValueString);
|
|
||||||
g_knobs.setKnob(knobName, knobValue);
|
|
||||||
} catch (Error& e) {
|
|
||||||
if (e.code() == error_code_invalid_option_value) {
|
|
||||||
fprintf(stderr,
|
|
||||||
"WARNING: Invalid value '%s' for knob option '%s'\n",
|
|
||||||
knobValueString.c_str(),
|
|
||||||
knobName.c_str());
|
|
||||||
TraceEvent(SevWarnAlways, "InvalidKnobValue")
|
|
||||||
.detail("Knob", printable(knobName))
|
|
||||||
.detail("Value", printable(knobValueString));
|
|
||||||
} else {
|
|
||||||
fprintf(stderr, "ERROR: Failed to set knob option '%s': %s\n", knobName.c_str(), e.what());
|
|
||||||
TraceEvent(SevError, "FailedToSetKnob")
|
|
||||||
.detail("Knob", printable(knobName))
|
|
||||||
.detail("Value", printable(knobValueString))
|
|
||||||
.error(e);
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reinitialize knobs in order to update knobs that are dependent on explicitly set knobs
|
|
||||||
g_knobs.initialize(Randomize::False, IsSimulated::False);
|
|
||||||
|
|
||||||
if (trace) {
|
if (trace) {
|
||||||
if (!traceLogGroup.empty())
|
if (!traceLogGroup.empty())
|
||||||
setNetworkOption(FDBNetworkOptions::TRACE_LOG_GROUP, StringRef(traceLogGroup));
|
setNetworkOption(FDBNetworkOptions::TRACE_LOG_GROUP, StringRef(traceLogGroup));
|
||||||
@ -3831,6 +3802,34 @@ int main(int argc, char* argv[]) {
|
|||||||
return FDB_EXIT_ERROR;
|
return FDB_EXIT_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto& g_knobs = IKnobCollection::getMutableGlobalKnobCollection();
|
||||||
|
for (const auto& [knobName, knobValueString] : knobs) {
|
||||||
|
try {
|
||||||
|
auto knobValue = g_knobs.parseKnobValue(knobName, knobValueString);
|
||||||
|
g_knobs.setKnob(knobName, knobValue);
|
||||||
|
} catch (Error& e) {
|
||||||
|
if (e.code() == error_code_invalid_option_value) {
|
||||||
|
fprintf(stderr,
|
||||||
|
"WARNING: Invalid value '%s' for knob option '%s'\n",
|
||||||
|
knobValueString.c_str(),
|
||||||
|
knobName.c_str());
|
||||||
|
TraceEvent(SevWarnAlways, "InvalidKnobValue")
|
||||||
|
.detail("Knob", printable(knobName))
|
||||||
|
.detail("Value", printable(knobValueString));
|
||||||
|
} else {
|
||||||
|
fprintf(stderr, "ERROR: Failed to set knob option '%s': %s\n", knobName.c_str(), e.what());
|
||||||
|
TraceEvent(SevError, "FailedToSetKnob")
|
||||||
|
.detail("Knob", printable(knobName))
|
||||||
|
.detail("Value", printable(knobValueString))
|
||||||
|
.error(e);
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reinitialize knobs in order to update knobs that are dependent on explicitly set knobs
|
||||||
|
g_knobs.initialize(Randomize::False, IsSimulated::False);
|
||||||
|
|
||||||
TraceEvent("ProgramStart")
|
TraceEvent("ProgramStart")
|
||||||
.setMaxEventLength(12000)
|
.setMaxEventLength(12000)
|
||||||
.detail("SourceVersion", getSourceVersion())
|
.detail("SourceVersion", getSourceVersion())
|
||||||
|
@ -1402,7 +1402,9 @@ struct CLIOptions {
|
|||||||
exit_code = FDB_EXIT_ERROR;
|
exit_code = FDB_EXIT_ERROR;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void setupKnobs() {
|
||||||
auto& g_knobs = IKnobCollection::getMutableGlobalKnobCollection();
|
auto& g_knobs = IKnobCollection::getMutableGlobalKnobCollection();
|
||||||
for (const auto& [knobName, knobValueString] : knobs) {
|
for (const auto& [knobName, knobValueString] : knobs) {
|
||||||
try {
|
try {
|
||||||
@ -2432,8 +2434,6 @@ int main(int argc, char** argv) {
|
|||||||
|
|
||||||
registerCrashHandler();
|
registerCrashHandler();
|
||||||
|
|
||||||
IKnobCollection::setGlobalKnobCollection(IKnobCollection::Type::CLIENT, Randomize::False, IsSimulated::False);
|
|
||||||
|
|
||||||
#ifdef __unixish__
|
#ifdef __unixish__
|
||||||
struct sigaction act;
|
struct sigaction act;
|
||||||
|
|
||||||
@ -2534,6 +2534,10 @@ int main(int argc, char** argv) {
|
|||||||
try {
|
try {
|
||||||
API->selectApiVersion(opt.api_version);
|
API->selectApiVersion(opt.api_version);
|
||||||
API->setupNetwork();
|
API->setupNetwork();
|
||||||
|
opt.setupKnobs();
|
||||||
|
if (opt.exit_code != -1) {
|
||||||
|
return opt.exit_code;
|
||||||
|
}
|
||||||
Future<int> cliFuture = runCli(opt);
|
Future<int> cliFuture = runCli(opt);
|
||||||
Future<Void> timeoutFuture = opt.exit_timeout ? timeExit(opt.exit_timeout) : Never();
|
Future<Void> timeoutFuture = opt.exit_timeout ? timeExit(opt.exit_timeout) : Never();
|
||||||
auto f = stopNetworkAfter(success(cliFuture) || timeoutFuture);
|
auto f = stopNetworkAfter(success(cliFuture) || timeoutFuture);
|
||||||
@ -2548,4 +2552,4 @@ int main(int argc, char** argv) {
|
|||||||
fprintf(stderr, "ERROR: %s (%d)\n", e.what(), e.code());
|
fprintf(stderr, "ERROR: %s (%d)\n", e.what(), e.code());
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -83,6 +83,7 @@ std::unique_ptr<IKnobCollection>& IKnobCollection::globalKnobCollection() {
|
|||||||
|
|
||||||
void IKnobCollection::setGlobalKnobCollection(Type type, Randomize randomize, IsSimulated isSimulated) {
|
void IKnobCollection::setGlobalKnobCollection(Type type, Randomize randomize, IsSimulated isSimulated) {
|
||||||
globalKnobCollection() = create(type, randomize, isSimulated);
|
globalKnobCollection() = create(type, randomize, isSimulated);
|
||||||
|
ASSERT(FLOW_KNOBS == &bootstrapGlobalFlowKnobs);
|
||||||
FLOW_KNOBS = &globalKnobCollection()->getFlowKnobs();
|
FLOW_KNOBS = &globalKnobCollection()->getFlowKnobs();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1992,7 +1992,11 @@ void setNetworkOption(FDBNetworkOptions::Option option, Optional<StringRef> valu
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
auto knobValue = IKnobCollection::parseKnobValue(knobName, knobValueString, IKnobCollection::Type::CLIENT);
|
auto knobValue = IKnobCollection::parseKnobValue(knobName, knobValueString, IKnobCollection::Type::CLIENT);
|
||||||
IKnobCollection::getMutableGlobalKnobCollection().setKnob(knobName, knobValue);
|
if (g_network) {
|
||||||
|
IKnobCollection::getMutableGlobalKnobCollection().setKnob(knobName, knobValue);
|
||||||
|
} else {
|
||||||
|
networkOptions.knobs[knobName] = knobValue;
|
||||||
|
}
|
||||||
} catch (Error& e) {
|
} catch (Error& e) {
|
||||||
TraceEvent(SevWarnAlways, "UnrecognizedKnob").detail("Knob", knobName.c_str());
|
TraceEvent(SevWarnAlways, "UnrecognizedKnob").detail("Knob", knobName.c_str());
|
||||||
fprintf(stderr, "FoundationDB client ignoring unrecognized knob option '%s'\n", knobName.c_str());
|
fprintf(stderr, "FoundationDB client ignoring unrecognized knob option '%s'\n", knobName.c_str());
|
||||||
@ -2138,6 +2142,13 @@ ACTOR Future<Void> monitorNetworkBusyness() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void setupGlobalKnobs() {
|
||||||
|
IKnobCollection::setGlobalKnobCollection(IKnobCollection::Type::CLIENT, Randomize::False, IsSimulated::False);
|
||||||
|
for (const auto& [knobName, knobValue] : networkOptions.knobs) {
|
||||||
|
IKnobCollection::getMutableGlobalKnobCollection().setKnob(knobName, knobValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Setup g_network and start monitoring for network busyness
|
// Setup g_network and start monitoring for network busyness
|
||||||
void setupNetwork(uint64_t transportId, UseMetrics useMetrics) {
|
void setupNetwork(uint64_t transportId, UseMetrics useMetrics) {
|
||||||
if (g_network)
|
if (g_network)
|
||||||
@ -2146,6 +2157,7 @@ void setupNetwork(uint64_t transportId, UseMetrics useMetrics) {
|
|||||||
if (!networkOptions.logClientInfo.present())
|
if (!networkOptions.logClientInfo.present())
|
||||||
networkOptions.logClientInfo = true;
|
networkOptions.logClientInfo = true;
|
||||||
|
|
||||||
|
setupGlobalKnobs();
|
||||||
TLS::DisableOpenSSLAtExitHandler();
|
TLS::DisableOpenSSLAtExitHandler();
|
||||||
g_network = newNet2(tlsConfig, false, useMetrics || networkOptions.traceDirectory.present());
|
g_network = newNet2(tlsConfig, false, useMetrics || networkOptions.traceDirectory.present());
|
||||||
g_network->addStopCallback(Net2FileSystem::stop);
|
g_network->addStopCallback(Net2FileSystem::stop);
|
||||||
|
@ -72,6 +72,7 @@ struct NetworkOptions {
|
|||||||
Optional<bool> logClientInfo;
|
Optional<bool> logClientInfo;
|
||||||
Reference<ReferencedObject<Standalone<VectorRef<ClientVersionRef>>>> supportedVersions;
|
Reference<ReferencedObject<Standalone<VectorRef<ClientVersionRef>>>> supportedVersions;
|
||||||
bool runLoopProfilingEnabled;
|
bool runLoopProfilingEnabled;
|
||||||
|
std::map<std::string, KnobValue> knobs;
|
||||||
|
|
||||||
NetworkOptions();
|
NetworkOptions();
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user