Mercurial > hg > orthanc
changeset 6839:7c9ecd5a793c streaming
publishing cache metrics
| author | Sebastien Jodogne <s.jodogne@gmail.com> |
|---|---|
| date | Thu, 21 May 2026 14:13:21 +0200 |
| parents | 7607ed3d07ff |
| children | b891f8f14b51 |
| files | OrthancFramework/Sources/Cache/SharedObjectCache.cpp OrthancFramework/Sources/Cache/SharedObjectCache.h OrthancFramework/Sources/DataSource/DataSourceMemoryBudget.cpp OrthancFramework/Sources/DataSource/DataSourceMemoryBudget.h OrthancFramework/Sources/DataSource/DataSourceReader.cpp OrthancFramework/Sources/DataSource/DataSourceReader.h OrthancServer/Sources/ServerContext.cpp |
| diffstat | 7 files changed, 89 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/OrthancFramework/Sources/Cache/SharedObjectCache.cpp Thu May 21 12:37:33 2026 +0200 +++ b/OrthancFramework/Sources/Cache/SharedObjectCache.cpp Thu May 21 14:13:21 2026 +0200 @@ -189,4 +189,15 @@ assert(!lru_.Contains(id)); } + + + void SharedObjectCache::GetStatistics(size_t& capacity, + size_t& currentCount, + size_t& currentSize) + { + Mutex::ScopedLock lock(mutex_); + capacity = capacity_; + currentCount = lru_.GetSize(); + currentSize = currentSize_; + } }
--- a/OrthancFramework/Sources/Cache/SharedObjectCache.h Thu May 21 12:37:33 2026 +0200 +++ b/OrthancFramework/Sources/Cache/SharedObjectCache.h Thu May 21 14:13:21 2026 +0200 @@ -69,5 +69,9 @@ size_t size); void Invalidate(const std::string& id); + + void GetStatistics(size_t& capacity, + size_t& currentCount, + size_t& currentSize); }; }
--- a/OrthancFramework/Sources/DataSource/DataSourceMemoryBudget.cpp Thu May 21 12:37:33 2026 +0200 +++ b/OrthancFramework/Sources/DataSource/DataSourceMemoryBudget.cpp Thu May 21 14:13:21 2026 +0200 @@ -72,5 +72,17 @@ boost::mutex::scoped_lock lock(mutex_); return currentMemory_; } + + + void DataSourceMemoryBudget::GetStatistics(uint64_t& maximumMemory, + uint64_t& currentMemory, + unsigned int& countReservations) + + { + boost::mutex::scoped_lock lock(mutex_); + maximumMemory = maximumMemory_; + currentMemory = currentMemory_; + countReservations = reservations_; + } } }
--- a/OrthancFramework/Sources/DataSource/DataSourceMemoryBudget.h Thu May 21 12:37:33 2026 +0200 +++ b/OrthancFramework/Sources/DataSource/DataSourceMemoryBudget.h Thu May 21 14:13:21 2026 +0200 @@ -79,6 +79,10 @@ that_.Release(memory_); } }; + + void GetStatistics(uint64_t& maximumMemory, + uint64_t& currentMemory, + unsigned int& countReservations); }; } }
--- a/OrthancFramework/Sources/DataSource/DataSourceReader.cpp Thu May 21 12:37:33 2026 +0200 +++ b/OrthancFramework/Sources/DataSource/DataSourceReader.cpp Thu May 21 14:13:21 2026 +0200 @@ -221,4 +221,33 @@ return item->GetValue(); } + + + void DataSourceReader::GetStatistics(uint64_t& tasksMaximumMemory, + uint64_t& tasksCurrentMemory, + unsigned int& tasksReservations, + size_t& cacheCapacity, + size_t& cacheCurrentCount, + size_t& cacheCurrentSize) + { + { + boost::shared_ptr<Internals::DataSourceMemoryBudget> budgetCopy(budget_); + budgetCopy->GetStatistics(tasksMaximumMemory, tasksCurrentMemory, tasksReservations); + } + + { + boost::shared_ptr<SharedObjectCache> cacheCopy(cache_); + + if (cacheCopy) + { + cacheCopy->GetStatistics(cacheCapacity, cacheCurrentCount, cacheCurrentSize); + } + else + { + cacheCapacity = 0; + cacheCurrentCount = 0; + cacheCurrentSize = 0; + } + } + } }
--- a/OrthancFramework/Sources/DataSource/DataSourceReader.h Thu May 21 12:37:33 2026 +0200 +++ b/OrthancFramework/Sources/DataSource/DataSourceReader.h Thu May 21 14:13:21 2026 +0200 @@ -73,5 +73,12 @@ { executor_->Stop(); } + + void GetStatistics(uint64_t& tasksMaximumMemory, + uint64_t& tasksCurrentMemory, + unsigned int& tasksReservations, + size_t& cacheCapacity, + size_t& cacheCurrentCount, + size_t& cacheCurrentSize); }; }
--- a/OrthancServer/Sources/ServerContext.cpp Thu May 21 12:37:33 2026 +0200 +++ b/OrthancServer/Sources/ServerContext.cpp Thu May 21 14:13:21 2026 +0200 @@ -362,18 +362,30 @@ void ServerContext::PublishCacheMetrics() { - // TODO-Streaming + uint64_t tasksMaximumMemory; + uint64_t tasksCurrentMemory; + unsigned int tasksReservations; + size_t cacheCapacity; + size_t cacheCurrentCount; + size_t cacheCurrentSize; - //metricsRegistry_->SetFloatValue("orthanc_dicom_cache_size_mb", - //static_cast<float>(dicomCache_.GetCurrentSize()) / static_cast<float>(1024 * 1024)); - //metricsRegistry_->SetIntegerValue("orthanc_dicom_cache_count", - //static_cast<int64_t>(dicomCache_.GetNumberOfItems())); + storageAreaReader_->GetStatistics(tasksMaximumMemory, tasksCurrentMemory, tasksReservations, + cacheCapacity, cacheCurrentCount, cacheCurrentSize); + metricsRegistry_->SetFloatValue("orthanc_storage_cache_size_mb", + static_cast<float>(cacheCurrentSize) / static_cast<float>(MEGABYTE)); + metricsRegistry_->SetIntegerValue("orthanc_storage_cache_count", cacheCurrentCount); + dicomReader_->GetStatistics(tasksMaximumMemory, tasksCurrentMemory, tasksReservations, + cacheCapacity, cacheCurrentCount, cacheCurrentSize); + metricsRegistry_->SetFloatValue("orthanc_dicom_cache_size_mb", + static_cast<float>(cacheCurrentSize) / static_cast<float>(MEGABYTE)); + metricsRegistry_->SetIntegerValue("orthanc_dicom_cache_count", cacheCurrentCount); - //metricsRegistry_->SetFloatValue("orthanc_storage_cache_size_mb", - //static_cast<float>(storageCache_.GetCurrentSize()) / static_cast<float>(1024 * 1024)); - //metricsRegistry_->SetIntegerValue("orthanc_storage_cache_count", - //static_cast<int64_t>(storageCache_.GetNumberOfItems())); + transcoderReader_->GetStatistics(tasksMaximumMemory, tasksCurrentMemory, tasksReservations, + cacheCapacity, cacheCurrentCount, cacheCurrentSize); + metricsRegistry_->SetFloatValue("orthanc_transcoder_cache_size_mb", + static_cast<float>(cacheCurrentSize) / static_cast<float>(MEGABYTE)); + metricsRegistry_->SetIntegerValue("orthanc_transcoder_cache_count", cacheCurrentCount); } @@ -581,7 +593,7 @@ dicomReader_.reset(new DataSourceReader(pool, new DicomDataSource(storageAreaReader_))); dicomReader_->SetCapacity(1 * GIGABYTE); // 1 GB - TODO-Streaming - Parameter - dicomReader_->CreateCache(256 * MEGABYTE); // 256 MB - TODO-Streaming - Parameter + dicomReader_->CreateCache(32 * MEGABYTE); // 256 MB - TODO-Streaming - Parameter } if (transcoder_.get() != NULL)
