mirror of
https://github.com/shadow1ng/fscan.git
synced 2026-09-26 05:01:53 +08:00
性能优化: 热路径零分配, 自适应池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:
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user