Skip to content

Commit

Permalink
Reduce blocking time and response times for public interface when gar…
Browse files Browse the repository at this point in the history
…bage 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.
  • Loading branch information
Viir committed Jan 30, 2021
1 parent b827411 commit 783f207
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -533,8 +533,12 @@ TruncateProcessHistoryReport truncateProcessHistory(TimeSpan productionBlockDura

var totalStopwatch = System.Diagnostics.Stopwatch.StartNew();

var filePathsInProcessStore = processStoreFileStore.ListFilesInDirectory(ImmutableList<string>.Empty);

lock (avoidConcurrencyLock)
{
var lockStopwatch = System.Diagnostics.Stopwatch.StartNew();

var storeReductionStopwatch = System.Diagnostics.Stopwatch.StartNew();

var storeReductionReport =
Expand All @@ -556,12 +560,12 @@ TruncateProcessHistoryReport truncateProcessHistory(TimeSpan productionBlockDura

int deletedFilesCount = 0;

foreach (var filePath in processStoreFileStore.ListFilesInDirectory(ImmutableList<string>.Empty))
foreach (var filePath in filePathsInProcessStore)
{
if (filesForRestore.Contains(filePath))
continue;

if (productionBlockDurationLimit < totalStopwatch.Elapsed)
if (productionBlockDurationLimit < lockStopwatch.Elapsed)
break;

processStoreFileStore.DeleteFile(filePath);
Expand All @@ -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,
};
}
Expand Down Expand Up @@ -738,6 +743,8 @@ public class TruncateProcessHistoryReport

public int deletedFilesCount;

public int lockedTimeSpentMilli;

public int totalTimeSpentMilli;

public int storeReductionTimeSpentMilli;
Expand Down
4 changes: 2 additions & 2 deletions implement/elm-fullstack/elm-fullstack.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<TargetFramework>netcoreapp3.1</TargetFramework>
<RootNamespace>elm_fullstack</RootNamespace>
<AssemblyName>elm-fullstack</AssemblyName>
<AssemblyVersion>2021.0129.0.0</AssemblyVersion>
<FileVersion>2021.0129.0.0</FileVersion>
<AssemblyVersion>2021.0130.0.0</AssemblyVersion>
<FileVersion>2021.0130.0.0</FileVersion>
</PropertyGroup>

<PropertyGroup>
Expand Down

0 comments on commit 783f207

Please sign in to comment.