News for hackers. Stuff that matters.
Re:Evio – Fast event-loop networking for Go by hannofcart on Saturday November 04, 2017 @11:17AM (#15625394)
<quote>That is, I can write simple blocking code, and my server still scales. Using event loop programming in Go would take away one of my favorite things about the language, so I won't be using this.</quote>

If Go has or can emulate 'generators' a-la Python/Nodejs,then you can write synchronous looking,blocking-like code with event loops as well.

Re:Evio – Fast event-loop networking for Go by giovannibajo1 on Saturday November 04, 2017 @12:30PM (#15625742)
That is exactly what Go does by default. Any time a blocking operation is performed, Go either leaves the OS-level thread blocked there and switches away, or hand the blocking operation to an internal thread which is running epoll for the whole process.

The end result is much easier than Python/NodeJs because there is no explicit "async/await" or deferred-style programming. You simply write linear code and any blocking operation (at the syscall level) is transparently handled.

Re:Evio – Fast event-loop networking for Go by hannofcart on Saturday November 04, 2017 @02:43PM (#15626326)
Thanks for taking the time to write this response. The more I hear about Go's features, the more I seem to like it.
Re:Evio – Fast event-loop networking for Go by wyager on Saturday November 04, 2017 @04:07PM (#15626655)
FYI, this is not unique to Go. A number of languages implement lightweight threads in the same way (roughly), like erlang or Haskell. It’s all epoll or other efficient polling primitives under the hood.
Re:Evio – Fast event-loop networking for Go by weberc2 on Saturday November 04, 2017 @08:57PM (#15627637)
I'm of the impression that there's an important difference between Go and Haskell's models--namely that Go is M:N threaded and Haskell is not; however, I don't entirely understand the significance of the difference, so hopefully someone else can comment and enlighten me.
Re:Evio – Fast event-loop networking for Go by joel_ms on Sunday November 05, 2017 @02:20AM (#15628514)
Are you sure about Haskell not having m:n threads? Because it's seems weird, considering GHC is listed as one of a few examples on wikipedia: https://en.m.wikipedia.org/wiki/Thread_(computing)#M:N_.28hy...
Re:Evio – Fast event-loop networking for Go by weberc2 on Sunday November 05, 2017 @09:07AM (#15629429)
No, I'm not sure. :) I may have incorrectly assumed that the definition of M:N threads includes movable application threads (e.g., Go's scheduler can move goroutines from one kernel thread to another).
Re:Evio – Fast event-loop networking for Go by pcwalton on Saturday November 04, 2017 @04:09PM (#15626668)
In other words, Go uses threads.

There's nothing semantically unique to Go about this model.

Re:Evio – Fast event-loop networking for Go by giovannibajo1 on Saturday November 04, 2017 @06:17PM (#15627171)
It depends if you're describing a semantic model or you're concerned about implementation details.

Semantically, a goroutine is a thread, within a shared memory model. But what makes Go unique (or let's say more unique) is that it offers programmers a thread-like programming approach (linear, blocking code) but internally turns it into an event-driven approach (epoll/kqueue) for networking.

Moreover, the fact that goroutines are much cheaper than OS-level threads enable a more pervasive approach to concurrency.

Re:Evio – Fast event-loop networking for Go by cdoxsey on Saturday November 04, 2017 @04:22PM (#15626724)
Go uses an m:n thread model. Goroutines are multiplexed onto a smaller number of os-level threads. They're sort of like threads, but they have a simplified programming model (There is no thread-level storage for example).
Re:Evio – Fast event-loop networking for Go by pcwalton on Saturday November 04, 2017 @04:23PM (#15626729)
Goroutines are threads. They're just not kernel-level threads.

There have been implementations of pthreads that used an M:N model, for instance.

Re:Evio – Fast event-loop networking for Go by weberc2 on Saturday November 04, 2017 @09:00PM (#15627643)
For my information, why is M:N so successful for Go and not for pthreads? Is M:N more practical for systems with a particular kind of garbage collector?
Re:Evio – Fast event-loop networking for Go by pcwalton on Sunday November 05, 2017 @12:06PM (#15630292)
In my opinion, it's because the Go team put a ton of effort into getting M:N working and didn't rigorously evaluate any other alternatives in Go, once moving GC was implemented.

I'm not convinced that 1:1 wouldn't have been a perfectly reasonable implementation strategy for Go.

Re:Evio – Fast event-loop networking for Go by weberc2 on Sunday November 05, 2017 @02:33PM (#15631117)
This is surprising. It seems like Go gets pretty high praise from all over for its threading model, and it seems like there are relatively few high-performance servers that are built with 1:1. Am I wrong about that? If not, what explains this?