Files
go-omni/PERFORMANCE.md

23 lines
1.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# GoOmni 性能基线
这份基线用于比较未来自研网络层,不代表生产容量承诺。标准库 benchmark 测进程内请求分发;native benchmark 额外覆盖真实 TCP、Keep-Alive 和 GoOmni 请求链,但不包含 TLS、数据库或业务存储延迟。
运行:
```sh
python3 scripts/verifyPerformance.py
```
本次记录环境:Go 1.25.0、darwin/arm64、Apple M2 Max;每项连续运行 3 次:
```text
BenchmarkTransportRouteDispatch/nethttp 568–671 ns/op 1344 B/op 13 allocs/op
BenchmarkTransportApplicationRequest/nethttp 2017–2208 ns/op 3091 B/op 34 allocs/op
BenchmarkNativeApplicationRequest 15438–16711 ns/op 7855–7874 B/op 100 allocs/op
```
`BenchmarkTransportRouteDispatch` 只覆盖标准库路由、路径参数和 `http.Handler` 调用;`BenchmarkTransportApplicationRequest` 还包含 GoOmni Context、RequestID、统一 JSON 响应和默认中间件链。
`BenchmarkNativeApplicationRequest` 启动 native TCP listener,通过复用连接的 HTTP client 并发请求健康接口,包含 socket、请求解析、连接状态管理、响应写回和对象池路径。它用于观察网络层的相对变化,不应直接换算为生产 QPS。
比较新网络层时,应使用相同 Go 版本、机器和 benchmark 命令,并同时运行 `-race` 全量测试。性能下降需要结合分配次数、取消传播、错误响应和业务契约结果一起判断。