feat(event pool): simplify realization of event pool
Description
I have managed to improve the performance of the pool and improve its readability
Benchmarks
Old
BenchmarkEventPoolOneGoroutine-8 58460538 19.96 ns/op 0 B/op 0 allocs/op
BenchmarkEventPoolManyGoroutines-8 100 10746244 ns/op 4986 B/op 56 allocs/op
BenchmarkEventPoolSlowestPath-8 152 8189235 ns/op 27087 B/op 1034 allocs/op
New
BenchmarkEventPoolOneGoroutine-8 39543708 32.61 ns/op 0 B/op 0 allocs/op
BenchmarkEventPoolManyGoroutines-8 697 1724738 ns/op 876 B/op 15 allocs/op
BenchmarkEventPoolSlowestPath-8 1026 1038654 ns/op 24619 B/op 1007 allocs/op
@kirillov6 @goshansmails please review!
btw, i've tested realisation based on sync.Pool, it was too much faster than my new realisation, but the possibility of event dump was lost
@ythosa, hello!
You can use BenchmarkLightJsonReadPar to check how the performance has changed. On mac m1 this bench showed following result: old:
BenchmarkLightJsonReadPar-8 1 2256751708 ns/op 643.06 MB/s 4825008 B/op 48384 allocs/op
new:
BenchmarkLightJsonReadPar-8 1 4433031459 ns/op 327.37 MB/s 4272744 B/op 42659 allocs/op
Also, we can't use sync.Pool because insaneJSON uses own global pool. So, we need to refactor insaneJSON first, then we can test sync.Pool
Wow, I haven't seen this benchmark. You are very cool...