276 points · by dmit · 9y ago · 43 comments
Wow, I didn't know this. Anyone knows for which programs they use Haskell? The article doesn't say anything.
This might be it, don't have time to verify right now: http://cufp.org/2015/fighting-spam-with-haskell-at-facebook....
Video: https://www.youtube.com/watch?v=IOEGfnjh92o
Abstract: http://cufp.org/2015/fighting-spam-with-haskell-at-facebook....
I'd be curious to find out if the success FB has had with Haskell for spam filtering means they might consider Haskell for different parts of their stack too? Does anyone have any insight on this?
Ah, yes. As a Go developer, really wish Go moved to an 1:1 threading model.
(I believe the story is slightly different in Haskell.)
Nice sequential blocking-style code is my favorite thing about Go. I realize it's not C, and it makes runtime work much harder, but the payoff up in complex servers is completely worth it.
No, it would not mean such a thing at all. Where did you get this idea?
In fact, on some operating systems/linker combinations, gccgo uses a 1:1 threading model.
> Nice sequential blocking-style code is my favorite thing about Go.
Mine too.
A typical server under load has more outstanding requests to answer than it can OS threads. It is not uncommon in a Go server at Google to find a million or so goroutines.
If you want to have an OS thread that can also run C code, it needs a large enough stack to run C code. A million such stacks is not practical.
On an OS that lets you avoid creating stacks with threads like Linux, and which has quite light-weight kernel-side accounting for threads, it would be possible to give each goroutine a thread. You would still need an N:M pool for cgo.
As an added problem, 1:1 is slower for certain kinds of common channel operations. Anywhere you have an unbuffered channel and block waiting for a value, a 1:1 model requires a context switch to pass the value, whereas M:N means the userland scheduler can switch goroutines on the OS thread.
It is precisely these benchmarks that led Ian to implement M:N in gccgo. If there are combinations where it is 1:1, that is either a new decision he has made in the last year, or (more likely) OS/ARCH combinations that he hasn't moved to M:N yet.
I have seen a similar attempt at 1:1 lightweight tasks in C++ that ran into this. Without the ability to preemptively move tasks between OS threads, it ran into performance problems. Programs that needed the speed in that model had to switch to a futures-style of programming.
Haskell would lose more features, but also its "blocking-style" syntax (that is based on callbacks, but nobody ever thinks about it this way).
There is a reason POSIX threading is implemented in the kernel on every operating system, even if they all started as N:M or 1:M implementations.
Because it's already there and it already works just fine.
It's so frustrating to see this sort of comment on nearly every post about a language outside the mainstream. It's a religious argument and not a productive one.
Well clearly it didn't work just fine if its threading model was interacting poorly with that of their Haskell code. If there's a mismatch between those two components then that will continue to bite them in the future, and it's legitimate to ask whether moving the boundary would be a better way to solve the problem.
When they realized the bug the path forward probably seemed like patching and not a Haskell re-write, and that's a reasonable mistake to make.
They seemed to have succeeded in creating a culture of coders/hackers that were opinionated/empowered sufficiently to use their tool of choice, and to persuade others of the advantages.
This doesn't really happen in large-cap companies (though does happen to empowered teams, but even then, only somewhat - thinking finance). And speaks to advantages.