Adjust optimistic scheduler config

This commit is contained in:
Piotr Wójcik 2025-09-01 23:54:09 +02:00
commit c71f14fc00
3 changed files with 8 additions and 7 deletions

View file

@ -132,7 +132,6 @@ public:
telemetry_cache_cutoff = 2000ms;
telemetry_request_interval = 500ms;
telemetry_broadcast_interval = 500ms;
optimistic_activation_delay = 2s;
rep_crawler_normal_interval = 500ms;
rep_crawler_warmup_interval = 500ms;
}
@ -183,9 +182,6 @@ public:
/** Telemetry data older than this value is considered stale */
std::chrono::milliseconds telemetry_cache_cutoff{ 1000 * 130 }; // 2 * `telemetry_broadcast_interval` + some margin
/** How much to delay activation of optimistic elections to avoid interfering with election scheduler */
std::chrono::seconds optimistic_activation_delay{ 30 };
std::chrono::milliseconds rep_crawler_normal_interval{ 1000 * 7 };
std::chrono::milliseconds rep_crawler_warmup_interval{ 1000 * 3 };

View file

@ -126,7 +126,7 @@ bool nano::scheduler::optimistic::predicate () const
auto candidate = candidates.get<tag_unconfirmed_height> ().begin ();
debug_assert (candidate != candidates.get<tag_unconfirmed_height> ().end ());
return elapsed (candidate->timestamp, network_constants.optimistic_activation_delay);
return elapsed (candidate->timestamp, config.activation_delay);
}
void nano::scheduler::optimistic::run ()
@ -136,7 +136,7 @@ void nano::scheduler::optimistic::run ()
{
stats.inc (nano::stat::type::optimistic_scheduler, nano::stat::detail::loop);
condition.wait_for (lock, network_constants.optimistic_activation_delay / 2, [this] () {
condition.wait_for (lock, config.activation_delay / 2, [this] () {
return stopped || predicate ();
});
@ -204,6 +204,7 @@ nano::error nano::scheduler::optimistic_config::deserialize (nano::tomlconfig &
toml.get ("enable", enable);
toml.get ("gap_threshold", gap_threshold);
toml.get ("max_size", max_size);
toml.get_duration ("activation_delay", activation_delay);
return toml.get_error ();
}
@ -213,6 +214,7 @@ nano::error nano::scheduler::optimistic_config::serialize (nano::tomlconfig & to
toml.put ("enable", enable, "Enable or disable optimistic elections\ntype:bool");
toml.put ("gap_threshold", gap_threshold, "Minimum difference between confirmation frontier and account frontier to become a candidate for optimistic confirmation\ntype:uint64");
toml.put ("max_size", max_size, "Maximum number of candidates stored in memory\ntype:uint64");
toml.put ("activation_delay", activation_delay.count (), "How much to delay activation of optimistic elections to avoid interfering with election scheduler\ntype:milliseconds");
return toml.get_error ();
}

View file

@ -33,10 +33,13 @@ public:
bool enable{ true };
/** Minimum difference between confirmation frontier and account frontier to become a candidate for optimistic confirmation */
uint64_t gap_threshold{ 32 };
uint64_t gap_threshold{ 16 };
/** Maximum number of candidates stored in memory */
std::size_t max_size{ 1024 * 4 };
/** How much to delay activation of optimistic elections to avoid interfering with election scheduler */
std::chrono::milliseconds activation_delay{ 1s };
};
class optimistic final