|
18 | 18 | using System.Security; |
19 | 19 | using System.Text; |
20 | 20 | using System.Threading; |
| 21 | +using System.Threading.Tasks; |
21 | 22 | using static GVFS.Common.Git.LibGit2Repo; |
22 | 23 |
|
23 | 24 | namespace GVFS.Mount |
@@ -84,6 +85,27 @@ public void Mount(EventLevel verbosity, Keywords keywords) |
84 | 85 | { |
85 | 86 | this.currentState = MountState.Mounting; |
86 | 87 |
|
| 88 | + // Start auth + config query immediately — these are network-bound and don't |
| 89 | + // depend on repo metadata or cache paths. Every millisecond of network latency |
| 90 | + // we can overlap with local I/O is a win. |
| 91 | + Stopwatch parallelTimer = Stopwatch.StartNew(); |
| 92 | + |
| 93 | + var networkTask = Task.Run(() => |
| 94 | + { |
| 95 | + Stopwatch sw = Stopwatch.StartNew(); |
| 96 | + string authError; |
| 97 | + if (!this.enlistment.Authentication.TryInitialize(this.tracer, this.enlistment, out authError)) |
| 98 | + { |
| 99 | + this.tracer.RelatedWarning("Mount will proceed, but new files cannot be accessed until GVFS can authenticate: " + authError); |
| 100 | + } |
| 101 | + |
| 102 | + this.tracer.RelatedInfo("ParallelMount: Auth completed in {0}ms", sw.ElapsedMilliseconds); |
| 103 | + |
| 104 | + ServerGVFSConfig config = this.QueryAndValidateGVFSConfig(); |
| 105 | + this.tracer.RelatedInfo("ParallelMount: Auth + config query completed in {0}ms", sw.ElapsedMilliseconds); |
| 106 | + return config; |
| 107 | + }); |
| 108 | + |
87 | 109 | // We must initialize repo metadata before starting the pipe server so it |
88 | 110 | // can immediately handle status requests |
89 | 111 | string error; |
@@ -122,39 +144,57 @@ public void Mount(EventLevel verbosity, Keywords keywords) |
122 | 144 |
|
123 | 145 | this.enlistment.InitializeCachePaths(localCacheRoot, gitObjectsRoot, blobSizesRoot); |
124 | 146 |
|
125 | | - if (!this.enlistment.Authentication.TryInitialize(this.tracer, this.enlistment, out error)) |
| 147 | + // Local validations and git config run while we wait for the network |
| 148 | + var localTask = Task.Run(() => |
126 | 149 | { |
127 | | - this.tracer.RelatedWarning("Mount will proceed, but new files cannot be accessed until GVFS can authenticate: " + error); |
128 | | - } |
| 150 | + Stopwatch sw = Stopwatch.StartNew(); |
129 | 151 |
|
130 | | - this.ValidateGitVersion(); |
131 | | - this.ValidateHooksVersion(); |
132 | | - this.ValidateFileSystemSupportsRequiredFeatures(); |
| 152 | + this.ValidateGitVersion(); |
| 153 | + this.tracer.RelatedInfo("ParallelMount: ValidateGitVersion completed in {0}ms", sw.ElapsedMilliseconds); |
133 | 154 |
|
134 | | - ServerGVFSConfig serverGVFSConfig = this.QueryAndValidateGVFSConfig(); |
| 155 | + this.ValidateHooksVersion(); |
| 156 | + this.ValidateFileSystemSupportsRequiredFeatures(); |
135 | 157 |
|
136 | | - CacheServerResolver cacheServerResolver = new CacheServerResolver(this.tracer, this.enlistment); |
137 | | - this.cacheServer = cacheServerResolver.ResolveNameFromRemote(this.cacheServer.Url, serverGVFSConfig); |
| 158 | + GitProcess git = new GitProcess(this.enlistment); |
| 159 | + if (!git.IsValidRepo()) |
| 160 | + { |
| 161 | + this.FailMountAndExit("The .git folder is missing or has invalid contents"); |
| 162 | + } |
138 | 163 |
|
139 | | - this.EnsureLocalCacheIsHealthy(serverGVFSConfig); |
| 164 | + if (!GVFSPlatform.Instance.FileSystem.IsFileSystemSupported(this.enlistment.EnlistmentRoot, out string fsError)) |
| 165 | + { |
| 166 | + this.FailMountAndExit("FileSystem unsupported: " + fsError); |
| 167 | + } |
140 | 168 |
|
141 | | - GitProcess git = new GitProcess(this.enlistment); |
142 | | - if (!git.IsValidRepo()) |
143 | | - { |
144 | | - this.FailMountAndExit("The .git folder is missing or has invalid contents"); |
145 | | - } |
| 169 | + this.tracer.RelatedInfo("ParallelMount: Local validations completed in {0}ms", sw.ElapsedMilliseconds); |
| 170 | + |
| 171 | + if (!this.TrySetRequiredGitConfigSettings()) |
| 172 | + { |
| 173 | + this.FailMountAndExit("Unable to configure git repo"); |
| 174 | + } |
146 | 175 |
|
147 | | - if (!GVFSPlatform.Instance.FileSystem.IsFileSystemSupported(this.enlistment.EnlistmentRoot, out error)) |
| 176 | + this.LogEnlistmentInfoAndSetConfigValues(); |
| 177 | + this.tracer.RelatedInfo("ParallelMount: Local validations + git config completed in {0}ms", sw.ElapsedMilliseconds); |
| 178 | + }); |
| 179 | + |
| 180 | + try |
148 | 181 | { |
149 | | - this.FailMountAndExit("FileSystem unsupported: " + error); |
| 182 | + Task.WaitAll(networkTask, localTask); |
150 | 183 | } |
151 | | - |
152 | | - if (!this.TrySetRequiredGitConfigSettings()) |
| 184 | + catch (AggregateException ae) |
153 | 185 | { |
154 | | - this.FailMountAndExit("Unable to configure git repo"); |
| 186 | + this.FailMountAndExit(ae.Flatten().InnerExceptions[0].Message); |
155 | 187 | } |
156 | 188 |
|
157 | | - this.LogEnlistmentInfoAndSetConfigValues(); |
| 189 | + parallelTimer.Stop(); |
| 190 | + this.tracer.RelatedInfo("ParallelMount: All parallel tasks completed in {0}ms", parallelTimer.ElapsedMilliseconds); |
| 191 | + |
| 192 | + ServerGVFSConfig serverGVFSConfig = networkTask.Result; |
| 193 | + |
| 194 | + CacheServerResolver cacheServerResolver = new CacheServerResolver(this.tracer, this.enlistment); |
| 195 | + this.cacheServer = cacheServerResolver.ResolveNameFromRemote(this.cacheServer.Url, serverGVFSConfig); |
| 196 | + |
| 197 | + this.EnsureLocalCacheIsHealthy(serverGVFSConfig); |
158 | 198 |
|
159 | 199 | using (NamedPipeServer pipeServer = this.StartNamedPipe()) |
160 | 200 | { |
|
0 commit comments