Attempt for improvement [#METR-21840].

This commit is contained in:
Alexey Milovidov 2016-11-01 22:20:24 +03:00
parent 751f3913ee
commit aaec9d1db6
2 changed files with 12 additions and 25 deletions

View File

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

View File

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