diff options
Diffstat (limited to 'packages/meshbay-node/src/meshbay_node/config.py')
| -rw-r--r-- | packages/meshbay-node/src/meshbay_node/config.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/packages/meshbay-node/src/meshbay_node/config.py b/packages/meshbay-node/src/meshbay_node/config.py index eb694ae..c5596f1 100644 --- a/packages/meshbay-node/src/meshbay_node/config.py +++ b/packages/meshbay-node/src/meshbay_node/config.py @@ -74,6 +74,14 @@ max_concurrent_uploads = 8 # the partial file is deleted. max_upload_gb = 8 +# How many processes carry the connections of members. At 1 the node does it +# all in one process, on one core: about 35 MB/s summed over every transfer in +# progress. Above 1 the node starts that many processes for the connections and +# keeps the rest for itself, so transfers use that many cores, plus part of one +# for the node. Takes effect for new connections, without a restart. Not above +# the number of cores of this machine. +connection_processes = 1 + # HEVC sources have no browser decoder on most platforms, so streaming one is # transcoded to H264 rather than the usual free copy โ real CPU per viewer. # Set to false only if every viewer's client is known to decode HEVC itself. @@ -193,6 +201,9 @@ class NodeConfig: # concurrency. There is still no aggregate quota (MESHBAY_DESIGN.md # ยง15.3), so this is what stands between a writable root and a full disk. max_upload_gb: float = 8.0 + # How many processes hold the peer connections. One means this process + # holds them itself, as it always did. See transport/webrtc/workers.py. + connection_processes: int = 1 # HEVC (and any future codec in media_probe.py's # BROWSER_INCOMPATIBLE_VIDEO_CODECS) has no decoder in most browsers, so # streaming it needs a real re-encode to H264 rather than the usual free @@ -289,6 +300,11 @@ class Config: return self.groups[0] if self.groups else GroupConfig() +def max_processes() -> int: + """The most connection processes this machine can use: one per core.""" + return max(1, os.cpu_count() or 1) + + def _positive(value: object, default: int, name: str) -> int: """A count that must be at least one, or the default with a word about it. @@ -389,6 +405,7 @@ def node_settings_defaults(nd: NodeConfig | None = None) -> dict: "max_concurrent_downloads": nd.max_concurrent_downloads, "max_concurrent_uploads": nd.max_concurrent_uploads, "max_upload_gb": nd.max_upload_gb, + "connection_processes": nd.connection_processes, "transcode_incompatible_video": nd.transcode_incompatible_video, "stun_servers": nd.stun_servers or list(DEFAULT_STUN_SERVERS), "ice_interfaces": nd.ice_interfaces, @@ -438,6 +455,9 @@ def load_config(path: Path = DEFAULT_CONFIG_PATH) -> Config: cfg.node.max_upload_gb = _positive_float( nd.get("max_upload_gb", cfg.node.max_upload_gb), cfg.node.max_upload_gb, "max_upload_gb") + cfg.node.connection_processes = min(max_processes(), _positive( + nd.get("connection_processes", cfg.node.connection_processes), + cfg.node.connection_processes, "connection_processes")) cfg.node.transcode_incompatible_video = bool( nd.get("transcode_incompatible_video", cfg.node.transcode_incompatible_video)) cfg.node.hardware_video_encode = bool( |