2017-05-26 04:48:44 +08:00
|
|
|
/*
|
|
|
|
* Knobs.cpp
|
|
|
|
*
|
|
|
|
* This source file is part of the FoundationDB open source project
|
|
|
|
*
|
|
|
|
* Copyright 2013-2018 Apple Inc. and the FoundationDB project authors
|
2018-02-22 02:25:11 +08:00
|
|
|
*
|
2017-05-26 04:48:44 +08:00
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
2018-02-22 02:25:11 +08:00
|
|
|
*
|
2017-05-26 04:48:44 +08:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2018-02-22 02:25:11 +08:00
|
|
|
*
|
2017-05-26 04:48:44 +08:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2018-10-20 01:30:13 +08:00
|
|
|
#include "flow/Knobs.h"
|
2017-05-26 04:48:44 +08:00
|
|
|
#include "flow/flow.h"
|
2018-05-06 00:38:09 +08:00
|
|
|
#include <cmath>
|
2019-05-04 08:01:43 +08:00
|
|
|
#include <cinttypes>
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2021-06-10 11:50:00 +08:00
|
|
|
FlowKnobs::FlowKnobs(Randomize randomize, IsSimulated isSimulated) {
|
|
|
|
initialize(randomize, isSimulated);
|
|
|
|
}
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2021-06-10 13:33:00 +08:00
|
|
|
FlowKnobs bootstrapGlobalFlowKnobs(Randomize::NO, IsSimulated::NO);
|
|
|
|
FlowKnobs const* FLOW_KNOBS = &bootstrapGlobalFlowKnobs;
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2021-06-10 11:50:00 +08:00
|
|
|
#define init(knob, value) initKnob(knob, value, #knob)
|
2020-04-02 04:59:06 +08:00
|
|
|
|
2019-11-05 08:10:08 +08:00
|
|
|
// clang-format off
|
2021-06-10 11:50:00 +08:00
|
|
|
void FlowKnobs::initialize(Randomize _randomize, IsSimulated _isSimulated) {
|
|
|
|
bool const randomize = _randomize == Randomize::YES;
|
|
|
|
bool const isSimulated = _isSimulated == IsSimulated::YES;
|
2017-05-26 04:48:44 +08:00
|
|
|
init( AUTOMATIC_TRACE_DUMP, 1 );
|
|
|
|
init( PREVENT_FAST_SPIN_DELAY, .01 );
|
|
|
|
init( CACHE_REFRESH_INTERVAL_WHEN_ALL_ALTERNATIVES_FAILED, 1.0 );
|
|
|
|
|
|
|
|
init( DELAY_JITTER_OFFSET, 0.9 );
|
|
|
|
init( DELAY_JITTER_RANGE, 0.2 );
|
|
|
|
init( BUSY_WAIT_THRESHOLD, 0 ); // 1e100 == never sleep
|
2019-12-12 03:23:24 +08:00
|
|
|
init( CLIENT_REQUEST_INTERVAL, 1.0 ); if( randomize && BUGGIFY ) CLIENT_REQUEST_INTERVAL = 2.0;
|
|
|
|
init( SERVER_REQUEST_INTERVAL, 1.0 ); if( randomize && BUGGIFY ) SERVER_REQUEST_INTERVAL = 2.0;
|
2017-05-26 04:48:44 +08:00
|
|
|
|
|
|
|
init( REACTOR_FLAGS, 0 );
|
|
|
|
|
|
|
|
init( DISABLE_ASSERTS, 0 );
|
|
|
|
init( QUEUE_MODEL_SMOOTHING_AMOUNT, 2.0 );
|
|
|
|
|
2020-01-29 04:09:37 +08:00
|
|
|
init( RUN_LOOP_PROFILING_INTERVAL, 0.125 ); // A value of 0 disables run loop profiling
|
|
|
|
init( SLOWTASK_PROFILING_LOG_INTERVAL, 0 ); // A value of 0 means use RUN_LOOP_PROFILING_INTERVAL
|
2017-05-26 04:48:44 +08:00
|
|
|
init( SLOWTASK_PROFILING_MAX_LOG_INTERVAL, 1.0 );
|
|
|
|
init( SLOWTASK_PROFILING_LOG_BACKOFF, 2.0 );
|
2020-01-29 04:09:37 +08:00
|
|
|
init( SATURATION_PROFILING_LOG_INTERVAL, 0.5 ); // A value of 0 means use RUN_LOOP_PROFILING_INTERVAL
|
|
|
|
init( SATURATION_PROFILING_MAX_LOG_INTERVAL, 5.0 );
|
|
|
|
init( SATURATION_PROFILING_LOG_BACKOFF, 2.0 );
|
2017-05-26 04:48:44 +08:00
|
|
|
|
|
|
|
init( RANDOMSEED_RETRY_LIMIT, 4 );
|
2019-03-19 03:40:15 +08:00
|
|
|
init( FAST_ALLOC_LOGGING_BYTES, 10e6 );
|
2019-03-21 02:20:47 +08:00
|
|
|
init( HUGE_ARENA_LOGGING_BYTES, 100e6 );
|
2019-03-31 04:36:13 +08:00
|
|
|
init( HUGE_ARENA_LOGGING_INTERVAL, 5.0 );
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2020-09-05 08:37:34 +08:00
|
|
|
init( WRITE_TRACING_ENABLED, true ); if( randomize && BUGGIFY ) WRITE_TRACING_ENABLED = false;
|
2020-12-09 08:49:54 +08:00
|
|
|
init( TRACING_UDP_LISTENER_PORT, 8889 ); // Only applicable if TracerType is set to a network option.
|
2020-09-05 08:37:34 +08:00
|
|
|
|
2017-05-26 04:48:44 +08:00
|
|
|
//connectionMonitor
|
|
|
|
init( CONNECTION_MONITOR_LOOP_TIME, isSimulated ? 0.75 : 1.0 ); if( randomize && BUGGIFY ) CONNECTION_MONITOR_LOOP_TIME = 6.0;
|
|
|
|
init( CONNECTION_MONITOR_TIMEOUT, isSimulated ? 1.50 : 2.0 ); if( randomize && BUGGIFY ) CONNECTION_MONITOR_TIMEOUT = 6.0;
|
2019-08-10 03:35:55 +08:00
|
|
|
init( CONNECTION_MONITOR_IDLE_TIMEOUT, 180.0 ); if( randomize && BUGGIFY ) CONNECTION_MONITOR_IDLE_TIMEOUT = 5.0;
|
2019-06-29 04:43:22 +08:00
|
|
|
init( CONNECTION_MONITOR_INCOMING_IDLE_MULTIPLIER, 1.2 );
|
2019-07-09 10:13:53 +08:00
|
|
|
init( CONNECTION_MONITOR_UNREFERENCED_CLOSE_DELAY, 2.0 );
|
2017-05-26 04:48:44 +08:00
|
|
|
|
|
|
|
//FlowTransport
|
|
|
|
init( CONNECTION_REJECTED_MESSAGE_DELAY, 1.0 );
|
2017-09-19 02:04:51 +08:00
|
|
|
init( CONNECTION_ID_TIMEOUT, 600.0 ); if( randomize && BUGGIFY ) CONNECTION_ID_TIMEOUT = 60.0;
|
2017-05-26 04:48:44 +08:00
|
|
|
init( CONNECTION_CLEANUP_DELAY, 100.0 );
|
|
|
|
init( INITIAL_RECONNECTION_TIME, 0.05 );
|
|
|
|
init( MAX_RECONNECTION_TIME, 0.5 );
|
|
|
|
init( RECONNECTION_TIME_GROWTH_RATE, 1.2 );
|
|
|
|
init( RECONNECTION_RESET_TIME, 5.0 );
|
2020-08-31 09:49:49 +08:00
|
|
|
init( ALWAYS_ACCEPT_DELAY, 15.0 );
|
2020-03-06 10:17:49 +08:00
|
|
|
init( ACCEPT_BATCH_SIZE, 10 );
|
2019-04-05 05:11:12 +08:00
|
|
|
init( TOO_MANY_CONNECTIONS_CLOSED_RESET_DELAY, 5.0 );
|
|
|
|
init( TOO_MANY_CONNECTIONS_CLOSED_TIMEOUT, 20.0 );
|
2020-01-09 05:31:58 +08:00
|
|
|
init( PEER_UNAVAILABLE_FOR_LONG_TIME_TIMEOUT, 3600.0 );
|
2020-04-11 08:02:11 +08:00
|
|
|
init( INCOMPATIBLE_PEER_DELAY_BEFORE_LOGGING, 5.0 );
|
2020-10-12 14:05:21 +08:00
|
|
|
init( PING_LOGGING_INTERVAL, 3.0 );
|
2020-10-07 08:38:09 +08:00
|
|
|
init( PING_SAMPLE_AMOUNT, 100 );
|
2020-11-06 04:14:35 +08:00
|
|
|
init( NETWORK_CONNECT_SAMPLE_AMOUNT, 100 );
|
2018-08-11 08:47:21 +08:00
|
|
|
|
2018-07-27 08:21:23 +08:00
|
|
|
init( TLS_CERT_REFRESH_DELAY_SECONDS, 12*60*60 );
|
2020-01-13 14:12:18 +08:00
|
|
|
init( TLS_SERVER_CONNECTION_THROTTLE_TIMEOUT, 9.0 );
|
|
|
|
init( TLS_CLIENT_CONNECTION_THROTTLE_TIMEOUT, 11.0 );
|
2020-01-22 10:58:34 +08:00
|
|
|
init( TLS_SERVER_CONNECTION_THROTTLE_ATTEMPTS, 1 );
|
2020-07-28 01:58:30 +08:00
|
|
|
init( TLS_CLIENT_CONNECTION_THROTTLE_ATTEMPTS, 1 );
|
2020-06-29 08:29:13 +08:00
|
|
|
init( TLS_CLIENT_HANDSHAKE_THREADS, 0 );
|
2021-03-05 04:51:24 +08:00
|
|
|
init( TLS_SERVER_HANDSHAKE_THREADS, 64 );
|
2020-06-23 18:09:56 +08:00
|
|
|
init( TLS_HANDSHAKE_THREAD_STACKSIZE, 64 * 1024 );
|
2020-06-29 08:29:13 +08:00
|
|
|
init( TLS_MALLOC_ARENA_MAX, 6 );
|
2020-07-16 17:31:17 +08:00
|
|
|
init( TLS_HANDSHAKE_LIMIT, 1000 );
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2020-02-11 07:03:35 +08:00
|
|
|
init( NETWORK_TEST_CLIENT_COUNT, 30 );
|
2019-08-22 09:39:02 +08:00
|
|
|
init( NETWORK_TEST_REPLY_SIZE, 600e3 );
|
2020-02-11 07:03:35 +08:00
|
|
|
init( NETWORK_TEST_REQUEST_COUNT, 0 ); // 0 -> run forever
|
|
|
|
init( NETWORK_TEST_REQUEST_SIZE, 1 );
|
|
|
|
init( NETWORK_TEST_SCRIPT_MODE, false );
|
2019-08-22 09:37:50 +08:00
|
|
|
|
2017-05-26 04:48:44 +08:00
|
|
|
//AsyncFileCached
|
2019-07-24 06:05:21 +08:00
|
|
|
init( PAGE_CACHE_4K, 2LL<<30 );
|
2017-05-26 04:48:44 +08:00
|
|
|
init( PAGE_CACHE_64K, 200LL<<20 );
|
|
|
|
init( SIM_PAGE_CACHE_4K, 1e8 );
|
|
|
|
init( SIM_PAGE_CACHE_64K, 1e7 );
|
|
|
|
init( BUGGIFY_SIM_PAGE_CACHE_4K, 1e6 );
|
|
|
|
init( BUGGIFY_SIM_PAGE_CACHE_64K, 1e6 );
|
|
|
|
init( MAX_EVICT_ATTEMPTS, 100 ); if( randomize && BUGGIFY ) MAX_EVICT_ATTEMPTS = 2;
|
2019-05-03 20:04:43 +08:00
|
|
|
init( CACHE_EVICTION_POLICY, "random" );
|
2018-10-06 06:05:26 +08:00
|
|
|
init( PAGE_CACHE_TRUNCATE_LOOKUP_FRACTION, 0.1 ); if( randomize && BUGGIFY ) PAGE_CACHE_TRUNCATE_LOOKUP_FRACTION = 0.0; else if( randomize && BUGGIFY ) PAGE_CACHE_TRUNCATE_LOOKUP_FRACTION = 1.0;
|
2021-02-03 04:42:46 +08:00
|
|
|
init( FLOW_CACHEDFILE_WRITE_IO_SIZE, 0 );
|
2021-02-03 04:39:05 +08:00
|
|
|
if ( randomize && BUGGIFY) {
|
|
|
|
// Choose 16KB to 64KB as I/O size
|
|
|
|
FLOW_CACHEDFILE_WRITE_IO_SIZE = deterministicRandom()->randomInt(16384, 65537);
|
2021-01-24 17:50:09 +08:00
|
|
|
}
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2019-10-16 01:22:18 +08:00
|
|
|
//AsyncFileEIO
|
|
|
|
init( EIO_MAX_PARALLELISM, 4 );
|
2019-10-25 02:39:55 +08:00
|
|
|
init( EIO_USE_ODIRECT, 0 );
|
2019-10-16 01:22:18 +08:00
|
|
|
|
2017-05-26 04:48:44 +08:00
|
|
|
//AsyncFileKAIO
|
|
|
|
init( MAX_OUTSTANDING, 64 );
|
|
|
|
init( MIN_SUBMIT, 10 );
|
2017-06-16 17:14:19 +08:00
|
|
|
|
|
|
|
init( PAGE_WRITE_CHECKSUM_HISTORY, 0 ); if( randomize && BUGGIFY ) PAGE_WRITE_CHECKSUM_HISTORY = 10000000;
|
2019-03-13 05:04:18 +08:00
|
|
|
init( DISABLE_POSIX_KERNEL_AIO, 0 );
|
2017-05-26 04:48:44 +08:00
|
|
|
|
|
|
|
//AsyncFileNonDurable
|
2021-04-27 00:50:19 +08:00
|
|
|
init( NON_DURABLE_MAX_WRITE_DELAY, 2.0 ); if( randomize && BUGGIFY ) NON_DURABLE_MAX_WRITE_DELAY = 5.0;
|
2017-05-26 04:48:44 +08:00
|
|
|
init( MAX_PRIOR_MODIFICATION_DELAY, 1.0 ); if( randomize && BUGGIFY ) MAX_PRIOR_MODIFICATION_DELAY = 10.0;
|
|
|
|
|
|
|
|
//GenericActors
|
|
|
|
init( BUGGIFY_FLOW_LOCK_RELEASE_DELAY, 1.0 );
|
2020-02-20 08:48:30 +08:00
|
|
|
init( LOW_PRIORITY_DELAY_COUNT, 5 );
|
2021-01-28 03:50:42 +08:00
|
|
|
init( LOW_PRIORITY_MAX_DELAY, 5.0 );
|
2017-05-26 04:48:44 +08:00
|
|
|
|
|
|
|
//IAsyncFile
|
|
|
|
init( INCREMENTAL_DELETE_TRUNCATE_AMOUNT, 5e8 ); //500MB
|
|
|
|
init( INCREMENTAL_DELETE_INTERVAL, 1.0 ); //every 1 second
|
|
|
|
|
|
|
|
//Net2 and FlowTransport
|
|
|
|
init( MIN_COALESCE_DELAY, 10e-6 ); if( randomize && BUGGIFY ) MIN_COALESCE_DELAY = 0;
|
|
|
|
init( MAX_COALESCE_DELAY, 20e-6 ); if( randomize && BUGGIFY ) MAX_COALESCE_DELAY = 0;
|
|
|
|
init( SLOW_LOOP_CUTOFF, 15.0 / 1000.0 );
|
|
|
|
init( SLOW_LOOP_SAMPLING_RATE, 0.1 );
|
|
|
|
init( TSC_YIELD_TIME, 1000000 );
|
2020-02-08 06:34:24 +08:00
|
|
|
init( MIN_LOGGED_PRIORITY_BUSY_FRACTION, 0.05 );
|
2020-02-21 02:43:34 +08:00
|
|
|
init( CERT_FILE_MAX_SIZE, 5 * 1024 * 1024 );
|
2021-01-20 09:13:27 +08:00
|
|
|
init( READY_QUEUE_RESERVED_SIZE, 8192 );
|
2017-05-26 04:48:44 +08:00
|
|
|
|
|
|
|
//Network
|
|
|
|
init( PACKET_LIMIT, 100LL<<20 );
|
|
|
|
init( PACKET_WARNING, 2LL<<20 ); // 2MB packet warning quietly allows for 1MB system messages
|
|
|
|
init( TIME_OFFSET_LOGGING_INTERVAL, 60.0 );
|
2020-07-16 17:31:17 +08:00
|
|
|
init( MAX_PACKET_SEND_BYTES, 128 * 1024 );
|
2019-06-12 08:52:25 +08:00
|
|
|
init( MIN_PACKET_BUFFER_BYTES, 4 * 1024 );
|
2019-06-26 00:52:05 +08:00
|
|
|
init( MIN_PACKET_BUFFER_FREE_BYTES, 256 );
|
2019-08-24 02:07:46 +08:00
|
|
|
init( FLOW_TCP_NODELAY, 1 );
|
|
|
|
init( FLOW_TCP_QUICKACK, 0 );
|
2017-05-26 04:48:44 +08:00
|
|
|
|
|
|
|
//Sim2
|
|
|
|
init( MIN_OPEN_TIME, 0.0002 );
|
|
|
|
init( MAX_OPEN_TIME, 0.0012 );
|
|
|
|
init( SIM_DISK_IOPS, 5000 );
|
|
|
|
init( SIM_DISK_BANDWIDTH, 50000000 );
|
|
|
|
init( MIN_NETWORK_LATENCY, 100e-6 );
|
|
|
|
init( FAST_NETWORK_LATENCY, 800e-6 );
|
|
|
|
init( SLOW_NETWORK_LATENCY, 100e-3 );
|
2019-05-11 05:01:52 +08:00
|
|
|
init( MAX_CLOGGING_LATENCY, 0 ); if( randomize && BUGGIFY ) MAX_CLOGGING_LATENCY = 0.1 * deterministicRandom()->random01();
|
|
|
|
init( MAX_BUGGIFIED_DELAY, 0 ); if( randomize && BUGGIFY ) MAX_BUGGIFIED_DELAY = 0.2 * deterministicRandom()->random01();
|
2019-11-22 08:24:18 +08:00
|
|
|
init( SIM_CONNECT_ERROR_MODE, deterministicRandom()->randomInt(0,3) );
|
2021-06-09 00:57:37 +08:00
|
|
|
|
2017-05-26 04:48:44 +08:00
|
|
|
//Tracefiles
|
|
|
|
init( ZERO_LENGTH_FILE_PAD, 1 );
|
|
|
|
init( TRACE_FLUSH_INTERVAL, 0.25 );
|
|
|
|
init( TRACE_RETRY_OPEN_INTERVAL, 1.00 );
|
2019-11-05 08:10:08 +08:00
|
|
|
init( MIN_TRACE_SEVERITY, isSimulated ? 1 : 10 ); // Related to the trace severity in Trace.h
|
2017-05-26 04:48:44 +08:00
|
|
|
init( MAX_TRACE_SUPPRESSIONS, 1e4 );
|
2020-10-22 08:57:27 +08:00
|
|
|
init( TRACE_DATETIME_ENABLED, true ); // trace time in human readable format (always real time)
|
2018-06-01 04:27:35 +08:00
|
|
|
init( TRACE_SYNC_ENABLED, 0 );
|
2018-03-28 23:21:22 +08:00
|
|
|
init( TRACE_EVENT_METRIC_UNITS_PER_SAMPLE, 500 );
|
2018-06-27 05:37:21 +08:00
|
|
|
init( TRACE_EVENT_THROTTLER_SAMPLE_EXPIRY, 1800.0 ); // 30 mins
|
2018-03-28 23:21:22 +08:00
|
|
|
init( TRACE_EVENT_THROTTLER_MSG_LIMIT, 20000 );
|
2019-07-13 07:12:35 +08:00
|
|
|
init( MAX_TRACE_FIELD_LENGTH, 495 ); // If the value of this is changed, the corresponding default in Trace.cpp should be changed as well
|
|
|
|
init( MAX_TRACE_EVENT_LENGTH, 4000 ); // If the value of this is changed, the corresponding default in Trace.cpp should be changed as well
|
2020-03-17 04:59:31 +08:00
|
|
|
init( ALLOCATION_TRACING_ENABLED, true );
|
2017-05-26 04:48:44 +08:00
|
|
|
|
|
|
|
//TDMetrics
|
|
|
|
init( MAX_METRICS, 600 );
|
|
|
|
init( MAX_METRIC_SIZE, 2500 );
|
|
|
|
init( MAX_METRIC_LEVEL, 25 );
|
2018-07-02 02:30:37 +08:00
|
|
|
init( METRIC_LEVEL_DIVISOR, log(4) );
|
2017-05-26 04:48:44 +08:00
|
|
|
init( METRIC_LIMIT_START_QUEUE_SIZE, 10 ); // The queue size at which to start restricting logging by disabling levels
|
|
|
|
init( METRIC_LIMIT_RESPONSE_FACTOR, 10 ); // The additional queue size at which to disable logging of another level (higher == less restrictive)
|
|
|
|
|
|
|
|
//Load Balancing
|
2019-08-20 05:04:21 +08:00
|
|
|
init( LOAD_BALANCE_ZONE_ID_LOCALITY_ENABLED, 0 );
|
2019-07-17 03:46:02 +08:00
|
|
|
init( LOAD_BALANCE_DC_ID_LOCALITY_ENABLED, 1 );
|
2017-05-26 04:48:44 +08:00
|
|
|
init( LOAD_BALANCE_MAX_BACKOFF, 5.0 );
|
|
|
|
init( LOAD_BALANCE_START_BACKOFF, 0.01 );
|
|
|
|
init( LOAD_BALANCE_BACKOFF_RATE, 2.0 );
|
|
|
|
init( MAX_LAGGING_REQUESTS_OUTSTANDING, 100000 );
|
|
|
|
init( INSTANT_SECOND_REQUEST_MULTIPLIER, 2.0 );
|
|
|
|
init( BASE_SECOND_REQUEST_TIME, 0.0005 );
|
|
|
|
init( SECOND_REQUEST_MULTIPLIER_GROWTH, 0.01 );
|
|
|
|
init( SECOND_REQUEST_MULTIPLIER_DECAY, 0.00025 );
|
|
|
|
init( SECOND_REQUEST_BUDGET_GROWTH, 0.05 );
|
|
|
|
init( SECOND_REQUEST_MAX_BUDGET, 100.0 );
|
|
|
|
init( ALTERNATIVES_FAILURE_RESET_TIME, 5.0 );
|
|
|
|
init( ALTERNATIVES_FAILURE_MIN_DELAY, 0.05 );
|
2017-10-20 06:36:32 +08:00
|
|
|
init( ALTERNATIVES_FAILURE_DELAY_RATIO, 0.2 );
|
2019-08-10 03:35:19 +08:00
|
|
|
init( ALTERNATIVES_FAILURE_MAX_DELAY, 1.0 );
|
|
|
|
init( ALTERNATIVES_FAILURE_SLOW_DELAY_RATIO, 0.04 );
|
|
|
|
init( ALTERNATIVES_FAILURE_SLOW_MAX_DELAY, 30.0 );
|
2019-08-10 04:03:40 +08:00
|
|
|
init( ALTERNATIVES_FAILURE_SKIP_DELAY, 1.0 );
|
2017-10-20 06:36:32 +08:00
|
|
|
init( FUTURE_VERSION_INITIAL_BACKOFF, 1.0 );
|
|
|
|
init( FUTURE_VERSION_MAX_BACKOFF, 8.0 );
|
|
|
|
init( FUTURE_VERSION_BACKOFF_GROWTH, 2.0 );
|
2019-08-22 05:55:21 +08:00
|
|
|
init( LOAD_BALANCE_MAX_BAD_OPTIONS, 1 ); //should be the same as MAX_MACHINES_FALLING_BEHIND
|
2019-08-20 04:59:49 +08:00
|
|
|
init( LOAD_BALANCE_PENALTY_IS_BAD, true );
|
2020-08-13 08:17:21 +08:00
|
|
|
init( BASIC_LOAD_BALANCE_UPDATE_RATE, 10.0 ); //should be longer than the rate we log network metrics
|
|
|
|
init( BASIC_LOAD_BALANCE_MAX_CHANGE, 0.10 );
|
2020-01-08 17:59:01 +08:00
|
|
|
init( BASIC_LOAD_BALANCE_MAX_PROB, 2.0 );
|
2020-10-06 03:35:10 +08:00
|
|
|
init( BASIC_LOAD_BALANCE_MIN_REQUESTS, 20 ); //do not adjust LB probabilities if the proxies are less than releasing less than 20 transactions per second
|
|
|
|
init( BASIC_LOAD_BALANCE_MIN_CPU, 0.05 ); //do not adjust LB probabilities if the proxies are less than 5% utilized
|
|
|
|
init( BASIC_LOAD_BALANCE_BUCKETS, 40 ); //proxies bin recent GRV requests into 40 time bins
|
|
|
|
init( BASIC_LOAD_BALANCE_COMPUTE_PRECISION, 10000 ); //determines how much of the LB usage is holding the CPU usage of the proxy
|
2021-05-13 02:53:20 +08:00
|
|
|
init( LOAD_BALANCE_TSS_TIMEOUT, 5.0 );
|
2020-03-20 14:21:41 +08:00
|
|
|
|
|
|
|
// Health Monitor
|
2020-04-09 10:34:40 +08:00
|
|
|
init( FAILURE_DETECTION_DELAY, 4.0 ); if( randomize && BUGGIFY ) FAILURE_DETECTION_DELAY = 1.0;
|
2020-03-27 13:50:39 +08:00
|
|
|
init( HEALTH_MONITOR_MARK_FAILED_UNSTABLE_CONNECTIONS, true );
|
2020-03-20 14:21:41 +08:00
|
|
|
init( HEALTH_MONITOR_CLIENT_REQUEST_INTERVAL_SECS, 30 );
|
2020-03-27 13:50:39 +08:00
|
|
|
init( HEALTH_MONITOR_CONNECTION_MAX_CLOSED, 5 );
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
2019-11-05 08:10:08 +08:00
|
|
|
// clang-format on
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
static std::string toLower(std::string const& name) {
|
2019-07-31 09:21:24 +08:00
|
|
|
std::string lower_name;
|
2021-03-11 02:06:03 +08:00
|
|
|
for (auto c = name.begin(); c != name.end(); ++c)
|
2019-07-31 09:21:24 +08:00
|
|
|
if (*c >= 'A' && *c <= 'Z')
|
|
|
|
lower_name += *c - 'A' + 'a';
|
|
|
|
else
|
|
|
|
lower_name += *c;
|
|
|
|
return lower_name;
|
|
|
|
}
|
|
|
|
|
2021-06-07 15:29:36 +08:00
|
|
|
template <class T>
|
|
|
|
static T parseIntegral(std::string const& value) {
|
|
|
|
T v;
|
2021-06-03 01:04:46 +08:00
|
|
|
int n = 0;
|
|
|
|
if (StringRef(value).startsWith(LiteralStringRef("0x"))) {
|
|
|
|
if (sscanf(value.c_str(), "0x%" SCNx64 "%n", &v, &n) != 1 || n != value.size())
|
|
|
|
throw invalid_option_value();
|
|
|
|
} else {
|
|
|
|
if (sscanf(value.c_str(), "%" SCNd64 "%n", &v, &n) != 1 || n != value.size())
|
|
|
|
throw invalid_option_value();
|
|
|
|
}
|
|
|
|
return v;
|
|
|
|
}
|
|
|
|
|
|
|
|
ParsedKnobValue Knobs::parseKnobValue(std::string const& knob, std::string const& value) const {
|
2017-05-26 04:48:44 +08:00
|
|
|
if (double_knobs.count(knob)) {
|
|
|
|
double v;
|
2021-03-11 02:06:03 +08:00
|
|
|
int n = 0;
|
2017-05-26 04:48:44 +08:00
|
|
|
if (sscanf(value.c_str(), "%lf%n", &v, &n) != 1 || n != value.size())
|
|
|
|
throw invalid_option_value();
|
2021-06-03 01:04:46 +08:00
|
|
|
return v;
|
|
|
|
} else if (bool_knobs.count(knob)) {
|
2021-03-11 02:06:03 +08:00
|
|
|
if (toLower(value) == "true") {
|
2021-06-03 01:04:46 +08:00
|
|
|
return true;
|
2021-03-11 02:06:03 +08:00
|
|
|
} else if (toLower(value) == "false") {
|
2021-06-03 01:04:46 +08:00
|
|
|
return false;
|
2019-07-31 09:21:24 +08:00
|
|
|
} else {
|
2021-06-07 15:29:36 +08:00
|
|
|
return parseIntegral<bool>(value);
|
2019-07-31 09:21:24 +08:00
|
|
|
}
|
2021-06-03 01:04:46 +08:00
|
|
|
} else if (int64_knobs.count(knob)) {
|
2021-06-07 15:29:36 +08:00
|
|
|
return parseIntegral<int64_t>(value);
|
2021-06-03 01:04:46 +08:00
|
|
|
} else if (int_knobs.count(knob)) {
|
2021-06-07 15:29:36 +08:00
|
|
|
return parseIntegral<int>(value);
|
2021-06-03 01:04:46 +08:00
|
|
|
} else if (string_knobs.count(knob)) {
|
|
|
|
return value;
|
2019-07-31 09:21:24 +08:00
|
|
|
}
|
2021-06-03 01:04:46 +08:00
|
|
|
return NoKnobFound{};
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Knobs::setKnob(std::string const& knob, int value) {
|
|
|
|
if (!int_knobs.count(knob)) {
|
|
|
|
return false;
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
2021-06-03 01:04:46 +08:00
|
|
|
*int_knobs[knob] = value;
|
|
|
|
explicitlySetKnobs.insert(toLower(knob));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Knobs::setKnob(std::string const& knob, int64_t value) {
|
|
|
|
if (!int64_knobs.count(knob)) {
|
|
|
|
return false;
|
2017-10-13 08:49:41 +08:00
|
|
|
}
|
2021-06-03 01:04:46 +08:00
|
|
|
*int64_knobs[knob] = value;
|
|
|
|
explicitlySetKnobs.insert(toLower(knob));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Knobs::setKnob(std::string const& knob, bool value) {
|
|
|
|
if (!bool_knobs.count(knob)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
*bool_knobs[knob] = value;
|
|
|
|
explicitlySetKnobs.insert(toLower(knob));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Knobs::setKnob(std::string const& knob, double value) {
|
|
|
|
if (!double_knobs.count(knob)) {
|
|
|
|
return false;
|
2017-10-13 08:49:41 +08:00
|
|
|
}
|
2021-06-03 01:04:46 +08:00
|
|
|
*double_knobs[knob] = value;
|
|
|
|
explicitlySetKnobs.insert(toLower(knob));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Knobs::setKnob(std::string const& knob, std::string const& value) {
|
|
|
|
if (!string_knobs.count(knob)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
*string_knobs[knob] = value;
|
|
|
|
explicitlySetKnobs.insert(toLower(knob));
|
|
|
|
return true;
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
void Knobs::initKnob(double& knob, double value, std::string const& name) {
|
2020-04-02 04:59:06 +08:00
|
|
|
if (!explicitlySetKnobs.count(toLower(name))) {
|
|
|
|
knob = value;
|
|
|
|
double_knobs[toLower(name)] = &knob;
|
|
|
|
}
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
void Knobs::initKnob(int64_t& knob, int64_t value, std::string const& name) {
|
2020-04-02 04:59:06 +08:00
|
|
|
if (!explicitlySetKnobs.count(toLower(name))) {
|
|
|
|
knob = value;
|
|
|
|
int64_knobs[toLower(name)] = &knob;
|
|
|
|
}
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
void Knobs::initKnob(int& knob, int value, std::string const& name) {
|
2020-04-02 04:59:06 +08:00
|
|
|
if (!explicitlySetKnobs.count(toLower(name))) {
|
|
|
|
knob = value;
|
|
|
|
int_knobs[toLower(name)] = &knob;
|
|
|
|
}
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
void Knobs::initKnob(std::string& knob, const std::string& value, const std::string& name) {
|
2020-04-02 04:59:06 +08:00
|
|
|
if (!explicitlySetKnobs.count(toLower(name))) {
|
|
|
|
knob = value;
|
|
|
|
string_knobs[toLower(name)] = &knob;
|
|
|
|
}
|
2017-10-13 08:49:41 +08:00
|
|
|
}
|
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
void Knobs::initKnob(bool& knob, bool value, std::string const& name) {
|
2020-04-02 04:59:06 +08:00
|
|
|
if (!explicitlySetKnobs.count(toLower(name))) {
|
|
|
|
knob = value;
|
|
|
|
bool_knobs[toLower(name)] = &knob;
|
|
|
|
}
|
2019-07-31 09:21:24 +08:00
|
|
|
}
|
|
|
|
|
2020-11-22 04:55:03 +08:00
|
|
|
void Knobs::trace() const {
|
2021-03-11 02:06:03 +08:00
|
|
|
for (auto& k : double_knobs)
|
2018-06-09 02:11:08 +08:00
|
|
|
TraceEvent("Knob").detail("Name", k.first.c_str()).detail("Value", *k.second);
|
2021-03-11 02:06:03 +08:00
|
|
|
for (auto& k : int_knobs)
|
2018-06-09 02:11:08 +08:00
|
|
|
TraceEvent("Knob").detail("Name", k.first.c_str()).detail("Value", *k.second);
|
2021-03-11 02:06:03 +08:00
|
|
|
for (auto& k : int64_knobs)
|
2018-06-09 02:11:08 +08:00
|
|
|
TraceEvent("Knob").detail("Name", k.first.c_str()).detail("Value", *k.second);
|
2021-03-11 02:06:03 +08:00
|
|
|
for (auto& k : string_knobs)
|
2018-06-09 02:11:08 +08:00
|
|
|
TraceEvent("Knob").detail("Name", k.first.c_str()).detail("Value", *k.second);
|
2021-03-11 02:06:03 +08:00
|
|
|
for (auto& k : bool_knobs)
|
2019-07-31 09:21:24 +08:00
|
|
|
TraceEvent("Knob").detail("Name", k.first.c_str()).detail("Value", *k.second);
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|