cloudwego / cloudwego/netpoll-benchmark

Mode_Idle 用了一个写死的 50 ms timeout,建了几百个链接之后几乎全timeout了

Open
#14 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
45
Forks
11
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**

在`Mode_Idle`测量之前,客户端会依次创建 `4 * 并发数` 个额外的空闲连接。使用默认的并发值,这意味着每个子基准测试需要 400、2,000 或 4,000 个设置连接。

每个连接使用写死的 50 毫秒超时。一次短暂的超时就会立即触发 panic 并中止基准测试。这个超时不可配置,也不会尝试重试,而且设置的连接不会被显式关闭。
`runner/bench/client.go:27-43`
```go
var conns = make([]runner.Conn, 4*concurrent)
switch mod {
case runner.Mode_Idle:
// add idle conn 80%
for i := range conns {
conn, err := client.DialTimeout(network, address, dialTimeout)
if err != nil {
panic(fmt.Errorf("dial idle conn failed: %s", err.Error()))
}
conns[i] = conn
}
}
```

`runner/bench/client.go:50-60`
```go
dialTimeout time.Duration = 50 * time.Millisecond
```

**To Reproduce**
搞一个脚本启动
```bash
./scripts/build.sh

for trial in $(seq 1 20); do
echo "mode 2 trial $trial"
./scripts/benchmark_server.sh 2 || break
done
```

**behavior**

```text
panic: dial idle conn failed: dial tcp 127.0.0.1:7004: i/o timeout

goroutine 1 [running]:
github.com/cloudwego/netpoll-benchmark/runner/bench.Benching(...)
runner/bench/client.go:40
```

**Environment:**

```bash
$ go env
AR='ar'
CC='gcc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='g++'
GCCGO='gccgo'
GO111MODULE=''
GOAMD64='v1'
GOARCH='amd64'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/home/hxy/.cache/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/home/hxy/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build3082581226=/tmp/go-build -gno-record-gcc-switches'
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMOD='/dev/null'
GOMODCACHE='/home/hxy/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/hxy/go'
GOPRIVATE=''
GOPROXY='https://goproxy.cn,direct'
GOROOT='/home/hxy/app/go1.24'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/hxy/.config/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/home/hxy/app/go1.24/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.24.6'
GOWORK=''
PKG_CONFIG='pkg-config'
```

**Additional context**
当前的故障是初始化失败,而不是测量到的请求超时。把它当作实现性能结果会把机器调度和连接设置的时间与稳定状态的 Echo 工作负载混为一谈。一个可配置且可观察的设置策略可以在不改变测量模式 2 请求语义的情况下,提高跨平台的可重现性。
这个修了好久我真的。搞了好多patch。

Contributor guide

Open the contributing guide

Research direction

Start with runner/bench/client.go:27-43 and 50-60, then reproduce the setup failure with scripts/build.sh and scripts/benchmark_server.sh in Mode_Idle. Trace how idle connections are created and handled during initialization. Done means setup failures are configurable and observable without changing the Mode_Idle request workload or confusing setup failures with benchmark timeouts.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.