perf: 优化负载感知调度的准确性和响应速度

基于 Codex 审查建议的性能优化。

负载批量查询优化:
- getAccountsLoadBatchScript 添加过期槽位清理
- 使用 ZREMRANGEBYSCORE 在计数前清理过期条目
- 防止过期槽位导致负载率计算偏高
- 提升负载感知调度的准确性

等待循环优化:
- waitForSlotWithPingTimeout 添加立即获取尝试
- 避免不必要的 initialBackoff 延迟
- 低负载场景下减少响应延迟

测试改进:
- 取消跳过 TestGetAccountsLoadBatch 集成测试
- 过期槽位清理应该修复了 CI 中的计数问题

影响:
- 更准确的负载感知调度决策
- 更快的槽位获取响应
- 更好的测试覆盖率
This commit is contained in:
ianshaw
2026-01-01 19:47:35 -08:00
parent 681a357e07
commit b8779764b5
3 changed files with 26 additions and 3 deletions

View File

@@ -275,7 +275,6 @@ func (s *ConcurrencyCacheSuite) TestGetUserConcurrency_Missing() {
}
func (s *ConcurrencyCacheSuite) TestGetAccountsLoadBatch() {
s.T().Skip("TODO: Fix this test - CurrentConcurrency returns 0 instead of expected value in CI")
// Setup: Create accounts with different load states
account1 := int64(100)
account2 := int64(101)