@@ -385,7 +385,16 @@ func hashExecutable() (hash [32]byte, err error) {
385
385
// process, possibly running a different version of gopls, possibly
386
386
// running concurrently.
387
387
func gc (goplsDir string ) {
388
- const period = 1 * time .Minute // period between collections
388
+ // period between collections
389
+ //
390
+ // This was increased from 1 minute as an immediate measure to
391
+ // reduce the CPU cost of gopls when idle, which was around
392
+ // 15% of a core (#61049). A better solution might be to avoid
393
+ // walking the entire tree every period. e.g. walk only the
394
+ // subtree corresponding to this gopls executable every period,
395
+ // and the subtrees for other gopls instances every hour.
396
+ const period = 5 * time .Minute
397
+
389
398
// Sleep statDelay*batchSize between stats to smooth out I/O.
390
399
//
391
400
// The constants below were chosen using the following heuristics:
@@ -396,17 +405,7 @@ func gc(goplsDir string) {
396
405
// sleeping after every stat (due to OS optimizations).
397
406
const statDelay = 100 * time .Microsecond // average delay between stats, to smooth out I/O
398
407
const batchSize = 1000 // # of stats to process before sleeping
399
- maxAge := 5 * 24 * time .Hour // max time since last access before file is deleted
400
-
401
- // This environment variable is set when running under a Go test builder.
402
- // We use it to trigger much more aggressive cache eviction to prevent
403
- // filling of the tmp volume by short-lived test processes.
404
- // A single run of the gopls tests takes on the order of a minute
405
- // and produces <50MB of cache data, so these are still generous.
406
- if os .Getenv ("GO_BUILDER_NAME" ) != "" {
407
- maxAge = 1 * time .Hour
408
- SetBudget (250 * 1e6 ) // 250MB
409
- }
408
+ const maxAge = 5 * 24 * time .Hour // max time since last access before file is deleted
410
409
411
410
// The macOS filesystem is strikingly slow, at least on some machines.
412
411
// /usr/bin/find achieves only about 25,000 stats per second
0 commit comments