From 6d3dbcb129b67152c89bbbe2a7dad98b071bf838 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 1 Dec 2026 13:19:32 +0000 Subject: Two options for a node on a machine that should idle --libp2p-ping-interval: how often libp2p pings each open connection, 15 s unless given, 0 for once as it opens. The pings keep no connection open and close none; continuum takes each connection's round trip from them, to keep the fastest of several to one peer. --worker-threads: how many threads take the node's work in turns, as many as the machine has cores unless given. The runtime is built from the configuration, so the count is set as the node starts. Each wakes the node's threads less often; docs/operations.md, An idle node, says what to choose, and what was measured. --- src/config/mod.rs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src/config/mod.rs') diff --git a/src/config/mod.rs b/src/config/mod.rs index 1b9a439..6f9bd98 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -503,6 +503,13 @@ pub(crate) const OPTIONS: &[OptionSpec] = &[ None, "Longest wait between HELLOs to a member that doesn't answer (dormant, or unanswered HELLOs): they start at 10 keepalives and double up to this. It bounds how long a returning member, or the other side of a partition, takes to be noticed. Default: 60 keepalives (1h at 1m). Shorter than 10 keepalives, it is every wait.", ), + option( + "worker-threads", + Kind::Integer, + "COUNT", + None, + "How many threads take the node's work in turns (at least 1): as many as the machine has cores unless given. What takes long (reading and saving the document, judging a store's events, a remake's snapshot) runs on threads of its own beside them, started as needed. Fewer wake less often on a node that is idle most of the time; set as the node starts, and changed only by a restart (docs/operations.md, Worker threads).", + ), option( "neighbours", Kind::Integer, @@ -636,6 +643,13 @@ pub(crate) const OPTIONS: &[OptionSpec] = &[ Some("false"), "With the libp2p transport: find nodes on the LAN (multicast DNS, IPv4). Those that speak continuum are seeds while joining, so nodes on one LAN find each other without configured seeds; a swarm key keeps a new node from joining another swarm on the same LAN.", ), + option( + "libp2p-ping-interval", + Kind::Duration, + "DURATION", + Some("15s"), + "With the libp2p transport: how often each open connection is pinged, for its round trip: of several connections to one peer the fastest is kept, by the shortest round trip each measured. Every connection is pinged once as it opens, whatever this says; 0 leaves it at that. The pings keep no connection open and close none: continuum's own keepalives tell whether a peer answers. A longer interval, or none, spares a node that is idle most of the time the wakeups (docs/transports.md, Pings).", + ), option( "libp2p-upnp", Kind::Flag, @@ -961,6 +975,8 @@ pub(crate) struct Settings { serialize_with = "crate::units::serialize_optional_duration" )] pub(crate) dormant_probe_max: Option, + #[serde(default)] + pub(crate) worker_threads: Option, #[serde(default = "default_neighbours")] pub(crate) neighbours: usize, #[serde( @@ -1012,6 +1028,12 @@ pub(crate) struct Settings { #[serde(default)] #[cfg_attr(not(feature = "libp2p"), allow(dead_code))] pub(crate) libp2p_upnp: bool, + #[serde( + default = "default_libp2p_ping_interval", + with = "crate::units::duration_option" + )] + #[cfg_attr(not(feature = "libp2p"), allow(dead_code))] + pub(crate) libp2p_ping_interval: Duration, #[serde(default)] #[cfg_attr(not(feature = "libp2p"), allow(dead_code))] pub(crate) libp2p_ignore: Vec, @@ -1099,6 +1121,9 @@ fn default_keepalive() -> Duration { fn default_stream_heartbeat() -> Duration { Duration::from_secs(30) } +fn default_libp2p_ping_interval() -> Duration { + Duration::from_secs(15) +} fn default_neighbours() -> usize { 12 } @@ -1284,6 +1309,9 @@ impl Settings { if self.debug_epoch.is_some() && !self.debug_api { bail!("debug-epoch needs debug-api"); } + if self.worker_threads == Some(0) { + bail!("worker-threads must be at least 1"); + } if self.neighbours < 2 { bail!("neighbours must be at least 2"); } -- cgit v1.3.1