memory usage settings

This commit is contained in:
Alexander Kuzmenkov 2020-06-23 15:30:45 +03:00
parent eac6eb8c5a
commit ab809f59b9
6 changed files with 59 additions and 12 deletions

View File

@ -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

View File

@ -6,8 +6,6 @@
<allow_introspection_functions>1</allow_introspection_functions>
<log_queries>1</log_queries>
<metrics_perf_events_enabled>1</metrics_perf_events_enabled>
<!--FIXME support this setting in clickhouse-benchmark (see compare.sh, run-benchmark function)-->
<max_memory_usage>30000000000</max_memory_usage>
</default>
</profiles>
</yandex>

View File

@ -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'):

View File

@ -645,12 +645,22 @@ int Server::main(const std::vector<std::string> & /*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);

View File

@ -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);

View File

@ -219,6 +219,19 @@ SettingsChanges SettingsCollection<Derived>::changes() const
}
template <class Derived>
std::string SettingsCollection<Derived>::dumpChangesToString() const
{
std::stringstream ss;
for (const auto & c : changes())
{
ss << c.name << " = "
<< applyVisitor(FieldVisitorToString(), c.value) << "\n";
}
return ss.str();
}
template <class Derived>
void SettingsCollection<Derived>::applyChange(const SettingChange & change)
{