diff --git a/docker/test/performance-comparison/compare.sh b/docker/test/performance-comparison/compare.sh index 8f4defb2c6d..0a205796c9d 100755 --- a/docker/test/performance-comparison/compare.sh +++ b/docker/test/performance-comparison/compare.sh @@ -131,6 +131,11 @@ function run_tests test_files=$(ls "$test_prefix"/*.xml) fi + # Determine which concurrent benchmarks to run. For now, the only test + # we run as a concurrent benchmark is 'website'. Run it as benchmark if we + # are also going to run it as a normal test. + for test in $test_files; do echo $test; done | sed -n '/website/p' > benchmarks-to-run.txt + # Delete old report files. for x in {test-times,wall-clock-times}.tsv do @@ -169,12 +174,20 @@ function run_benchmark rm -rf benchmark ||: mkdir benchmark ||: - # TODO disable this when there is an explicit list of tests to run - "$script_dir/perf.py" --print right/performance/website.xml > benchmark/website-queries.tsv - # TODO things to fix in clickhouse-benchmark: - # - --max_memory_usage setting does nothing - clickhouse-benchmark --port 9001 --concurrency 6 --cumulative --iterations 1000 --randomize 1 --delay 0 --json benchmark/website-left.json --continue_on_errors -- --max_memory_usage 30000000000 < benchmark/website-queries.tsv - clickhouse-benchmark --port 9002 --concurrency 6 --cumulative --iterations 1000 --randomize 1 --delay 0 --json benchmark/website-right.json --continue_on_errors -- --max_memory_usage 30000000000 < benchmark/website-queries.tsv + # The list is built by run_tests. + for file in $(cat benchmarks-to-run.txt) + do + name=$(basename "$file" ".xml") + + "$script_dir/perf.py" --print-queries "$file" > "benchmark/$name-queries.txt" + "$script_dir/perf.py" --print-settings "$file" > "benchmark/$name-settings.txt" + + readarray -t settings < "benchmark/$name-settings.txt" + command=(clickhouse-benchmark --concurrency 6 --cumulative --iterations 1000 --randomize 1 --delay 0 --continue_on_errors "${settings[@]}") + + "${command[@]}" --port 9001 --json "benchmark/$name-left.json" < "benchmark/$name-queries.txt" + "${command[@]}" --port 9002 --json "benchmark/$name-right.json" < "benchmark/$name-queries.txt" + done } function get_profiles_watchdog diff --git a/docker/test/performance-comparison/config/users.d/perf-comparison-tweaks-users.xml b/docker/test/performance-comparison/config/users.d/perf-comparison-tweaks-users.xml index 1bde2a1388b..6e3e3df5d39 100644 --- a/docker/test/performance-comparison/config/users.d/perf-comparison-tweaks-users.xml +++ b/docker/test/performance-comparison/config/users.d/perf-comparison-tweaks-users.xml @@ -6,8 +6,6 @@ 1 1 1 - - 30000000000 diff --git a/docker/test/performance-comparison/perf.py b/docker/test/performance-comparison/perf.py index 74d0300b074..f81673bd8a1 100755 --- a/docker/test/performance-comparison/perf.py +++ b/docker/test/performance-comparison/perf.py @@ -21,7 +21,8 @@ parser.add_argument('--host', nargs='*', default=['localhost'], help="Server hos parser.add_argument('--port', nargs='*', default=[9000], help="Server port(s). Corresponds to '--host' options.") parser.add_argument('--runs', type=int, default=int(os.environ.get('CHPC_RUNS', 17)), help='Number of query runs per server. Defaults to CHPC_RUNS environment variable.') parser.add_argument('--long', action='store_true', help='Do not skip the tests tagged as long.') -parser.add_argument('--print', action='store_true', help='Print test queries and exit.') +parser.add_argument('--print-queries', action='store_true', help='Print test queries and exit.') +parser.add_argument('--print-settings', action='store_true', help='Print test settings and exit.') args = parser.parse_args() test_name = os.path.splitext(os.path.basename(args.file[0].name))[0] @@ -52,11 +53,20 @@ test_query_templates = [q.text for q in root.findall('query')] test_queries = substitute_parameters(test_query_templates) # If we're only asked to print the queries, do that and exit -if args.print: +if args.print_queries: for q in test_queries: print(q) exit(0) +# If we're only asked to print the settings, do that and exit. These are settings +# for clickhouse-benchmark, so we print them as command line arguments, e.g. +# '--max_memory_usage=10000000'. +if args.print_settings: + for s in root.findall('settings/*'): + print(f'--{s.tag}={s.text}') + + exit(0) + # Skip long tests if not args.long: for tag in root.findall('.//tag'): diff --git a/programs/server/Server.cpp b/programs/server/Server.cpp index 25d8e5595b7..424c0f3ccf7 100644 --- a/programs/server/Server.cpp +++ b/programs/server/Server.cpp @@ -645,12 +645,22 @@ int Server::main(const std::vector & /*args*/) if (max_server_memory_usage == 0) { max_server_memory_usage = default_max_server_memory_usage; - LOG_INFO(log, "Setting max_server_memory_usage was set to {}", formatReadableSizeWithBinarySuffix(max_server_memory_usage)); + LOG_INFO(log, "Setting max_server_memory_usage was set to {}" + " ({} available * {:.2f} max_server_memory_usage_to_ram_ratio)", + formatReadableSizeWithBinarySuffix(max_server_memory_usage), + formatReadableSizeWithBinarySuffix(memory_amount), + max_server_memory_usage_to_ram_ratio); } else if (max_server_memory_usage > default_max_server_memory_usage) { max_server_memory_usage = default_max_server_memory_usage; - LOG_INFO(log, "Setting max_server_memory_usage was lowered to {} because the system has low amount of memory", formatReadableSizeWithBinarySuffix(max_server_memory_usage)); + LOG_INFO(log, "Setting max_server_memory_usage was lowered to {}" + " because the system has low amount of memory. The amount was" + " calculated as {} available" + " * {:.2f} max_server_memory_usage_to_ram_ratio", + formatReadableSizeWithBinarySuffix(max_server_memory_usage), + formatReadableSizeWithBinarySuffix(memory_amount), + max_server_memory_usage_to_ram_ratio); } total_memory_tracker.setOrRaiseHardLimit(max_server_memory_usage); diff --git a/src/Core/SettingsCollection.h b/src/Core/SettingsCollection.h index 71a308fb37e..10c64c615ff 100644 --- a/src/Core/SettingsCollection.h +++ b/src/Core/SettingsCollection.h @@ -549,6 +549,9 @@ public: /// Gathers all changed values (e.g. for applying them later to another collection of settings). SettingsChanges changes() const; + // A debugging aid. + std::string dumpChangesToString() const; + /// Applies change to concrete setting. void applyChange(const SettingChange & change); diff --git a/src/Core/SettingsCollectionImpl.h b/src/Core/SettingsCollectionImpl.h index 877567a7caf..f0854f11b8a 100644 --- a/src/Core/SettingsCollectionImpl.h +++ b/src/Core/SettingsCollectionImpl.h @@ -219,6 +219,19 @@ SettingsChanges SettingsCollection::changes() const } +template +std::string SettingsCollection::dumpChangesToString() const +{ + std::stringstream ss; + for (const auto & c : changes()) + { + ss << c.name << " = " + << applyVisitor(FieldVisitorToString(), c.value) << "\n"; + } + return ss.str(); +} + + template void SettingsCollection::applyChange(const SettingChange & change) {