refactor(security): 调整分段锁桶字段顺序优化内存布局

将 counters 字段置于 mu 锁之前,符合 Go 结构体字段排序最佳实践,
数据字段优先于锁字段,可能优化内存访问效率。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
xfy 2026-04-14 14:53:21 +08:00
parent 686b8c3239
commit cdc767160b

View File

@ -22,8 +22,8 @@ import (
// limiterBucket 分段锁桶,每个桶持有部分键的计数器。
// 使用分段锁减少全局锁竞争,提高并发性能。
type limiterBucket struct {
mu sync.RWMutex
counters map[string]*windowCounter
mu sync.RWMutex
}
// SlidingWindowLimiter 滑动窗口限流器。