Merge pull request #4098 from sfc-gh-tclinkenbeard/simplify-global-knobs
Simplified global knobs
This commit is contained in:
commit
3472237c5d
|
@ -3580,19 +3580,10 @@ int main(int argc, char* argv[]) {
|
|||
}
|
||||
}
|
||||
|
||||
delete FLOW_KNOBS;
|
||||
FlowKnobs* flowKnobs = new FlowKnobs;
|
||||
FLOW_KNOBS = flowKnobs;
|
||||
|
||||
delete CLIENT_KNOBS;
|
||||
ClientKnobs* clientKnobs = new ClientKnobs;
|
||||
CLIENT_KNOBS = clientKnobs;
|
||||
|
||||
for(auto k=knobs.begin(); k!=knobs.end(); ++k) {
|
||||
try {
|
||||
if (!flowKnobs->setKnob( k->first, k->second ) &&
|
||||
!clientKnobs->setKnob( k->first, k->second ))
|
||||
{
|
||||
if (!globalFlowKnobs->setKnob(k->first, k->second) &&
|
||||
!globalClientKnobs->setKnob(k->first, k->second)) {
|
||||
fprintf(stderr, "WARNING: Unrecognized knob option '%s'\n", k->first.c_str());
|
||||
TraceEvent(SevWarnAlways, "UnrecognizedKnobOption").detail("Knob", printable(k->first));
|
||||
}
|
||||
|
@ -3610,8 +3601,8 @@ int main(int argc, char* argv[]) {
|
|||
}
|
||||
|
||||
// Reinitialize knobs in order to update knobs that are dependent on explicitly set knobs
|
||||
flowKnobs->initialize(true);
|
||||
clientKnobs->initialize(true);
|
||||
globalFlowKnobs->initialize(true);
|
||||
globalClientKnobs->initialize(true);
|
||||
|
||||
if (trace) {
|
||||
if(!traceLogGroup.empty())
|
||||
|
|
|
@ -2857,17 +2857,9 @@ struct CLIOptions {
|
|||
return;
|
||||
}
|
||||
|
||||
delete FLOW_KNOBS;
|
||||
FlowKnobs* flowKnobs = new FlowKnobs;
|
||||
FLOW_KNOBS = flowKnobs;
|
||||
|
||||
delete CLIENT_KNOBS;
|
||||
ClientKnobs* clientKnobs = new ClientKnobs;
|
||||
CLIENT_KNOBS = clientKnobs;
|
||||
|
||||
for (const auto& [knob, value] : knobs) {
|
||||
try {
|
||||
if (!flowKnobs->setKnob(knob, value) && !clientKnobs->setKnob(knob, value)) {
|
||||
if (!globalFlowKnobs->setKnob(knob, value) && !globalClientKnobs->setKnob(knob, value)) {
|
||||
fprintf(stderr, "WARNING: Unrecognized knob option '%s'\n", knob.c_str());
|
||||
TraceEvent(SevWarnAlways, "UnrecognizedKnobOption").detail("Knob", printable(knob));
|
||||
}
|
||||
|
@ -2890,8 +2882,8 @@ struct CLIOptions {
|
|||
}
|
||||
|
||||
// Reinitialize knobs in order to update knobs that are dependent on explicitly set knobs
|
||||
flowKnobs->initialize(true);
|
||||
clientKnobs->initialize(true);
|
||||
globalFlowKnobs->initialize(true);
|
||||
globalClientKnobs->initialize(true);
|
||||
}
|
||||
|
||||
int processArg(CSimpleOpt& args) {
|
||||
|
|
|
@ -23,7 +23,8 @@
|
|||
#include "fdbclient/SystemData.h"
|
||||
#include "flow/UnitTest.h"
|
||||
|
||||
ClientKnobs const* CLIENT_KNOBS = new ClientKnobs();
|
||||
std::unique_ptr<ClientKnobs> globalClientKnobs = std::make_unique<ClientKnobs>();
|
||||
ClientKnobs const* CLIENT_KNOBS = globalClientKnobs.get();
|
||||
|
||||
#define init( knob, value ) initKnob( knob, value, #knob )
|
||||
|
||||
|
|
|
@ -232,6 +232,7 @@ public:
|
|||
void initialize(bool randomize = false);
|
||||
};
|
||||
|
||||
extern std::unique_ptr<ClientKnobs> globalClientKnobs;
|
||||
extern ClientKnobs const* CLIENT_KNOBS;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1444,22 +1444,17 @@ void setNetworkOption(FDBNetworkOptions::Option option, Optional<StringRef> valu
|
|||
|
||||
std::string knobName = optionValue.substr(0, eq);
|
||||
std::string knobValue = optionValue.substr(eq+1);
|
||||
if (const_cast<FlowKnobs*>(FLOW_KNOBS)->setKnob(knobName, knobValue))
|
||||
{
|
||||
// update dependent knobs
|
||||
const_cast<FlowKnobs*>(FLOW_KNOBS)->initialize();
|
||||
}
|
||||
else if (const_cast<ClientKnobs*>(CLIENT_KNOBS)->setKnob(knobName, knobValue))
|
||||
{
|
||||
// update dependent knobs
|
||||
const_cast<ClientKnobs*>(CLIENT_KNOBS)->initialize();
|
||||
}
|
||||
else
|
||||
{
|
||||
TraceEvent(SevWarnAlways, "UnrecognizedKnob").detail("Knob", knobName.c_str());
|
||||
if (globalFlowKnobs->setKnob(knobName, knobValue)) {
|
||||
// update dependent knobs
|
||||
globalFlowKnobs->initialize();
|
||||
} else if (globalClientKnobs->setKnob(knobName, knobValue)) {
|
||||
// update dependent knobs
|
||||
globalClientKnobs->initialize();
|
||||
} else {
|
||||
TraceEvent(SevWarnAlways, "UnrecognizedKnob").detail("Knob", knobName.c_str());
|
||||
fprintf(stderr, "FoundationDB client ignoring unrecognized knob option '%s'\n", knobName.c_str());
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case FDBNetworkOptions::TLS_PLUGIN:
|
||||
validateOptionValue(value, true);
|
||||
|
|
|
@ -22,7 +22,8 @@
|
|||
#include "fdbrpc/Locality.h"
|
||||
#include <cmath>
|
||||
|
||||
ServerKnobs const* SERVER_KNOBS = new ServerKnobs();
|
||||
std::unique_ptr<ServerKnobs> globalServerKnobs = std::make_unique<ServerKnobs>();
|
||||
ServerKnobs const* SERVER_KNOBS = globalServerKnobs.get();
|
||||
|
||||
#define init( knob, value ) initKnob( knob, value, #knob )
|
||||
|
||||
|
|
|
@ -633,6 +633,7 @@ public:
|
|||
void initialize(bool randomize = false, ClientKnobs* clientKnobs = nullptr, bool isSimulated = false);
|
||||
};
|
||||
|
||||
extern std::unique_ptr<ServerKnobs> globalServerKnobs;
|
||||
extern ServerKnobs const* SERVER_KNOBS;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1584,27 +1584,16 @@ int main(int argc, char* argv[]) {
|
|||
|
||||
enableBuggify(opts.buggifyEnabled, BuggifyType::General);
|
||||
|
||||
delete FLOW_KNOBS;
|
||||
delete SERVER_KNOBS;
|
||||
delete CLIENT_KNOBS;
|
||||
FlowKnobs* flowKnobs = new FlowKnobs;
|
||||
ClientKnobs* clientKnobs = new ClientKnobs;
|
||||
ServerKnobs* serverKnobs = new ServerKnobs;
|
||||
FLOW_KNOBS = flowKnobs;
|
||||
SERVER_KNOBS = serverKnobs;
|
||||
CLIENT_KNOBS = clientKnobs;
|
||||
|
||||
if (!serverKnobs->setKnob("log_directory", opts.logFolder)) ASSERT(false);
|
||||
if (!globalServerKnobs->setKnob("log_directory", opts.logFolder)) ASSERT(false);
|
||||
if (role != ServerRole::Simulation) {
|
||||
if (!serverKnobs->setKnob("commit_batches_mem_bytes_hard_limit", std::to_string(opts.memLimit)))
|
||||
if (!globalServerKnobs->setKnob("commit_batches_mem_bytes_hard_limit", std::to_string(opts.memLimit)))
|
||||
ASSERT(false);
|
||||
}
|
||||
for (auto k = opts.knobs.begin(); k != opts.knobs.end(); ++k) {
|
||||
try {
|
||||
if (!flowKnobs->setKnob( k->first, k->second ) &&
|
||||
!clientKnobs->setKnob( k->first, k->second ) &&
|
||||
!serverKnobs->setKnob( k->first, k->second ))
|
||||
{
|
||||
if (!globalFlowKnobs->setKnob(k->first, k->second) &&
|
||||
!globalClientKnobs->setKnob(k->first, k->second) &&
|
||||
!globalServerKnobs->setKnob(k->first, k->second)) {
|
||||
fprintf(stderr, "WARNING: Unrecognized knob option '%s'\n", k->first.c_str());
|
||||
TraceEvent(SevWarnAlways, "UnrecognizedKnobOption").detail("Knob", printable(k->first));
|
||||
}
|
||||
|
@ -1619,15 +1608,15 @@ int main(int argc, char* argv[]) {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (!serverKnobs->setKnob("server_mem_limit", std::to_string(opts.memLimit))) ASSERT(false);
|
||||
if (!globalServerKnobs->setKnob("server_mem_limit", std::to_string(opts.memLimit))) ASSERT(false);
|
||||
|
||||
// Reinitialize knobs in order to update knobs that are dependent on explicitly set knobs
|
||||
flowKnobs->initialize(true, role == ServerRole::Simulation);
|
||||
clientKnobs->initialize(true);
|
||||
serverKnobs->initialize(true, clientKnobs, role == ServerRole::Simulation);
|
||||
globalFlowKnobs->initialize(true, role == ServerRole::Simulation);
|
||||
globalClientKnobs->initialize(true);
|
||||
globalServerKnobs->initialize(true, globalClientKnobs.get(), role == ServerRole::Simulation);
|
||||
|
||||
// evictionPolicyStringToEnum will throw an exception if the string is not recognized as a valid
|
||||
EvictablePageCache::evictionPolicyStringToEnum(flowKnobs->CACHE_EVICTION_POLICY);
|
||||
EvictablePageCache::evictionPolicyStringToEnum(FLOW_KNOBS->CACHE_EVICTION_POLICY);
|
||||
|
||||
if (opts.memLimit <= FLOW_KNOBS->PAGE_CACHE_4K) {
|
||||
fprintf(stderr, "ERROR: --memory has to be larger than --cache_memory\n");
|
||||
|
@ -1765,9 +1754,9 @@ int main(int argc, char* argv[]) {
|
|||
|
||||
auto histogramReportActor = histogramReport();
|
||||
|
||||
clientKnobs->trace();
|
||||
flowKnobs->trace();
|
||||
serverKnobs->trace();
|
||||
CLIENT_KNOBS->trace();
|
||||
FLOW_KNOBS->trace();
|
||||
SERVER_KNOBS->trace();
|
||||
|
||||
auto dataFolder = opts.dataFolder.size() ? opts.dataFolder : "simfdb";
|
||||
std::vector<std::string> directories = platform::listDirectories( dataFolder );
|
||||
|
|
|
@ -187,7 +187,7 @@ struct ClientTransactionProfileCorrectnessWorkload : TestWorkload {
|
|||
|
||||
Future<Void> setup(Database const& cx) override {
|
||||
if (clientId == 0) {
|
||||
const_cast<ClientKnobs *>(CLIENT_KNOBS)->CSI_STATUS_DELAY = 2.0; // 2 seconds
|
||||
globalClientKnobs->CSI_STATUS_DELAY = 2.0; // 2 seconds
|
||||
return changeProfilingParameters(cx, trInfoSizeLimit, samplingProbability);
|
||||
}
|
||||
return Void();
|
||||
|
|
|
@ -23,7 +23,8 @@
|
|||
#include <cmath>
|
||||
#include <cinttypes>
|
||||
|
||||
FlowKnobs const* FLOW_KNOBS = new FlowKnobs();
|
||||
std::unique_ptr<FlowKnobs> globalFlowKnobs = std::make_unique<FlowKnobs>();
|
||||
FlowKnobs const* FLOW_KNOBS = globalFlowKnobs.get();
|
||||
|
||||
#define init( knob, value ) initKnob( knob, value, #knob )
|
||||
|
||||
|
@ -336,7 +337,7 @@ void Knobs::initKnob( bool& knob, bool value, std::string const& name ) {
|
|||
}
|
||||
}
|
||||
|
||||
void Knobs::trace() {
|
||||
void Knobs::trace() const {
|
||||
for(auto &k : double_knobs)
|
||||
TraceEvent("Knob").detail("Name", k.first.c_str()).detail("Value", *k.second);
|
||||
for(auto &k : int_knobs)
|
||||
|
|
|
@ -32,9 +32,10 @@
|
|||
class Knobs {
|
||||
public:
|
||||
bool setKnob( std::string const& name, std::string const& value ); // Returns true if the knob name is known, false if it is unknown
|
||||
void trace();
|
||||
void trace() const;
|
||||
|
||||
protected:
|
||||
Knobs()=default;
|
||||
void initKnob( double& knob, double value, std::string const& name );
|
||||
void initKnob( int64_t& knob, int64_t value, std::string const& name );
|
||||
void initKnob( int& knob, int value, std::string const& name );
|
||||
|
@ -256,6 +257,7 @@ public:
|
|||
void initialize(bool randomize = false, bool isSimulated = false);
|
||||
};
|
||||
|
||||
extern std::unique_ptr<FlowKnobs> globalFlowKnobs;
|
||||
extern FlowKnobs const* FLOW_KNOBS;
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue