Commit 10c37f15 authored by Seb Mondet's avatar Seb Mondet Committed by Raphaël Proust

Make 2-min sleep configurable (`P2p_maintenance`)

parent 35727d4a
......@@ -76,6 +76,7 @@ let default_p2p_limits : P2p.limits = {
connection_timeout = 10. ;
authentication_timeout = 5. ;
greylist_timeout = 86400 ; (* one day *)
maintenance_idle_time = 120. ; (* two minutes *)
min_connections = 10 ;
expected_connections = 50 ;
max_connections = 100 ;
......@@ -133,6 +134,7 @@ let limit : P2p.limits Data_encoding.t =
let open Data_encoding in
conv
(fun { P2p.connection_timeout ; authentication_timeout ; greylist_timeout ;
maintenance_idle_time ;
min_connections ; expected_connections ; max_connections ;
backlog ; max_incoming_connections ;
max_download_speed ; max_upload_speed ;
......@@ -152,7 +154,7 @@ let limit : P2p.limits Data_encoding.t =
incoming_message_queue_size, outgoing_message_queue_size,
known_points_history_size, known_peer_ids_history_size,
max_known_points)),
( max_known_peer_ids, greylist_timeout))))
( max_known_peer_ids, greylist_timeout, maintenance_idle_time))))
(fun (((( connection_timeout, authentication_timeout,
min_connections, expected_connections,
max_connections, backlog, max_incoming_connections,
......@@ -162,8 +164,9 @@ let limit : P2p.limits Data_encoding.t =
incoming_message_queue_size, outgoing_message_queue_size,
known_points_history_size, known_peer_ids_history_size,
max_known_points)),
( max_known_peer_ids, greylist_timeout))) ->
( max_known_peer_ids, greylist_timeout, maintenance_idle_time))) ->
{ connection_timeout ; authentication_timeout ; greylist_timeout ;
maintenance_idle_time ;
min_connections ; expected_connections ;
max_connections ; backlog ; max_incoming_connections ;
max_download_speed ; max_upload_speed ;
......@@ -234,13 +237,17 @@ let limit : P2p.limits Data_encoding.t =
default_p2p_limits.known_points_history_size)
(opt "max_known_points" (tup2 uint16 uint16))
))
(obj2
(obj3
(opt "max_known_peer_ids" (tup2 uint16 uint16))
(dft "greylist-timeout"
~description: "GC delay for the greylists tables, in seconds."
int31 default_p2p_limits.greylist_timeout)
))
(dft "maintenance-idle-time"
~description: "How long to wait at most, in seconds, \
before running a maintenance loop."
float default_p2p_limits.maintenance_idle_time)
)
)
let p2p =
let open Data_encoding in
......
......@@ -72,6 +72,7 @@ type limits = {
connection_timeout : float ;
authentication_timeout : float ;
greylist_timeout : int ;
maintenance_idle_time: float ;
min_connections : int ;
expected_connections : int ;
......@@ -127,6 +128,7 @@ let create_connection_pool config limits meta_cfg conn_meta_cfg msg_cfg io_sched
connection_timeout = limits.connection_timeout ;
authentication_timeout = limits.authentication_timeout ;
greylist_timeout = limits.greylist_timeout ;
maintenance_idle_time = limits.maintenance_idle_time ;
incoming_app_message_queue_size = limits.incoming_app_message_queue_size ;
incoming_message_queue_size = limits.incoming_message_queue_size ;
outgoing_message_queue_size = limits.outgoing_message_queue_size ;
......
......@@ -116,6 +116,9 @@ type limits = {
greylist_timeout : int ;
(** GC delay for the grelists tables, in seconds. *)
maintenance_idle_time: float ;
(** How long to wait at most, in seconds, before running a maintenance loop. *)
min_connections : int ;
(** Strict minimum number of connections (triggers an urgent maintenance) *)
......
......@@ -190,10 +190,11 @@ and too_many_connections st n_connected =
let rec worker_loop st =
let Pool pool = st.pool in
let config = P2p_pool.config pool in
begin
protect ~canceler:st.canceler begin fun () ->
Lwt.pick [
Lwt_unix.sleep 120. ; (* every two minutes *)
Lwt_unix.sleep config.P2p_pool.maintenance_idle_time ; (* default: every two minutes *)
Lwt_condition.wait st.please_maintain ; (* when asked *)
P2p_pool.Pool_event.wait_too_few_connections pool ; (* limits *)
P2p_pool.Pool_event.wait_too_many_connections pool ;
......
......@@ -201,6 +201,7 @@ type config = {
connection_timeout : float ;
authentication_timeout : float ;
greylist_timeout : int ;
maintenance_idle_time: float ;
incoming_app_message_queue_size : int option ;
incoming_message_queue_size : int option ;
......
......@@ -106,6 +106,9 @@ type config = {
greylist_timeout : int ;
(** GC delay for the grelists tables, in seconds. *)
maintenance_idle_time: float ;
(** How long to wait at most, in seconds, before running a maintenance loop. *)
incoming_app_message_queue_size : int option ;
(** Size of the message queue for user messages (messages returned
by this module's [read] function. *)
......
......@@ -95,6 +95,7 @@ let detach_node f points n =
connection_timeout = 10. ;
authentication_timeout = 2. ;
greylist_timeout = 2 ;
maintenance_idle_time = 120. ;
incoming_app_message_queue_size = None ;
incoming_message_queue_size = None ;
outgoing_message_queue_size = None ;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment