File tree 2 files changed +14
-0
lines changed 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ import (
24
24
"golang.org/x/tools/gopls/internal/lsp"
25
25
"golang.org/x/tools/gopls/internal/lsp/cache"
26
26
"golang.org/x/tools/gopls/internal/lsp/debug"
27
+ "golang.org/x/tools/gopls/internal/lsp/filecache"
27
28
"golang.org/x/tools/gopls/internal/lsp/lsprpc"
28
29
"golang.org/x/tools/gopls/internal/lsp/protocol"
29
30
"golang.org/x/tools/gopls/internal/lsp/source"
@@ -214,6 +215,11 @@ func isZeroValue(f *flag.Flag, value string) bool {
214
215
// If no arguments are passed it will invoke the server sub command, as a
215
216
// temporary measure for compatibility.
216
217
func (app * Application ) Run (ctx context.Context , args ... string ) error {
218
+ // In the category of "things we can do while waiting for the Go command":
219
+ // Pre-initialize the filecache, which takes ~50ms to hash the gopls
220
+ // executable, and immediately runs a gc.
221
+ filecache .Start ()
222
+
217
223
ctx = debug .WithInstance (ctx , app .wd , app .OCAgent )
218
224
if len (args ) == 0 {
219
225
s := flag .NewFlagSet (app .Name (), flag .ExitOnError )
Original file line number Diff line number Diff line change @@ -38,6 +38,14 @@ import (
38
38
"golang.org/x/tools/internal/lockedfile"
39
39
)
40
40
41
+ // Start causes the filecache to initialize and start garbage gollection.
42
+ //
43
+ // Start is automatically called by the first call to Get, but may be called
44
+ // explicitly to pre-initialize the cache.
45
+ func Start () {
46
+ go getCacheDir ()
47
+ }
48
+
41
49
// Get retrieves from the cache and returns a newly allocated
42
50
// copy of the value most recently supplied to Set(kind, key),
43
51
// possibly by another process.
You can’t perform that action at this time.
0 commit comments