From 79fb693cbb3d10d035944bb0a8eb324f2d9311f4 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 25 Sep 2022 14:41:55 -0500 Subject: default scan workers to Environment.ProcessorCount --- docs/config.md | 2 +- src/slskd/Core/Options.cs | 52 +++++++++++++++++++++++------------------------ 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/docs/config.md b/docs/config.md index a7106487..dbe34a36 100644 --- a/docs/config.md +++ b/docs/config.md @@ -170,7 +170,7 @@ Scanning shares is an I/O intensive operation; all of the files and directories are used to allow metadata to be read from several files concurrently. The scan generally gets faster as additional workers are added, but each worker also adds additional I/O pressure and increases CPU and memory usage. At some number of workers performance will start to get worse as more are added. The optimal number of workers will vary from system to system, so if scan performance is important to you it will be a good idea to experiment to see what the optimal number is for your system. -The default number of workers is 16. +The default number of workers determined by the [Environment.ProcessorCount](https://learn.microsoft.com/en-us/dotnet/api/system.environment.processorcount?view=net-6.0) property. | Command Line | Environment Variable | Description | | ---------------------------- | -------------------------- | ------------------------------------------------------- | diff --git a/src/slskd/Core/Options.cs b/src/slskd/Core/Options.cs index 070476d1..937804de 100644 --- a/src/slskd/Core/Options.cs +++ b/src/slskd/Core/Options.cs @@ -380,32 +380,6 @@ namespace slskd [Validate] public ShareCacheOptions Cache { get; init; } = new ShareCacheOptions(); - /// - /// Share caching options. - /// - public class ShareCacheOptions - { - /// - /// Gets the type of storage to use for the share cache. - /// - [Argument(default, "share-cache-storage-mode")] - [EnvironmentVariable("SHARE_CACHE_STORAGE_MODE")] - [Description("the type of storage to use for the cache")] - [Enum(typeof(StorageMode))] - [RequiresRestart] - public string StorageMode { get; init; } = slskd.StorageMode.Memory.ToString().ToLowerInvariant(); - - /// - /// Gets the number of workers to use while scanning shares. - /// - [Argument(default, "share-cache-workers")] - [EnvironmentVariable("SHARE_CACHE_WORKERS")] - [Description("the number of workers to use while scanning shares")] - [Range(1, 128)] - [RequiresRestart] - public int Workers { get; init; } = 16; - } - /// /// Extended validation. /// @@ -492,6 +466,32 @@ namespace slskd return results; } + + /// + /// Share caching options. + /// + public class ShareCacheOptions + { + /// + /// Gets the type of storage to use for the share cache. + /// + [Argument(default, "share-cache-storage-mode")] + [EnvironmentVariable("SHARE_CACHE_STORAGE_MODE")] + [Description("the type of storage to use for the cache")] + [Enum(typeof(StorageMode))] + [RequiresRestart] + public string StorageMode { get; init; } = slskd.StorageMode.Memory.ToString().ToLowerInvariant(); + + /// + /// Gets the number of workers to use while scanning shares. + /// + [Argument(default, "share-cache-workers")] + [EnvironmentVariable("SHARE_CACHE_WORKERS")] + [Description("the number of workers to use while scanning shares")] + [Range(1, 128)] + [RequiresRestart] + public int Workers { get; init; } = Environment.ProcessorCount; + } } /// -- cgit v1.2.3