log_buffer: cap the shared-snapshot race test's heap (#10281)

TestSharedSnapshotConcurrentIntegrity writes as fast as one core can
marshal for two seconds, so its transient heap scales with host speed.
On linux/386 a fast runner walks the heap into the 4GB address-space
ceiling and the run dies with out of memory. Set a 1GB memory limit for
the duration of the test so the GC paces the writer instead of the
address space; the seal-and-recycle race being tested is unaffected.
This commit is contained in:
Chris Lu
2026-07-09 00:29:17 -07:00
committed by GitHub
parent 399f8033f8
commit fd5a6ff427
@@ -2,6 +2,7 @@ package log_buffer
import (
"fmt"
"runtime/debug"
"sync"
"testing"
"time"
@@ -85,6 +86,12 @@ func TestSharedSnapshotSurvivesRecycle(t *testing.T) {
// and recycling windows. Every delivered entry must unmarshal cleanly with the
// expected payload — corruption here means a reader saw recycled bytes.
func TestSharedSnapshotConcurrentIntegrity(t *testing.T) {
// The writer below is deliberately unthrottled, so transient marshal garbage
// scales with host speed; on linux/386 a fast runner can hit the 4GB
// address-space ceiling. Cap the heap so the GC paces the writer instead.
prevLimit := debug.SetMemoryLimit(1 << 30)
defer debug.SetMemoryLimit(prevLimit)
lb := NewLogBuffer("test", time.Hour, func(*LogBuffer, time.Time, time.Time, []byte, int64, int64) {}, nil, nil)
defer lb.ShutdownLogBuffer()