changeset 585:99c404a35d6a

added 'MetadataWorkerThreadsCount' configuration
author Alain Mazy <am@osimis.io>
date Wed, 28 Jun 2023 15:30:14 +0200
parents 39b7ccaa6dfc
children 30d6a4d61d21
files NEWS Plugin/Configuration.cpp Plugin/Configuration.h Plugin/WadoRs.cpp
diffstat 4 files changed, 15 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Wed Jun 28 15:10:15 2023 +0200
+++ b/NEWS	Wed Jun 28 15:30:14 2023 +0200
@@ -1,9 +1,12 @@
 Pending changes in the mainline
 ===============================
 
-* Speeded up instance metadata retrieval using OrthancPluginLoadDicomInstance() from SDK 1.12.1
+* speed improvements:
+  - Speeded up instance metadata retrieval using OrthancPluginLoadDicomInstance() from SDK 1.12.1
+  - Using multiple threads to compute the studies/../series/../metadata route when in "Full" mode.
+    New configuration: "MetadataWorkerThreadsCount" defaults to 4
+  - Small speed-up the studies/../series/../metadata route when in "MainDicomTags" mode.
 * Support "X-Forwarded-Host" and "X-Forwarded-Proto" headers to compute BulkDataURI.
-* Small speed-up the studies/../series/../metadata route when in "MainDicomTags" mode.
 * Fix issue #216 (Requests fail due to bad parsing of the accept HTTP header (semi-colons))
 
 
--- a/Plugin/Configuration.cpp	Wed Jun 28 15:10:15 2023 +0200
+++ b/Plugin/Configuration.cpp	Wed Jun 28 15:30:14 2023 +0200
@@ -671,6 +671,11 @@
       }
     }
 
+    unsigned int GetMetadataWorkerThreadsCount()
+    {
+      return GetUnsignedIntegerValue("MetadataWorkerThreadsCount", 4);
+    }
+
     
     MetadataMode GetMetadataMode(Orthanc::ResourceType level)
     {
--- a/Plugin/Configuration.h	Wed Jun 28 15:10:15 2023 +0200
+++ b/Plugin/Configuration.h	Wed Jun 28 15:30:14 2023 +0200
@@ -137,5 +137,7 @@
     void LoadDicomWebServers();
 
     void SaveDicomWebServers();
+
+    unsigned int GetMetadataWorkerThreadsCount();
   }
 }
--- a/Plugin/WadoRs.cpp	Wed Jun 28 15:10:15 2023 +0200
+++ b/Plugin/WadoRs.cpp	Wed Jun 28 15:30:14 2023 +0200
@@ -1292,7 +1292,7 @@
   std::list<std::string> instancesIds;
   std::string seriesDicomUid;
 
-  size_t threadCount = 4;
+  unsigned int workersCount =  OrthancPlugins::Configuration::GetMetadataWorkerThreadsCount();
   bool oneLargeQuery = false;  // we keep this code here for future use once we'll have optimized Orthanc API /series/.../instances?full to minimize the SQL queries
                                 // right now, it is faster to call /instances/..?full in each worker but, later, it should be more efficient with a large SQL query in Orthanc
 
@@ -1305,7 +1305,7 @@
     GetChildrenIdentifiers(instancesIds, seriesDicomUid, Orthanc::ResourceType_Series, seriesOrthancId);
   }
 
-  if (threadCount > 1)
+  if (workersCount > 1)
   {
     // span a few workers to get the tags from the core and serialize them
     Orthanc::SharedMessageQueue instancesQueue;
@@ -1313,7 +1313,7 @@
     boost::mutex writerMutex;
     std::vector<boost::shared_ptr<InstanceWorkerData> > instancesWorkersData;
 
-    for (size_t t = 0; t < threadCount; t++)
+    for (unsigned int t = 0; t < workersCount; t++)
     {
       InstanceWorkerData* threadData = new InstanceWorkerData(boost::lexical_cast<std::string>(t), &instancesQueue, wadoBase);
       instancesWorkersData.push_back(boost::shared_ptr<InstanceWorkerData>(threadData));