1 // Copyright 2020 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
15 // Pilosa is a repository that has historically caused significant memory
16 // problems for Gopls. We use it for a simple stress test that types
17 // arbitrarily in a file with lots of dependents.
19 var pilosaPath = flag.String("pilosa_path", "", "Path to a directory containing "+
20 "github.com/pilosa/pilosa, for stress testing. Do not set this unless you "+
21 "know what you're doing!")
23 func stressTestOptions(dir string) []RunOption {
25 // Run in an existing directory, since we're trying to simulate known cases
26 // that cause gopls memory problems.
29 // Enable live debugging.
30 WithDebugAddress(":8087"),
32 // Skip logs as they buffer up memory unnaturally.
34 // Similarly to logs: disable hooks so that they don't affect performance.
36 // The Debug server only makes sense if running in singleton mode.
38 // Set a generous timeout. Individual tests should control their own
39 // graceful termination.
40 WithTimeout(20 * time.Minute),
42 // Use the actual proxy, since we want our builds to succeed.
43 WithGOPROXY("https://proxy.golang.org"),
47 func TestPilosaStress(t *testing.T) {
48 if *pilosaPath == "" {
49 t.Skip("-pilosa_path not configured")
51 opts := stressTestOptions(*pilosaPath)
53 withOptions(opts...).run(t, "", func(t *testing.T, env *Env) {
56 "internal/private.pb.go",
58 "roaring/roaring_internal_test.go",
59 "server/handler_test.go",
61 for _, file := range files {
64 ctx, cancel := context.WithTimeout(env.Ctx, 10*time.Minute)
68 // MagicNumber is an identifier that occurs in roaring.go. Just change it
70 env.RegexpReplace("roaring/roaring.go", "MagicNumber", fmt.Sprintf("MagicNumber%d", 1))
77 env.RegexpReplace("roaring/roaring.go", fmt.Sprintf("MagicNumber%d", i), fmt.Sprintf("MagicNumber%d", i+1))
78 time.Sleep(20 * time.Millisecond)