ants icon indicating copy to clipboard operation
ants copied to clipboard

Performance differences between go1.13 and 1.14 and later versions

Open Keima-lpj opened this issue 2 years ago β€’ 1 comments

In the same hardware environment, I found similar results to the author's conclusion for go1.13 in my tests, but for 1.14 onwards, ants no longer has a time consumption advantage, only a memory usage advantage. Is it because version 1.14 implements signal-based scheduling? Attached are the test results, 3 million times, default pool size

1.13 go test -run="TestNoPool" -v === RUN TestNoPool --- PASS: TestNoPool (2.64s) ants_test.go:47: memory usage:1530 MB PASS ok testGo/ant 2.759s

go test -run="TestAntsPool" -v === RUN TestAntsPool --- PASS: TestAntsPool (1.55s) ants_test.go:71: pool, capacity:2147483647 ants_test.go:72: pool, running workers number:29722 ants_test.go:73: pool, free workers number:2147453925 ants_test.go:78: memory usage:73 MB PASS ok testGo/ant 1.549s

1.14 go test -run="TestNoPool" -v === RUN TestNoPool TestNoPool: ants_test.go:47: memory usage:289 MB --- PASS: TestNoPool (0.78s) PASS ok testGo/ant 0.783s

go test -run="TestAntsPool" -v === RUN TestAntsPool TestAntsPool: ants_test.go:71: pool, capacity:2147483647 TestAntsPool: ants_test.go:72: pool, running workers number:27475 TestAntsPool: ants_test.go:73: pool, free workers number:2147456172 TestAntsPool: ants_test.go:78: memory usage:71 MB --- PASS: TestAntsPool (1.38s) PASS ok testGo/ant 1.385s

Keima-lpj avatar May 31 '22 13:05 Keima-lpj

I did the same tests where the golang environment is 1.18. It is easy to see go func() directly faster than using ants pool.So I also think goroutine pool can only save memory usage currently, not improvement in time.

Professor-Jiang avatar Aug 01 '22 10:08 Professor-Jiang

Agree with OP. One more thing, the memory usage advantage is not too much, that we could ignore because it runs 1m times in each b.N loop: https://github.com/panjf2000/ants/blob/master/ants_benchmark_test.go#L33

jansen191024 avatar Oct 16 '22 07:10 jansen191024

duplicate #123

panjf2000 avatar Mar 03 '23 09:03 panjf2000