Skip to content

Commit 743372f

Browse files
findleyrgopherbot
authored andcommitted
gopls/internal/lsp/debug: limit to 100 recent trace entries
Before this CL, we would keep traces for up to a minute, even if we exceeded the maximum number of recent traces. This could lead to an unusable trace debug page, as traces can be very chatty during large operations. Change the condition to enforce a strict limit on the number of traces to keep, and remove age-based eviction. Change-Id: Ie9b44e2c5ef236c3e23e3eb21b7eb55da74295da Reviewed-on: https://go-review.googlesource.com/c/tools/+/495259 Reviewed-by: Alan Donovan <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Run-TryBot: Robert Findley <[email protected]> Auto-Submit: Robert Findley <[email protected]>
1 parent 522243a commit 743372f

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

gopls/internal/lsp/debug/trace.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -259,13 +259,10 @@ func (t *traces) ProcessEvent(ctx context.Context, ev core.Event, lm label.Map)
259259
// addRecentLocked appends a start or end event to the "recent" log,
260260
// evicting an old entry if necessary.
261261
func (t *traces) addRecentLocked(span *traceSpan, start bool) {
262-
const (
263-
maxRecent = 100 // number of log entries before age-based eviction
264-
maxAge = 1 * time.Minute
265-
)
266262
t.recent = append(t.recent, spanStartEnd{Start: start, Span: span})
267263

268-
for len(t.recent) > maxRecent && t.recent[0].Time().Before(time.Now().Add(-maxAge)) {
264+
const maxRecent = 100 // number of log entries before eviction
265+
for len(t.recent) > maxRecent {
269266
t.recent[0] = spanStartEnd{} // aid GC
270267
t.recent = t.recent[1:]
271268
t.recentEvictions++

0 commit comments

Comments
 (0)