mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-26 17:41:59 +00:00
Attempt for improvement [#METR-21840].
This commit is contained in:
parent
751f3913ee
commit
aaec9d1db6
@ -17,15 +17,9 @@ public:
|
||||
* This behaviour balances merge-tree workload.
|
||||
* It called 'base', because merge-tree depth could be estimated as logarithm with that base.
|
||||
*/
|
||||
double base = 8;
|
||||
|
||||
/** Lower base by 1 after that time.
|
||||
* It will be lowered by 2 after that time * 2^1,
|
||||
* It will be lowered by 3 after that time * 2^2,
|
||||
* and so on, exponentially.
|
||||
*/
|
||||
time_t lower_base_after = 30;
|
||||
double base = 2;
|
||||
|
||||
time_t lower_base_after_seconds = 300;
|
||||
size_t lower_base_after_num_parts = 20;
|
||||
|
||||
/// Zero means unlimited.
|
||||
|
@ -74,6 +74,7 @@ struct Estimator
|
||||
void selectWithinPartition(
|
||||
const SimpleMergeSelector::PartsInPartition & parts,
|
||||
const size_t max_total_size_to_merge,
|
||||
const time_t current_min_part_age,
|
||||
Estimator & estimator,
|
||||
const SimpleMergeSelector::Settings & settings)
|
||||
{
|
||||
@ -115,7 +116,8 @@ void selectWithinPartition(
|
||||
|
||||
double actual_base = settings.base;
|
||||
|
||||
if (parts.size() > settings.lower_base_after_num_parts)
|
||||
if (parts.size() > settings.lower_base_after_num_parts
|
||||
|| current_min_part_age > settings.lower_base_after_seconds)
|
||||
actual_base = 1;
|
||||
|
||||
{
|
||||
@ -129,21 +131,6 @@ void selectWithinPartition(
|
||||
max_size = it->size;
|
||||
}
|
||||
|
||||
if (actual_base > 1)
|
||||
{
|
||||
time_t min_age = -1;
|
||||
for (auto it = local_estimator.best_begin; it != local_estimator.best_end; ++it)
|
||||
if (min_age == -1 || it->age < min_age)
|
||||
min_age = it->age;
|
||||
|
||||
if (min_age > settings.lower_base_after)
|
||||
{
|
||||
actual_base -= log2(min_age - settings.lower_base_after);
|
||||
if (actual_base < 1)
|
||||
actual_base = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (static_cast<double>(sum_size) / max_size >= actual_base)
|
||||
estimator.consider(local_estimator.best_begin, local_estimator.best_end, sum_size, 0, 0);
|
||||
}
|
||||
@ -156,10 +143,16 @@ SimpleMergeSelector::PartsInPartition SimpleMergeSelector::select(
|
||||
const Partitions & partitions,
|
||||
const size_t max_total_size_to_merge)
|
||||
{
|
||||
time_t min_age = -1;
|
||||
for (const auto & partition : partitions)
|
||||
for (const auto & part : partition)
|
||||
if (min_age == -1 || part.age < min_age)
|
||||
min_age = part.age;
|
||||
|
||||
Estimator estimator;
|
||||
|
||||
for (const auto & partition : partitions)
|
||||
selectWithinPartition(partition, max_total_size_to_merge, estimator, settings);
|
||||
selectWithinPartition(partition, max_total_size_to_merge, min_age, estimator, settings);
|
||||
|
||||
return estimator.getBest();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user