NodeJS does what it was designed to do well.
How much memory do you need in 2024 to run 1M concurrent tasks?
21–30 of 205 posts
Re: How much memory do you need in 2024 to run 1M concurrent tasks?
#22I feel this benchmark compares apples to oranges in some cases. For example, for node, the author puts a million promises into the runtime event loop and uses `Promise.all` to wait for them all. This is very different from, say, the Go version where the author creates a million goroutines and puts `waitgroup.Done` as a defer call. While this might be the idiomatic way of concurrency in the respective languages, it do…
But I do think that spawning a goroutine just to do a non-blocking task and get its return is kinda wasteful.
Re: How much memory do you need in 2024 to run 1M concurrent tasks?
#23Re: How much memory do you need in 2024 to run 1M concurrent tasks?
#24Earlier quoted context omitted.
I'd expect that because Promises are small Javascript objects while goroutines each get a stack that grows from at least 2 KB.
Otoh Go actually supports concurrency.
Re: How much memory do you need in 2024 to run 1M concurrent tasks?
#25Why C with pthreads missing in this benchmark ?
Re: How much memory do you need in 2024 to run 1M concurrent tasks?
#26Yet again nodejs surpasses my pre-read expectations 3rd best (generalized) for a million? Wow. I must be missing something - isn’t Go supposed to be memory efficient? Perhaps promises and goroutines aren’t comparable?
I'm not sure what "memory efficient" means. But, Go sprung as a competitor to Java (portability, language stability, corporate language support/development) and C++ (faster compile times). Can't beat C++ in terms of memory management (performance, guys, not safety) much. But, you can fare well against the JVM, I'm guessing.
This probably doesn't matter in the real world as you will actually use the tasks to do some real work which should really dwarf the static overhead is almost all cases.
Re: How much memory do you need in 2024 to run 1M concurrent tasks?
#27Re: How much memory do you need in 2024 to run 1M concurrent tasks?
#28Note 1: The gist is in Ukrainian, and the blog post by Steve does a much better job, but hopefully you will find this useful. Feel free to replicate the results and post them.
Note 2: The absolute numbers do not necessarily imply good/bad. Both Go and BEAM focus on userspace scheduling and its fairness. Stackful coroutines have their own advantages. I think where the blog post's data is most relevant is understanding the advantages of stackless coroutines when it comes to "highly granular" concurrency - dispatching concurrent requests, fanning out to process many small items at once, etc. In any case, I did not expect sibling comments to go onto praising Node.js, is it really that surprising for event loop based concurrency? :)
Also, if you are an Elixir aficionado and were impressed by C#'s numbers - know that they translate ~1:1 to F# now that it has task CE, just sayin'.
Here's how the program looks in F#:
open System
open System.Threading.Tasks
let argv = Environment.GetCommandLineArgs()
[1..int argv[1]]
|> Seq.map (fun _ -> Task.Delay(TimeSpan.FromSeconds 10.0))
|> Task.WaitAllRe: How much memory do you need in 2024 to run 1M concurrent tasks?
#29Re: How much memory do you need in 2024 to run 1M concurrent tasks?
#30Souce: https://github.com/microsoft/referencesource/blob/master/msc...