From 783f207eb1bacb89177b85fe6d1b74cc73f5989a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20R=C3=A4tzel?= Date: Sat, 30 Jan 2021 10:37:39 +0000 Subject: [PATCH] Reduce blocking time and response times for public interface when garbage collecting in the process store Adapt to observation from production: The part enumerating the file paths can take the most time. To reduce response times on the public interface, move that part out of the locked region. --- .../PersistentProcess.WebHost/Program.cs | 2 +- .../StartupAdminInterface.cs | 11 +++++++++-- implement/elm-fullstack/elm-fullstack.csproj | 4 ++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/implement/PersistentProcess/PersistentProcess.WebHost/Program.cs b/implement/PersistentProcess/PersistentProcess.WebHost/Program.cs index 873440d2..d57a03fd 100644 --- a/implement/PersistentProcess/PersistentProcess.WebHost/Program.cs +++ b/implement/PersistentProcess/PersistentProcess.WebHost/Program.cs @@ -2,6 +2,6 @@ namespace Kalmit.PersistentProcess.WebHost { public class Program { - static public string AppVersionId => "2021-01-29"; + static public string AppVersionId => "2021-01-30"; } } diff --git a/implement/PersistentProcess/PersistentProcess.WebHost/StartupAdminInterface.cs b/implement/PersistentProcess/PersistentProcess.WebHost/StartupAdminInterface.cs index eab85b52..855d7aa8 100644 --- a/implement/PersistentProcess/PersistentProcess.WebHost/StartupAdminInterface.cs +++ b/implement/PersistentProcess/PersistentProcess.WebHost/StartupAdminInterface.cs @@ -533,8 +533,12 @@ TruncateProcessHistoryReport truncateProcessHistory(TimeSpan productionBlockDura var totalStopwatch = System.Diagnostics.Stopwatch.StartNew(); + var filePathsInProcessStore = processStoreFileStore.ListFilesInDirectory(ImmutableList.Empty); + lock (avoidConcurrencyLock) { + var lockStopwatch = System.Diagnostics.Stopwatch.StartNew(); + var storeReductionStopwatch = System.Diagnostics.Stopwatch.StartNew(); var storeReductionReport = @@ -556,12 +560,12 @@ TruncateProcessHistoryReport truncateProcessHistory(TimeSpan productionBlockDura int deletedFilesCount = 0; - foreach (var filePath in processStoreFileStore.ListFilesInDirectory(ImmutableList.Empty)) + foreach (var filePath in filePathsInProcessStore) { if (filesForRestore.Contains(filePath)) continue; - if (productionBlockDurationLimit < totalStopwatch.Elapsed) + if (productionBlockDurationLimit < lockStopwatch.Elapsed) break; processStoreFileStore.DeleteFile(filePath); @@ -578,6 +582,7 @@ TruncateProcessHistoryReport truncateProcessHistory(TimeSpan productionBlockDura storeReductionReport = storeReductionReport, getFilesForRestoreTimeSpentMilli = (int)getFilesForRestoreStopwatch.ElapsedMilliseconds, deleteFilesTimeSpentMilli = (int)deleteFilesStopwatch.ElapsedMilliseconds, + lockedTimeSpentMilli = (int)lockStopwatch.ElapsedMilliseconds, totalTimeSpentMilli = (int)totalStopwatch.ElapsedMilliseconds, }; } @@ -738,6 +743,8 @@ public class TruncateProcessHistoryReport public int deletedFilesCount; + public int lockedTimeSpentMilli; + public int totalTimeSpentMilli; public int storeReductionTimeSpentMilli; diff --git a/implement/elm-fullstack/elm-fullstack.csproj b/implement/elm-fullstack/elm-fullstack.csproj index e1abc213..d83bd8fb 100644 --- a/implement/elm-fullstack/elm-fullstack.csproj +++ b/implement/elm-fullstack/elm-fullstack.csproj @@ -5,8 +5,8 @@ netcoreapp3.1 elm_fullstack elm-fullstack - 2021.0129.0.0 - 2021.0129.0.0 + 2021.0130.0.0 + 2021.0130.0.0