blob: 8cdbcfe539936ec108203ab961ca1a7d9778ccd9 [file] [log] [blame]
// Copyright 2020 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package bench
import (
. ""
// Pilosa is a repository that has historically caused significant memory
// problems for Gopls. We use it for a simple stress test that types
// arbitrarily in a file with lots of dependents.
var pilosaPath = flag.String("pilosa_path", "", "Path to a directory containing "+
", for stress testing. Do not set this unless you "+
"know what you're doing!")
func stressTestOptions(dir string) []RunOption {
return []RunOption{
// Run in an existing directory, since we're trying to simulate known cases
// that cause gopls memory problems.
// Enable live debugging.
// Skip logs as they buffer up memory unnaturally.
// Similarly to logs: disable hooks so that they don't affect performance.
// The Debug server only makes sense if running in singleton mode.
// Set a generous timeout. Individual tests should control their own
// graceful termination.
Timeout(20 * time.Minute),
// Use the actual proxy, since we want our builds to succeed.
func TestPilosaStress(t *testing.T) {
if *pilosaPath == "" {
t.Skip("-pilosa_path not configured")
opts := stressTestOptions(*pilosaPath)
WithOptions(opts...).Run(t, "", func(t *testing.T, env *Env) {
files := []string{
for _, file := range files {
ctx, cancel := context.WithTimeout(env.Ctx, 10*time.Minute)
defer cancel()
i := 1
// MagicNumber is an identifier that occurs in roaring.go. Just change it
// arbitrarily.
env.RegexpReplace("roaring/roaring.go", "MagicNumber", fmt.Sprintf("MagicNumber%d", 1))
for {
select {
case <-ctx.Done():
env.RegexpReplace("roaring/roaring.go", fmt.Sprintf("MagicNumber%d", i), fmt.Sprintf("MagicNumber%d", i+1))
time.Sleep(20 * time.Millisecond)