Skip to content

Commit 5bcc1bd

Browse files
committed
gopls/internal/lsp/filecache: evict aggressively on Go builders
This change reduces the cache space budget (1GB -> 250MB) and maximum age (5 days -> 1 hour) when the program appears to be running on a Go builder, as indicated by GO_BUILDER_NAME. Previously, the tests were occasionally filling the builders' temp volumes. Fixes golang/go#57900 Change-Id: I7cd74c8ca9933db1d8a7eb127b7e1fb76f4b387f Reviewed-on: https://go-review.googlesource.com/c/tools/+/482823 TryBot-Result: Gopher Robot <[email protected]> Run-TryBot: Alan Donovan <[email protected]> Reviewed-by: Robert Findley <[email protected]> gopls-CI: kokoro <[email protected]>
1 parent 866a200 commit 5bcc1bd

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

gopls/internal/lsp/filecache/filecache.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,17 @@ func gc(goplsDir string) {
278278
// sleeping after every stat (due to OS optimizations).
279279
const statDelay = 100 * time.Microsecond // average delay between stats, to smooth out I/O
280280
const batchSize = 1000 // # of stats to process before sleeping
281-
const maxAge = 5 * 24 * time.Hour // max time since last access before file is deleted
281+
maxAge := 5 * 24 * time.Hour // max time since last access before file is deleted
282+
283+
// This environment variable is set when running under a Go test builder.
284+
// We use it to trigger much more aggressive cache eviction to prevent
285+
// filling of the tmp volume by short-lived test processes.
286+
// A single run of the gopls tests takes on the order of a minute
287+
// and produces <50MB of cache data, so these are still generous.
288+
if os.Getenv("GO_BUILDER_NAME") != "" {
289+
maxAge = 1 * time.Hour
290+
SetBudget(250 * 1e6) // 250MB
291+
}
282292

283293
// The macOS filesystem is strikingly slow, at least on some machines.
284294
// /usr/bin/find achieves only about 25,000 stats per second

0 commit comments

Comments
 (0)