Re:Memory usage of a toy C# server and client with 500K conc...
by zzzcpan on Saturday January 26, 2019 @05:52PM
(#19009085)
I don't think anyone would enjoy going back to goroutines (threads) after async/await. Multithreaded code is actually much harder to write and deal with. Go is inappropriate example here.
[ Parent
| on HN ]
Re:Memory usage of a toy C# server and client with 500K conc...
by WoodenChair on Saturday January 26, 2019 @07:22PM
(#19009499)
Goroutines are not threads:
https://rcoh.me/posts/why-you-can-have-a-million-go-routines...
Re:Memory usage of a toy C# server and client with 500K conc...
by giancarlostoro on Saturday January 26, 2019 @07:56PM
(#19009659)
Goroutines are probably closer to Fibers which D also has:
Re:Memory usage of a toy C# server and client with 500K conc...
by zzzcpan on Saturday January 26, 2019 @08:15PM
(#19009770)
They used to be closer to fibers years ago, when they were running on a single thread by default. Now they behave exactly like normal threads with the same problems. And fibers are threads anyway.
Re:Memory usage of a toy C# server and client with 500K conc...
by giancarlostoro on Saturday January 26, 2019 @10:11PM
(#19010151)
Care to share a reference to them no longer being lightweight?
Re:Memory usage of a toy C# server and client with 500K conc...
by zzzcpan on Sunday January 27, 2019 @01:11PM
(#19012893)
They still start with tiny stacks, if that's what you are asking. I believe it's somewhere around 2 KB nowadays.
Re:Memory usage of a toy C# server and client with 500K conc...
by hu3 on Sunday January 27, 2019 @06:37AM
(#19011341)
goroutines are anything but threads.
Here's a 40min talk explaining how Go's scheduler works:
Re:Memory usage of a toy C# server and client with 500K conc...
by zzzcpan on Sunday January 27, 2019 @01:05PM
(#19012860)
No, they are threads. It doesn't matter if they start with tiny growing stacks and whether blocking syscall wrappers call into the scheduler. Those are just implementation details.
Re:Memory usage of a toy C# server and client with 500K conc...
by Groxx on Tuesday January 29, 2019 @07:01PM
(#19031204)
I mean, sure, but they have all the same problems as threads for most / application-level developers. They're indeed quite different when you get into calling out to C or other kinds of FFI, but relatively few developers need to do so directly. For everyone else, they come with very nearly exactly the same semantics as threads.
Re:Memory usage of a toy C# server and client with 500K conc...
by tiuPapa on Sunday January 27, 2019 @12:06AM
(#19010427)
I have used both and its hard to argue that goroutines and channels are as easy to use as async/await.
Re:Memory usage of a toy C# server and client with 500K conc...
by weberc2 on Monday January 28, 2019 @09:36AM
(#19017661)
On the surface, perhaps, but when you factor in the gotchas of both approaches and the debugging difficulty, I much prefer goroutines. In particular, I’ve never witnessed someone DOS a fleet of servers in Go by scheduling a task was making a sync call under the covers, by doing an intensive computation in the event loop, or by scheduling tens of thousands of tiny events. We also have a lot of bugs involving accidentally putting the task/coroutine into a variable instead of the result of the task because the programmer forgot the “await” keyword, but that’s a dynamic typing problem.
Re:Memory usage of a toy C# server and client with 500K conc...
by tigershark on Sunday January 27, 2019 @03:00AM
(#19010823)
Goroutines are not threads.
Async await behind the scenes uses threads.
Re:Memory usage of a toy C# server and client with 500K conc...
by tigershark on Sunday January 27, 2019 @04:02AM
(#19010981)
In that case and in some others it doesn’t, but in general it does:
https://stackoverflow.com/questions/17661428/async-stay-on-t...
Probably it makes sense to say that async await can try to use a continuation passing style or run on a different thread because there is no actual guarantee that it will use one or the other.