From 0c6e2f5c99b02bdd4bb24ec1de53d9f2921a8eab Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Tue, 7 Apr 2026 11:26:32 +0200 Subject: [PATCH 1/2] update conf route x calcolo min/max statistiche --- MP.IOC/Services/MetricsFlushService.cs | 19 ++++++++++--------- MP.IOC/Services/RouteManager.cs | 2 +- MP.IOC/Services/RouteStatsManager.cs | 11 +++++++++++ 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/MP.IOC/Services/MetricsFlushService.cs b/MP.IOC/Services/MetricsFlushService.cs index 47e7afcb..417fbc18 100644 --- a/MP.IOC/Services/MetricsFlushService.cs +++ b/MP.IOC/Services/MetricsFlushService.cs @@ -72,21 +72,22 @@ namespace MP.IOC.Services var taskZAddHour = batch.SortedSetAddAsync(hoursIndex, hourKey, hourScore); var taskZAddDay = batch.SortedSetAddAsync(daysIndex, dayKey, dayScore); - // Optionally set TTL on bucket hashes (e.g., keep daily buckets 400 days) - var taskExpireHour = batch.KeyExpireAsync(hourKey, TimeSpan.FromDays(11)); // keep ~11 days for hourly - var taskExpireDay = batch.KeyExpireAsync(dayKey, TimeSpan.FromDays(400)); // keep ~400 days for daily + //// Optionally set TTL on bucket hashes (e.g., keep daily buckets 400 days) + //var taskExpireHour = batch.KeyExpireAsync(hourKey, TimeSpan.FromDays(11)); // keep ~11 days for hourly + //var taskExpireDay = batch.KeyExpireAsync(dayKey, TimeSpan.FromDays(400)); // keep ~400 days for daily // Execute batch batch.Execute(); // Await tasks to ensure completion - await Task.WhenAll(taskHourCount, taskHourTotal, taskDayCount, taskDayTotal, - taskZAddHour, taskZAddDay, taskExpireHour, taskExpireDay); + await Task.WhenAll(taskHourCount, taskHourTotal, taskDayCount, taskDayTotal, taskZAddHour, taskZAddDay); + //await Task.WhenAll(taskHourCount, taskHourTotal, taskDayCount, taskDayTotal, + // taskZAddHour, taskZAddDay, taskExpireHour, taskExpireDay); - // Trim indices to keep only last N entries (use ZREMRANGEBYRANK) - // Note: trimming is separate calls (not in batch) to ensure ordering; can be batched too. - await _db.SortedSetRemoveRangeByRankAsync(hoursIndex, 0, -MaxHourlyBuckets - 1); // keep last MaxHourlyBuckets - await _db.SortedSetRemoveRangeByRankAsync(daysIndex, 0, -MaxDailyBuckets - 1); + //// Trim indices to keep only last N entries (use ZREMRANGEBYRANK) + //// Note: trimming is separate calls (not in batch) to ensure ordering; can be batched too. + //await _db.SortedSetRemoveRangeByRankAsync(hoursIndex, 0, -MaxHourlyBuckets - 1); // keep last MaxHourlyBuckets + //await _db.SortedSetRemoveRangeByRankAsync(daysIndex, 0, -MaxDailyBuckets - 1); } _stats.Clear(); diff --git a/MP.IOC/Services/RouteManager.cs b/MP.IOC/Services/RouteManager.cs index 40176fc1..98b58120 100644 --- a/MP.IOC/Services/RouteManager.cs +++ b/MP.IOC/Services/RouteManager.cs @@ -81,7 +81,7 @@ namespace MP.IOC.Services var (oldW, newW) = _weightProvider.GetWeightsFor(metodo); var pickNew = DecideByWeights(oldW, newW); - var target = pickNew ? "new" : "old"; + var target = pickNew ? "IOC" : "IO"; // Costruisci destination base in base al target var destBase = pickNew diff --git a/MP.IOC/Services/RouteStatsManager.cs b/MP.IOC/Services/RouteStatsManager.cs index 58cf7b23..30a542d0 100644 --- a/MP.IOC/Services/RouteStatsManager.cs +++ b/MP.IOC/Services/RouteStatsManager.cs @@ -8,6 +8,8 @@ namespace MP.IOC.Services { public long Count; public TimeSpan TotalDuration = TimeSpan.Zero; + public TimeSpan MaxDuration = TimeSpan.Zero; + public TimeSpan MinDuration = TimeSpan.MaxValue; public ConcurrentDictionary Destinations = new(); public ConcurrentDictionary StatusCodes = new(); } @@ -30,6 +32,15 @@ namespace MP.IOC.Services lock (stat) { stat.TotalDuration += duration; + // aggiorno valori min/max se necessario + if (stat.MaxDuration < duration) + { + stat.MaxDuration = duration; + } + if (stat.MinDuration > duration) + { + stat.MinDuration = duration; + } } } } From f7bb5501899113ce3ebb61e76f92ec49b118c9f9 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Tue, 7 Apr 2026 11:26:34 +0200 Subject: [PATCH 2/2] Update x gestioen min/max --- MP.IOC/Resources/ChangeLog.html | 2 +- MP.IOC/Resources/VersNum.txt | 2 +- MP.IOC/Resources/manifest.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/MP.IOC/Resources/ChangeLog.html b/MP.IOC/Resources/ChangeLog.html index 8ca05566..8b0bc04c 100644 --- a/MP.IOC/Resources/ChangeLog.html +++ b/MP.IOC/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo MP-IOC -

Versione: 6.16.2604.710

+

Versione: 6.16.2604.711


Note di rilascio:
  • diff --git a/MP.IOC/Resources/VersNum.txt b/MP.IOC/Resources/VersNum.txt index 16b6304f..5796bee1 100644 --- a/MP.IOC/Resources/VersNum.txt +++ b/MP.IOC/Resources/VersNum.txt @@ -1 +1 @@ -6.16.2604.710 +6.16.2604.711 diff --git a/MP.IOC/Resources/manifest.xml b/MP.IOC/Resources/manifest.xml index ce899376..96f5201e 100644 --- a/MP.IOC/Resources/manifest.xml +++ b/MP.IOC/Resources/manifest.xml @@ -1,6 +1,6 @@ - 6.16.2604.710 + 6.16.2604.711 https://nexus.steamware.net/repository/SWS/MP-IOC/stable/LAST/MP.IOC.zip https://nexus.steamware.net/repository/SWS/MP-IOC/stable/LAST/ChangeLog.html false