From f07a49ff9b2326fd275e06b29073011410f939bb Mon Sep 17 00:00:00 2001 From: Nathan Mytelka Date: Sun, 26 Sep 2021 08:51:09 -0700 Subject: [PATCH 1/5] Stop removing from file state cache This was causing numerous unnecessary cache misses. --- src/Tasks/SystemState.cs | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/Tasks/SystemState.cs b/src/Tasks/SystemState.cs index 2992e07bc73..df59fad47b2 100644 --- a/src/Tasks/SystemState.cs +++ b/src/Tasks/SystemState.cs @@ -366,15 +366,6 @@ private FileState ComputeFileStateFromCachesAndDisk(string path) // If the process-wide cache contains an up-to-date FileState, always use it if (isProcessFileStateUpToDate) { - // If a FileState already exists in this instance cache due to deserialization, remove it; - // another instance has taken responsibility for serialization, and keeping this would - // result in multiple instances serializing the same data to disk - if (isCachedInInstance) - { - instanceLocalFileStateCache.Remove(path); - isDirty = true; - } - return cachedProcessFileState; } // If the process-wide FileState is missing or out-of-date, this instance owns serialization; From 0e7c6ea9ef7d62c365d7b826455a29b90567f8ee Mon Sep 17 00:00:00 2001 From: Nathan Mytelka Date: Sun, 26 Sep 2021 08:51:17 -0700 Subject: [PATCH 2/5] Tiny clarity tweak --- src/Tasks/AssemblyDependency/ReferenceTable.cs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/Tasks/AssemblyDependency/ReferenceTable.cs b/src/Tasks/AssemblyDependency/ReferenceTable.cs index 196a70b8747..3b214c55a9f 100644 --- a/src/Tasks/AssemblyDependency/ReferenceTable.cs +++ b/src/Tasks/AssemblyDependency/ReferenceTable.cs @@ -741,13 +741,8 @@ out string redistName /// private static void TryConvertToAssemblyName(string itemSpec, string fusionName, ref AssemblyNameExtension assemblyName) { - // FusionName is used if available. - string finalName = fusionName; - if (string.IsNullOrEmpty(finalName)) - { - // Otherwise, its itemSpec. - finalName = itemSpec; - } + // FusionName is used if available; otherwise use itemspec. + string finalName = string.IsNullOrEmpty(fusionName) ? itemSpec : fusionName; bool pathRooted = false; try From a970a3df29daa7d2a29a845d092543b36e61b83e Mon Sep 17 00:00:00 2001 From: Nathan Mytelka Date: Fri, 1 Oct 2021 08:54:48 -0700 Subject: [PATCH 3/5] Add to file cache --- src/Tasks/SystemState.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Tasks/SystemState.cs b/src/Tasks/SystemState.cs index df59fad47b2..b68cb5f8b5f 100644 --- a/src/Tasks/SystemState.cs +++ b/src/Tasks/SystemState.cs @@ -366,6 +366,10 @@ private FileState ComputeFileStateFromCachesAndDisk(string path) // If the process-wide cache contains an up-to-date FileState, always use it if (isProcessFileStateUpToDate) { + if (!isInstanceFileStateUpToDate) + { + instanceLocalFileStateCache[path] = cachedProcessFileState; + } return cachedProcessFileState; } // If the process-wide FileState is missing or out-of-date, this instance owns serialization; From 49e92636b4406f8147acaebe952f0a38289f57a4 Mon Sep 17 00:00:00 2001 From: Forgind Date: Fri, 1 Oct 2021 11:29:19 -0700 Subject: [PATCH 4/5] Update src/Tasks/SystemState.cs --- src/Tasks/SystemState.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Tasks/SystemState.cs b/src/Tasks/SystemState.cs index b68cb5f8b5f..f018d2044c7 100644 --- a/src/Tasks/SystemState.cs +++ b/src/Tasks/SystemState.cs @@ -369,6 +369,7 @@ private FileState ComputeFileStateFromCachesAndDisk(string path) if (!isInstanceFileStateUpToDate) { instanceLocalFileStateCache[path] = cachedProcessFileState; + isDirty = true; } return cachedProcessFileState; } From 749a96228c6dff19533a9c2707299261a05d3769 Mon Sep 17 00:00:00 2001 From: Nathan Mytelka Date: Mon, 4 Oct 2021 09:26:46 -0700 Subject: [PATCH 5/5] Change comments --- src/Tasks/SystemState.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Tasks/SystemState.cs b/src/Tasks/SystemState.cs index b68cb5f8b5f..5656518499b 100644 --- a/src/Tasks/SystemState.cs +++ b/src/Tasks/SystemState.cs @@ -366,14 +366,13 @@ private FileState ComputeFileStateFromCachesAndDisk(string path) // If the process-wide cache contains an up-to-date FileState, always use it if (isProcessFileStateUpToDate) { + // For the next build, we may be using a different process. Update the file cache. if (!isInstanceFileStateUpToDate) { instanceLocalFileStateCache[path] = cachedProcessFileState; } return cachedProcessFileState; } - // If the process-wide FileState is missing or out-of-date, this instance owns serialization; - // sync the process-wide cache and signal other instances to avoid data duplication if (isInstanceFileStateUpToDate) { return s_processWideFileStateCache[path] = cachedInstanceFileState;