changeset 7026:d251cd0ec90a streaming

fine tune default configs
author Alain Mazy <am@orthanc.team>
date Thu, 16 Jul 2026 16:00:22 +0200
parents a998c3b34bf4
children 27fb4cb98985
files OrthancServer/Resources/Configuration.json OrthancServer/Sources/OrthancConfiguration.cpp OrthancServer/Sources/OrthancConfiguration.h OrthancServer/Sources/ServerContext.cpp
diffstat 4 files changed, 27 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancServer/Resources/Configuration.json	Wed Jul 15 11:42:31 2026 +0200
+++ b/OrthancServer/Resources/Configuration.json	Thu Jul 16 16:00:22 2026 +0200
@@ -1206,7 +1206,7 @@
   // is disabled.  (new in Orthanc 1.12.11+)
   "TranscoderCacheSize" : 128,
 
-  // Number of threads that are used to provide DICOM files sequentially
+  // Total number of threads that are used to provide DICOM files sequentially
   // (currently used in Archive jobs, C-Store and C-Get).
   // Each time such a job needs to get a DICOM file content, it requests it from
   // a sequential DICOM reader that will itself use a s torage loader thread.
@@ -1222,10 +1222,11 @@
   // This is kind of equivalent to the older "LoaderThreads" configuration
   // but, furthermore, you must make sure that there are enough "StorageLoaderThreads"
   // and "SequentialDicomReaderThreads" for each job -> 
-  // "StorageLoaderThreads" should be larger than "ConcurrentJobs" * "SequentialDicomReaderWindowCapacity"
+  // "StorageLoaderThreads" should be larger than "ConcurrentJobs" * "SequentialDicomReaderWindowSize"
   // Together with "SequentialDicomReaderWindowCapacity", this also defines the amount of memory that is
   // used by each job that required a SequentialDicomReader.
-  "SequentialDicomReaderWindowSize": 4,
+  // By default, the value of this configuration is the same as "LoaderThreads".
+  // "SequentialDicomReaderWindowSize": 4,
   
   // Amount of RAM (in MB) that are allocated to each sequential DICOM
   // Reader.  The sequential DICOM reader stops pauses buffering as soon
--- a/OrthancServer/Sources/OrthancConfiguration.cpp	Wed Jul 15 11:42:31 2026 +0200
+++ b/OrthancServer/Sources/OrthancConfiguration.cpp	Thu Jul 16 16:00:22 2026 +0200
@@ -47,8 +47,6 @@
 static const char* const WARNINGS = "Warnings";
 static const char* const JOBS_ENGINE_THREADS_COUNT = "JobsEngineThreadsCount";
 static const char* const DICOM_LOSSY_TRANSCODING_QUALITY = "DicomLossyTranscodingQuality";
-static const char* const CONFIG_LOADER_THREADS = "LoaderThreads";
-static const char* const CONFIG_ZIP_LOADER_THREADS = "ZipLoaderThreads"; // for backward compatibility only
 
 static Json::Value defaultConfiguration;
 
@@ -1370,9 +1368,9 @@
     // from 1.10.0 to 1.12.10, only CONFIG_ZIP_LOADER_THREADS was available -> read from it if CONFIG_LOADER_THREADS is not specified.
     unsigned int loaderThreads = 1; // old ZipLoaderThreads default value
 
-    if (!LookupUnsignedIntegerParameter(loaderThreads, CONFIG_LOADER_THREADS))
+    if (!LookupUnsignedIntegerParameter(loaderThreads, ORTHANC_CONFIG_LOADER_THREADS))
     {
-      LookupUnsignedIntegerParameter(loaderThreads, CONFIG_ZIP_LOADER_THREADS); // we cannot use GetUnsignedIntegerParameter() because there is no default value for this old configuration
+      LookupUnsignedIntegerParameter(loaderThreads, ORTHANC_CONFIG_ZIP_LOADER_THREADS); // we cannot use GetUnsignedIntegerParameter() because there is no default value for this old configuration
     }
 
     if (loaderThreads <= 1)
--- a/OrthancServer/Sources/OrthancConfiguration.h	Wed Jul 15 11:42:31 2026 +0200
+++ b/OrthancServer/Sources/OrthancConfiguration.h	Thu Jul 16 16:00:22 2026 +0200
@@ -58,6 +58,10 @@
 #define ORTHANC_CONFIG_DICOM_THREADS_COUNT "DicomThreadsCount"
 #define ORTHANC_CONFIG_STORAGE_DIRECTORY "StorageDirectory"
 
+#define ORTHANC_CONFIG_LOADER_THREADS "LoaderThreads"
+#define ORTHANC_CONFIG_ZIP_LOADER_THREADS "ZipLoaderThreads"   // for backward compatibility only
+
+
 #define ORTHANC_CONFIG_STORAGE_LOADER_THREADS "StorageLoaderThreads"
 #define ORTHANC_CONFIG_STORAGE_MEMORY_CAPACITY "StorageMemoryCapacity"
 #define ORTHANC_CONFIG_MAXIMUM_STORAGE_CACHE_SIZE "MaximumStorageCacheSize"
--- a/OrthancServer/Sources/ServerContext.cpp	Wed Jul 15 11:42:31 2026 +0200
+++ b/OrthancServer/Sources/ServerContext.cpp	Thu Jul 16 16:00:22 2026 +0200
@@ -715,7 +715,7 @@
           else
           {
             storageLoaderThreads = std::min(50u, storageLoaderThreads);
-            LOG(WARNING) << "'" << ORTHANC_CONFIG_STORAGE_LOADER_THREADS << "' is not defined in your configuration, setting it to " << storageLoaderThreads << ", based on 'ConcurrentJobs' and the old 'LoaderThreads' configurations.";
+            LOG(WARNING) << "'" << ORTHANC_CONFIG_STORAGE_LOADER_THREADS << "' is not defined in your configuration, setting it to " << storageLoaderThreads << ", based on the '" << ORTHANC_CONFIG_CONCURRENT_JOBS << "' and the '" << ORTHANC_CONFIG_LOADER_THREADS << "' configurations capped at 50.";
           }
         }
         else
@@ -723,13 +723,18 @@
           LOG(WARNING) << "'" << ORTHANC_CONFIG_STORAGE_LOADER_THREADS << "' is set to " << storageLoaderThreads;
         }
 
-        // ----> IF you update values here, you must also update them in Configuration.json <-----
         transcoderThreads = lock.GetConfiguration().GetUnsignedIntegerParameter(ORTHANC_CONFIG_TRANSCODER_THREADS);
         LOG(WARNING) << "'" << ORTHANC_CONFIG_TRANSCODER_THREADS << "' is set to " << transcoderThreads;
 
         dicomParserThreads = lock.GetConfiguration().GetUnsignedIntegerParameter(ORTHANC_CONFIG_DICOM_PARSER_SOURCE_THREADS);
         LOG(WARNING) << "'" << ORTHANC_CONFIG_DICOM_PARSER_SOURCE_THREADS << "' is set to " << dicomParserThreads;
 
+        GetMemoryConfiguration(storageMemoryCapacityMb, lock, ORTHANC_CONFIG_STORAGE_MEMORY_CAPACITY);
+        GetMemoryConfiguration(dicomParserMemoryCapacityMb, lock, ORTHANC_CONFIG_DICOM_PARSER_MEMORY_CAPACITY);
+        GetMemoryConfiguration(dicomParserCacheSizeMb, lock, ORTHANC_CONFIG_DICOM_PARSER_CACHE_SIZE);
+        GetMemoryConfiguration(transcoderMemoryCapacityMb, lock, ORTHANC_CONFIG_TRANSCODER_MEMORY_CAPACITY);
+        GetMemoryConfiguration(transcoderCacheSizeMb, lock, ORTHANC_CONFIG_TRANSCODER_CACHE_SIZE);
+
         if (!lock.GetConfiguration().LookupUnsignedIntegerParameter(sequentialReaderThreads, ORTHANC_CONFIG_SEQUENTIAL_DICOM_READER_THREADS))
         {
           LOG(WARNING) << "'" << ORTHANC_CONFIG_SEQUENTIAL_DICOM_READER_THREADS << "' is not defined in your configuration, setting it to the same value as '" << ORTHANC_CONFIG_STORAGE_LOADER_THREADS << "': " << storageLoaderThreads;
@@ -740,16 +745,17 @@
           LOG(WARNING) << "'" << ORTHANC_CONFIG_SEQUENTIAL_DICOM_READER_THREADS << "' is set to " << sequentialReaderThreads;
         }
 
-        // ----> IF you update values here, you must also update them in Configuration.json <-----
-        GetMemoryConfiguration(storageMemoryCapacityMb, lock, ORTHANC_CONFIG_STORAGE_MEMORY_CAPACITY);
-        GetMemoryConfiguration(dicomParserMemoryCapacityMb, lock, ORTHANC_CONFIG_DICOM_PARSER_MEMORY_CAPACITY);
-        GetMemoryConfiguration(dicomParserCacheSizeMb, lock, ORTHANC_CONFIG_DICOM_PARSER_CACHE_SIZE);
-        GetMemoryConfiguration(transcoderMemoryCapacityMb, lock, ORTHANC_CONFIG_TRANSCODER_MEMORY_CAPACITY);
-        GetMemoryConfiguration(transcoderCacheSizeMb, lock, ORTHANC_CONFIG_TRANSCODER_CACHE_SIZE);
+        if (!lock.GetConfiguration().LookupUnsignedIntegerParameter(sequentialReaderWindowSize, ORTHANC_CONFIG_SEQUENTIAL_DICOM_READER_WINDOW_SIZE))
+        {
+          LOG(WARNING) << "'" << ORTHANC_CONFIG_SEQUENTIAL_DICOM_READER_WINDOW_SIZE << "' is not defined in your configuration, setting it to the same value as '" << ORTHANC_CONFIG_LOADER_THREADS << "': " << loaderThreads;
+          sequentialReaderWindowSize = loaderThreads;
+        }
+        else
+        {
+          LOG(WARNING) << "'" << ORTHANC_CONFIG_SEQUENTIAL_DICOM_READER_WINDOW_SIZE << "' is set to " << sequentialReaderWindowSize;
+        }
+
         GetMemoryConfiguration(sequentialReaderWindowCapacityMb, lock, ORTHANC_CONFIG_SEQUENTIAL_DICOM_READER_WINDOW_CAPACITY);
-
-        sequentialReaderWindowSize = lock.GetConfiguration().GetUnsignedIntegerParameter(ORTHANC_CONFIG_SEQUENTIAL_DICOM_READER_WINDOW_SIZE);
-        LOG(WARNING) << "'" << ORTHANC_CONFIG_SEQUENTIAL_DICOM_READER_WINDOW_SIZE << "' is set to " << sequentialReaderWindowSize;
       }
 
       // For streaming
@@ -840,13 +846,6 @@
       }
 
       {
-        // unsigned int loaderThreads;
-
-        // {
-        //   OrthancConfiguration::ReaderLock lock;
-        //   loaderThreads = lock.GetConfiguration().GetLoaderThreads();
-        // }
-
         std::unique_ptr<ThreadPool> pool(new ThreadPool);
         pool->SetThreadsCount(sequentialReaderThreads);  // TODO-Streaming - Check - clarify the difference between SequentialLoader and DataSourceReader
         pool->SetLoggingThreadName("SEQ-READER");