Skip to content

Commit

Permalink
Move thread calculation into MultiThreadedPlaceholderUpdatesAndDeletes
Browse files Browse the repository at this point in the history
  • Loading branch information
wilbaker committed Aug 5, 2019
1 parent 3357459 commit 1663653
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions GVFS/GVFS.Virtualization/Projection/GitIndexProjection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1199,18 +1199,13 @@ private void UpdatePlaceholders()

using (ITracer activity = this.context.Tracer.StartActivity("UpdatePlaceholders", EventLevel.Informational, metadata))
{
int minItemsPerThread = 10;
int numThreads = Math.Max(8, Environment.ProcessorCount);
numThreads = Math.Min(numThreads, placeholderFilesListCopy.Count / minItemsPerThread);
numThreads = Math.Max(numThreads, 1);

// folderPlaceholdersToKeep always contains the empty path so as to avoid unnecessary attempts
// to remove the repository's root folder.
ConcurrentHashSet<string> folderPlaceholdersToKeep = new ConcurrentHashSet<string>(StringComparer.OrdinalIgnoreCase);
folderPlaceholdersToKeep.Add(string.Empty);

stopwatch.Restart();
this.MultiThreadedPlaceholderUpdatesAndDeletes(numThreads, placeholderFilesListCopy, folderPlaceholdersToKeep);
this.MultiThreadedPlaceholderUpdatesAndDeletes(placeholderFilesListCopy, folderPlaceholdersToKeep);
stopwatch.Stop();

long millisecondsUpdatingFilePlaceholders = stopwatch.ElapsedMilliseconds;
Expand Down Expand Up @@ -1320,10 +1315,14 @@ private void UpdatePlaceholders()
}

private void MultiThreadedPlaceholderUpdatesAndDeletes(
int numThreads,
List<IPlaceholderData> placeholderList,
ConcurrentHashSet<string> folderPlaceholdersToKeep)
{
{
int minItemsPerThread = 10;
int numThreads = Math.Max(8, Environment.ProcessorCount);
numThreads = Math.Min(numThreads, placeholderList.Count / minItemsPerThread);
numThreads = Math.Max(numThreads, 1);

if (numThreads > 1)
{
Thread[] processThreads = new Thread[numThreads];
Expand Down

0 comments on commit 1663653

Please sign in to comment.