Leadaxe:sing-box-lx 修复 Windows 时钟精度导致的轮询自愈事件排序问题
Leadaxe 表示,lx 分支提交 592f734e6 为 round_robin 自愈事件引入严格递增的 rrNow 时间标记,避免 Windows 同一时钟刻度内的事件被判为同时发生,影响连接迁移或额外轮次判断。他称已在 macOS 上以 15.625 毫秒量化时钟模拟并验证修复,仍请求 Windows 复测,且模拟与报告中的一处标签差异尚未解释。
作者原文@LeadaxeFollow-up on the two Windows RR tests: confirmed and fixed in 592f734e6 on
lx. This replaces "not changed" in my previous comment.Cause. Go's monotonic clock on Windows reads the interrupt time and advances in ticks of up to 15.6 ms. The
round_robinself-heal rules order events by their moments (a pick, a probe's start and end, the end of a round, the freeze end) with<=,>=and<, and they are written for a clock that tells two events apart. Within one tick:
TestRRAlgo_10: the second connection started right after the first one's outcome tied with it, so K2 saw "the same attempt" (a <= first.b1inrrK2Table.sign) and the key never shifted.TestRRStand9: a pick made before the round's end tied with it, so W5 (grantExtra) took it as a pick made in the pause and gave an extra round.Fix. Event moments now come from
rrNow:time.Now, moved forward by a nanosecond when needed, so every mark is later than the previous one and the real order of events breaks the tie. The rules themselves are unchanged. On a nanosecond clock behaviour is identical, and durations shift by nanoseconds at most. Against URL test history written elsewhere in sing-box, a mark decides as the tie did; the one moment where a tie meant "newer" (rrBatch.start) stays ontime.Now. Tests take their moments fromrrNowtoo.Evidence without a Windows host. With
rrNowquantized to 15.625 ms on macOS, both tests fail 5/5 without the tie-break (with and withoutwith_lx_impair) and pass with it. On normal clocks the fullprotocol/grouppackage passes under-race, with and withoutwith_lx_impair. One difference from your report: in our simulationTestRRStand9failed without the tag as well. We have not explained that difference.Could you rerun on Windows against current
lx?go test ./protocol/group -run '^(TestRRAlgo_10_secondSoftSignShifts|TestRRStand9_searchPickGivesNoExtraRound)$' -count=5 go test -tags with_lx_impair ./protocol/group -run '^TestRRStand9_searchPickGivesNoExtraRound$' -count=5 go test -tags with_lx_command,with_xhttp ./transport/v2rayxhttp -run '^TestTransportStage_LX$' -count=20