Release 3.8.1.1: lighter idle UI poll, core cache, multicore ping.

Reduce idle CPU (cheap PollUI, binary cache, logbuf cap, DOM fingerprint),
speed ping/AWG HostPort, CopyBuffer pool; ship arm64 build and update notes.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
M4
2026-07-30 02:27:17 +03:00
co-authored by Cursor
parent bec6c8392d
commit 6b6c13c933
29 changed files with 559 additions and 100 deletions
+59
View File
@@ -0,0 +1,59 @@
package logbuf
import (
"bytes"
"sync"
)
const DefaultMax = 256 << 10 // 256 KiB
// Buffer is a concurrency-safe, size-capped bytes.Buffer replacement for engine stderr.
type Buffer struct {
mu sync.Mutex
buf bytes.Buffer
max int
}
func New(max int) *Buffer {
if max <= 0 {
max = DefaultMax
}
return &Buffer{max: max}
}
func (b *Buffer) Write(p []byte) (int, error) {
if b == nil {
return len(p), nil
}
b.mu.Lock()
defer b.mu.Unlock()
if b.buf.Len()+len(p) > b.max {
// Drop oldest half to keep recent diagnostics.
keep := b.buf.Bytes()
if len(keep) > b.max/2 {
keep = keep[len(keep)-b.max/2:]
}
b.buf.Reset()
_, _ = b.buf.Write(keep)
_, _ = b.buf.WriteString("\n… log truncated …\n")
}
return b.buf.Write(p)
}
func (b *Buffer) String() string {
if b == nil {
return ""
}
b.mu.Lock()
defer b.mu.Unlock()
return b.buf.String()
}
func (b *Buffer) Len() int {
if b == nil {
return 0
}
b.mu.Lock()
defer b.mu.Unlock()
return b.buf.Len()
}
+29
View File
@@ -0,0 +1,29 @@
package logbuf
import (
"strings"
"sync"
"testing"
)
func TestBufferConcurrentWriteAndCap(t *testing.T) {
b := New(64)
var wg sync.WaitGroup
for i := 0; i < 8; i++ {
wg.Add(1)
go func() {
defer wg.Done()
for j := 0; j < 40; j++ {
_, _ = b.Write([]byte("abcdefghij"))
}
}()
}
wg.Wait()
if b.Len() > 64+40 { // allow truncate marker overhead
t.Fatalf("len=%d exceeds soft cap", b.Len())
}
s := b.String()
if !strings.Contains(s, "abcdefghij") && !strings.Contains(s, "truncated") {
t.Fatalf("unexpected content %q", s)
}
}