1 /* 2 * Knobs.h 3 * 4 * This source file is part of the FoundationDB open source project 5 * 6 * Copyright 2013-2018 Apple Inc. and the FoundationDB project authors 7 * 8 * Licensed under the Apache License, Version 2.0 (the "License"); 9 * you may not use this file except in compliance with the License. 10 * You may obtain a copy of the License at 11 * 12 * http://www.apache.org/licenses/LICENSE-2.0 13 * 14 * Unless required by applicable law or agreed to in writing, software 15 * distributed under the License is distributed on an "AS IS" BASIS, 16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 * See the License for the specific language governing permissions and 18 * limitations under the License. 19 */ 20 21 #ifndef FLOW_KNOBS_H 22 #define FLOW_KNOBS_H 23 #pragma once 24 25 #include "flow/Platform.h" 26 27 #include <map> 28 #include <string> 29 #include <stdint.h> 30 31 class Knobs { 32 public: 33 bool setKnob( std::string const& name, std::string const& value ); // Returns true if the knob name is known, false if it is unknown 34 void trace(); 35 36 protected: 37 void initKnob( double& knob, double value, std::string const& name ); 38 void initKnob( int64_t& knob, int64_t value, std::string const& name ); 39 void initKnob( int& knob, int value, std::string const& name ); 40 void initKnob( std::string& knob, const std::string& value, const std::string& name ); 41 42 std::map<std::string, double*> double_knobs; 43 std::map<std::string, int64_t*> int64_knobs; 44 std::map<std::string, int*> int_knobs; 45 std::map<std::string, std::string*> string_knobs; 46 }; 47 48 class FlowKnobs : public Knobs { 49 public: 50 int AUTOMATIC_TRACE_DUMP; 51 double PREVENT_FAST_SPIN_DELAY; 52 double CACHE_REFRESH_INTERVAL_WHEN_ALL_ALTERNATIVES_FAILED; 53 54 double DELAY_JITTER_OFFSET; 55 double DELAY_JITTER_RANGE; 56 double BUSY_WAIT_THRESHOLD; 57 double CLIENT_REQUEST_INTERVAL; 58 double SERVER_REQUEST_INTERVAL; 59 60 int DISABLE_ASSERTS; 61 double QUEUE_MODEL_SMOOTHING_AMOUNT; 62 63 int RANDOMSEED_RETRY_LIMIT; 64 double FAST_ALLOC_LOGGING_BYTES; 65 double HUGE_ARENA_LOGGING_BYTES; 66 double HUGE_ARENA_LOGGING_INTERVAL; 67 68 //slow task profiling 69 double SLOWTASK_PROFILING_INTERVAL; 70 double SLOWTASK_PROFILING_MAX_LOG_INTERVAL; 71 double SLOWTASK_PROFILING_LOG_BACKOFF; 72 73 //connectionMonitor 74 double CONNECTION_MONITOR_LOOP_TIME; 75 double CONNECTION_MONITOR_TIMEOUT; 76 77 //FlowTransport 78 double CONNECTION_REJECTED_MESSAGE_DELAY; 79 double CONNECTION_ID_TIMEOUT; 80 double CONNECTION_CLEANUP_DELAY; 81 double INITIAL_RECONNECTION_TIME; 82 double MAX_RECONNECTION_TIME; 83 double RECONNECTION_TIME_GROWTH_RATE; 84 double RECONNECTION_RESET_TIME; 85 double CONNECTION_ACCEPT_DELAY; 86 87 int TLS_CERT_REFRESH_DELAY_SECONDS; 88 89 //AsyncFileCached 90 int64_t PAGE_CACHE_4K; 91 int64_t PAGE_CACHE_64K; 92 int64_t SIM_PAGE_CACHE_4K; 93 int64_t SIM_PAGE_CACHE_64K; 94 int64_t BUGGIFY_SIM_PAGE_CACHE_4K; 95 int64_t BUGGIFY_SIM_PAGE_CACHE_64K; 96 int MAX_EVICT_ATTEMPTS; 97 double PAGE_CACHE_TRUNCATE_LOOKUP_FRACTION; 98 double TOO_MANY_CONNECTIONS_CLOSED_RESET_DELAY; 99 int TOO_MANY_CONNECTIONS_CLOSED_TIMEOUT; 100 101 //AsyncFileKAIO 102 int MAX_OUTSTANDING; 103 int MIN_SUBMIT; 104 105 int PAGE_WRITE_CHECKSUM_HISTORY; 106 int DISABLE_POSIX_KERNEL_AIO; 107 108 //AsyncFileNonDurable 109 double MAX_PRIOR_MODIFICATION_DELAY; 110 111 //GenericActors 112 double MAX_DELIVER_DUPLICATE_DELAY; 113 double BUGGIFY_FLOW_LOCK_RELEASE_DELAY; 114 115 //IAsyncFile 116 int64_t INCREMENTAL_DELETE_TRUNCATE_AMOUNT; 117 double INCREMENTAL_DELETE_INTERVAL; 118 119 //Net2 120 double MIN_COALESCE_DELAY; 121 double MAX_COALESCE_DELAY; 122 double SLOW_LOOP_CUTOFF; 123 double SLOW_LOOP_SAMPLING_RATE; 124 int64_t TSC_YIELD_TIME; 125 int64_t REACTOR_FLAGS; 126 127 //Network 128 int64_t PACKET_LIMIT; 129 int64_t PACKET_WARNING; // 2MB packet warning quietly allows for 1MB system messages 130 double TIME_OFFSET_LOGGING_INTERVAL; 131 132 //Sim2 133 //FIMXE: more parameters could be factored out 134 double MIN_OPEN_TIME; 135 double MAX_OPEN_TIME; 136 int64_t SIM_DISK_IOPS; 137 int64_t SIM_DISK_BANDWIDTH; 138 double MIN_NETWORK_LATENCY; 139 double FAST_NETWORK_LATENCY; 140 double SLOW_NETWORK_LATENCY; 141 double MAX_CLOGGING_LATENCY; 142 double MAX_BUGGIFIED_DELAY; 143 144 //Tracefiles 145 int ZERO_LENGTH_FILE_PAD; 146 double TRACE_FLUSH_INTERVAL; 147 double TRACE_RETRY_OPEN_INTERVAL; 148 int MIN_TRACE_SEVERITY; 149 int MAX_TRACE_SUPPRESSIONS; 150 int TRACE_SYNC_ENABLED; 151 int TRACE_EVENT_METRIC_UNITS_PER_SAMPLE; 152 int TRACE_EVENT_THROTTLER_SAMPLE_EXPIRY; 153 int TRACE_EVENT_THROTTLER_MSG_LIMIT; 154 155 //TDMetrics 156 int64_t MAX_METRIC_SIZE; 157 int64_t MAX_METRIC_LEVEL; 158 double METRIC_LEVEL_DIVISOR; 159 int METRIC_LIMIT_START_QUEUE_SIZE; 160 int METRIC_LIMIT_RESPONSE_FACTOR; 161 int MAX_METRICS; 162 163 //Load Balancing 164 double LOAD_BALANCE_MAX_BACKOFF; 165 double LOAD_BALANCE_START_BACKOFF; 166 double LOAD_BALANCE_BACKOFF_RATE; 167 int64_t MAX_LAGGING_REQUESTS_OUTSTANDING; 168 double INSTANT_SECOND_REQUEST_MULTIPLIER; 169 double BASE_SECOND_REQUEST_TIME; 170 double SECOND_REQUEST_MULTIPLIER_GROWTH; 171 double SECOND_REQUEST_MULTIPLIER_DECAY; 172 double SECOND_REQUEST_BUDGET_GROWTH; 173 double SECOND_REQUEST_MAX_BUDGET; 174 double ALTERNATIVES_FAILURE_RESET_TIME; 175 double ALTERNATIVES_FAILURE_MAX_DELAY; 176 double ALTERNATIVES_FAILURE_MIN_DELAY; 177 double ALTERNATIVES_FAILURE_DELAY_RATIO; 178 double FUTURE_VERSION_INITIAL_BACKOFF; 179 double FUTURE_VERSION_MAX_BACKOFF; 180 double FUTURE_VERSION_BACKOFF_GROWTH; 181 182 FlowKnobs(bool randomize = false, bool isSimulated = false); 183 }; 184 185 extern FlowKnobs const* FLOW_KNOBS; 186 187 #endif 188