github.com/polarismesh/polaris@v1.17.8/common/timewheel/README.md (about) 1 # timewheel 2 3 为心跳上报定制实现的、线程安全的多层时间轮,简化功能以追求更好的性能。 4 5 基于链表和ticker实现。 只有插入操作:插入任务后就必须执行。 6 7 ## 测试/压测记录 8 9 覆盖率: 90%+ 10 11 1. 功能测试:正常 12 13 2. 压力测试: 16c 16g机器 14 15 开启5w个协程并发往同一个slot加10w个任务,单个操作用时280ns 16 17 ``` 18 goos: windows 19 goarch: amd64 20 pkg: github.com/polarismesh/polaris-server/common/timewheel 21 BenchmarkAddTask1-8 100000 280 ns/op 103 B/op 2 allocs/op 22 PASS 23 ``` 24 25 开启16w个协程并发往同一个slot加500w个任务,单个操作用时376ns 26 27 ``` 28 goos: windows 29 goarch: amd64 30 pkg: github.com/polarismesh/polaris-server/common/timewheel 31 BenchmarkAddTask1-8 5000000 376 ns/op 97 B/op 2 allocs/op 32 PASS 33 ``` 34 35 对比nosix/timewheel: 36 ``` 37 goos: linux 38 goarch: amd64 39 BenchmarkAddTask1-8 100000 2021 ns/op 721 B/op 3 allocs/op 40 --- BENCH: BenchmarkAddTask1-8 41 timewheel_test.go:40: N:100000, use time:255.514068ms 42 timewheel_test.go:40: N:100000, use time:324.360456ms 43 timewheel_test.go:40: N:100000, use time:402.377702ms 44 timewheel_test.go:40: N:100000, use time:419.118132ms 45 timewheel_test.go:40: N:100000, use time:195.719517ms 46 timewheel_test.go:40: N:100000, use time:215.3815ms 47 timewheel_test.go:40: N:100000, use time:176.733241ms 48 timewheel_test.go:40: N:100000, use time:188.846803ms 49 timewheel_test.go:40: N:100000, use time:164.038559ms 50 timewheel_test.go:40: N:100000, use time:200.684048ms 51 ```