性能优化: 热路径零分配, 自适应池CAS无锁化, 锁外计算

- port_scan: fmt.Sprintf→JoinHostPort+fmtPort零分配地址格式化 (2.5x)
- port_scan: strings.ToLower→containsFold零分配大小写不敏感匹配 (2.5x)
- port_scan: slidingWindowSchedule修复semaphore泄漏bug
- service_probe: readFromConn预分配4KB缓冲区消除扩容
- adaptive_pool: maybeAdjust用atomic CAS代替持锁检查, 99%免锁
- adaptive_timeout: Timeout锁外计算均值/标准差, 只锁缓存更新
- 新增perf_bench_test.go基准测试验证所有优化
This commit is contained in:
ZacharyZcR
2026-05-18 06:11:10 +08:00
parent 639298b7c8
commit 7063027acf
6 changed files with 226 additions and 44 deletions
+5
View File
@@ -607,6 +607,11 @@ func readFromConn(conn net.Conn) ([]byte, error) {
var result []byte
// 预分配 4KB,消除大部分服务 Banner 场景下的 append 扩容
if cap(buf) > 0 {
result = make([]byte, 0, 4096)
}
for {
count, err := conn.Read(buf)