3 ms·
This benchmark is nonsense. Apart from the fact that Go has an average Goroutine overhead of a 4kB stack (meaning an average usage of 3.9GB for 1M tasks), the c
by bilbo-b-baggins 2y ago
This benchmark is nonsense. Apart from the fact that Go has an average Goroutine overhead of a 4kB stack (meaning an average usage of 3.9GB for 1M tasks), the code written is also in a closure, and scheduling a 2nd Goroutine in the wg.Done(), so unlike some of the others it had at least 2M function calls on the event loop stack in addition to at least 1M closure references. So yeah, it’s a great example of bad code in any language.
- neonsunset 2y agoHere's an implementation in C# that more faithfully matches what you have to do in Go: var cnt = int.Parse(args[0]); var evt = new CountdownEvent(cnt); for (var i = 0; i < cnt; i++) { async Task Execute() { await Task.Delay(TimeSpan.FromSeconds(10)); evt.Signal(); } _ = Execute(); } evt.Wait(); It ends up consuming roughly 264.5 MB on ARM64 macOS 15.1.1 (compiled with NativeAOT).