News for hackers. Stuff that matters.
Re:No More Callbacks: 10,000 Actors, 10,000 Threads, 10,000 ... by ChuckMcM on Wednesday October 16, 2013 @01:01PM (#6560760)
Nice exemplar. Back when Java was being created, James Gosling was pretty insistent that concurrency be lightweight and scalable. When I ported it from SunOS 4 so Solaris 2.0 I had to move from the really light weight setjump()/longjmp() threads that he had implemented, into the thread system that Solaris had defined. There was a huge negative impact on performance (as I recall about 15x slower). That sucked because one of the coolest demos at the time had a little world in it where 'Fang' (the Java mascot) lived and a bunch of things in that world were all animated with threads. Looking at the 'fiber' model for threads I think they are much closer to what we should have done in the first place.

The thought was to have a billion threads on a SPARCStation 10 (that is like an old Pentium machine now). We never got close but it was a great goal. Definitely going to have to go back and revisit this topic now. Thanks for the excellent demo to play with!

Re:No More Callbacks: 10,000 Actors, 10,000 Threads, 10,000 ... by rdtsc on Wednesday October 16, 2013 @01:14PM (#6560817)
I got to about 500K processes on Erlang's VM on an i7 with lots of memory.

These people people got up to 2M concurrent TCP connections

http://blog.whatsapp.com/index.php/2012/01/1-million-is-so-2...

And on top of it, it is using isolated heaps. That is beautiful I think. Completely concurrent GC is beautiful.

I know Erlang syntax is not to for everyone's taste (I do like it though). There is also Elixir (http://elixir-lang.org/). But the underlying BEAM VM is an awesome piece of technology.

> The thought was to have a billion threads on a SPARCStation 10

There are some green-thread C libraries I've been playing with, like Protothreads ( http://dunkels.com/adam/pt/index.html ) and libconcurrency ( https://code.google.com/p/libconcurrency/ ) I think they use setjump/longjump trick. Some use setcontext()/getcontext() POSIX call.

I still like Erlang VM best.

Re:No More Callbacks: 10,000 Actors, 10,000 Threads, 10,000 ... by kerneis on Wednesday October 16, 2013 @06:33PM (#6562506)
> There are some green-thread C libraries

Shameless plug for CPC, a compiler translating green-threads to event-driven code: http://gabriel.kerneis.info/software/cpc/

Used to compile coroutines in QEMU during the latest GSoC: http://gabriel.kerneis.info/research/files/qemu-cpc.pdf

Re:No More Callbacks: 10,000 Actors, 10,000 Threads, 10,000 ... by reginaldjcooper on Thursday October 17, 2013 @12:39AM (#6563710)
Curse you; you added five papers to my already-full reading list :)
Re:No More Callbacks: 10,000 Actors, 10,000 Threads, 10,000 ... by jzelinskie on Wednesday October 16, 2013 @02:57PM (#6561425)
After you've been writing a bit of Erlang, you find yourself always putting a "." at the end of lines in other language's interpreters.

I actually really like Erlang and would love to get more familiar with it, but there are very few small projects that are suited to Erlang's domain.

Re:No More Callbacks: 10,000 Actors, 10,000 Threads, 10,000 ... by SkyMarshal on Wednesday October 16, 2013 @03:33PM (#6561637)
One option is to port your personal site/blog to Zotonic CMS and play around with that.
Re:No More Callbacks: 10,000 Actors, 10,000 Threads, 10,000 ... by lucaspiller on Thursday October 17, 2013 @10:02AM (#6565360)
Or your favourite library from another language, Erlang is quite lacking in that regard. I had a go at porting RSpec:

https://github.com/lucaspiller/espec

Re:No More Callbacks: 10,000 Actors, 10,000 Threads, 10,000 ... by imperialWicket on Friday October 18, 2013 @05:25PM (#6574105)
ChicagoBoss offers a pretty low barrier for entry as well.
Re:No More Callbacks: 10,000 Actors, 10,000 Threads, 10,000 ... by knewter on Wednesday October 16, 2013 @07:50PM (#6562802)
I love Erlang. I've been learning elixir and am recording screen casts at http://elixirsips.com. it's so good for concurrency.
Re:No More Callbacks: 10,000 Actors, 10,000 Threads, 10,000 ... by pron on Wednesday October 16, 2013 @06:10PM (#6562419)
BTW, the only reason the demo runs 10K or a few 10Ks of actors is because this simulation is very much CPU-bound, and no matter how you schedule tasks – you can't create more CPU power in software. In less computation intensive scenarios, Quasar supports millions of actors.
Re:No More Callbacks: 10,000 Actors, 10,000 Threads, 10,000 ... by HowardMei on Wednesday October 16, 2013 @01:47PM (#6561017)
Erlang is really good, especially for engineers with hardware background, who may find FP & Message Passing are more intuitive than OOP & Context Switching.

But it's quite difficult to hire.

Re:No More Callbacks: 10,000 Actors, 10,000 Threads, 10,000 ... by mpweiher on Wednesday October 16, 2013 @05:57PM (#6562367)
"FP & Message Passing are more intuitive than OOP & Context Switching."

Huh? OOP & Message Passing!

http://lists.squeakfoundation.org/pipermail/squeak-dev/1998-...

Re:No More Callbacks: 10,000 Actors, 10,000 Threads, 10,000 ... by reginaldjcooper on Wednesday October 16, 2013 @02:25PM (#6561259)
Difficult as in you are looking for Erlangers but cannot find them? I haven't seen many postings looking for Erlang programmers.
Re:No More Callbacks: 10,000 Actors, 10,000 Threads, 10,000 ... by yapcguy on Wednesday October 16, 2013 @02:49PM (#6561375)
Seems to be the same thing with Haskell and other languages, including Golang, that many groups on HN are passionate about. There aren't many people hiring for skills in these languages. Some start-up founders I know who have built their company on Python and Javascript, when I ask them if they have looked at Golang, they reply 'What's that?'.
Re:No More Callbacks: 10,000 Actors, 10,000 Threads, 10,000 ... by skriticos2 on Wednesday October 16, 2013 @03:25PM (#6561580)
I'd be happy if someone would hire Python. Most of it is Java, PHP and C# around here. So sad.
Re:No More Callbacks: 10,000 Actors, 10,000 Threads, 10,000 ... by wtracy on Wednesday October 16, 2013 @08:40PM (#6563007)
Where's "here"? I constantly get emails from recruiters looking for Python devs.

(I'm in the SF area, but a lot of the ads I see are for New York and parts of the Midwest.)

Re:No More Callbacks: 10,000 Actors, 10,000 Threads, 10,000 ... by yen223 on Thursday October 17, 2013 @04:55AM (#6564270)
Quite frankly, "here" could be anywhere that's not near the Bay Area.
Re:No More Callbacks: 10,000 Actors, 10,000 Threads, 10,000 ... by skriticos2 on Thursday October 17, 2013 @05:52AM (#6564387)
I think so too. I'm located in Germany, but I think this situation applies to most all of the word except the west coast of the U.S.
Re:No More Callbacks: 10,000 Actors, 10,000 Threads, 10,000 ... by reginaldjcooper on Thursday October 17, 2013 @12:36AM (#6563698)
Yeah I don't see many positions for Haskell, either (and I'd like to). OOP class systems are so irritating when you could get more powerful type-checking from less boilerplate. Maybe I should look into F#? AFAICT it seems to be Haskell's sister, who left academia to do finance and is pulling seven figures in her early twenties.
Re:No More Callbacks: 10,000 Actors, 10,000 Threads, 10,000 ... by marshray on Thursday October 17, 2013 @03:42AM (#6564103)
My group in Azure is hiring. I don't think we have any Haskell in production, but I sure bet we could get away with using F# and the new immutable collections for a lot of new stuff. zip [marshray@; maray] [live.com; @microsoft.com] Email me, I'd love some coworkers who were really into FP.
Re:No More Callbacks: 10,000 Actors, 10,000 Threads, 10,000 ... by lt4 on Thursday October 17, 2013 @11:34AM (#6566030)
This sounds interesting. If you don't mind I'd like to get in touch also.
Re:No More Callbacks: 10,000 Actors, 10,000 Threads, 10,000 ... by marshray on Thursday October 17, 2013 @05:51PM (#6568385)
Yes that'd be awesome!
Re:No More Callbacks: 10,000 Actors, 10,000 Threads, 10,000 ... by cmccabe on Wednesday October 16, 2013 @09:24PM (#6563134)
Python is 22 years old, Golang is 4 years old. Give it time.
Re:No More Callbacks: 10,000 Actors, 10,000 Threads, 10,000 ... by RussianCow on Thursday October 17, 2013 @02:34AM (#6563950)
Haskell is even older, but you don't see many job ads for it. I don't think it has much to do with the age of the language. Node.js is an example of a very young platform that many, many startups are using. (Although, to be fair, JavaScript has been around for quite some time now.)
Re:No More Callbacks: 10,000 Actors, 10,000 Threads, 10,000 ... by cmccabe on Friday October 18, 2013 @09:09PM (#6574918)
In order for a programming language to get used:

* it has to fill a need people have.

* people have to know about it.

* it has to have a mature implementation.

Age helps with point #2 and #3.

With regard to JavaScript, the web browser pretty much forces you to use it. So it doesn't really matter how good or bad it is, it will have adoption.

Re:No More Callbacks: 10,000 Actors, 10,000 Threads, 10,000 ... by CmonDev on Thursday October 17, 2013 @12:46PM (#6566517)
Space pilots and nuclear plant engineers are hard to hire because you need hardware to train. Hiring software developers just requires willingness to pay more money than market.
Re:No More Callbacks: 10,000 Actors, 10,000 Threads, 10,000 ... by ww520 on Wednesday October 16, 2013 @01:48PM (#6561030)
People have been using Netty (Java) to handle over 500K connections with NIO on one server. http://urbanairship.com/blog/2010/08/24/c500k-in-action-at-u...

That's 3 years ago. I'm sure more can be handled now, with more memory and more cores.

Bundled Netty with a distributed system like Hazelcast, you can easily scale out to more machines.

Re:No More Callbacks: 10,000 Actors, 10,000 Threads, 10,000 ... by pron on Wednesday October 16, 2013 @02:26PM (#6561265)
Quasar is distributed on top of our own IMDG called Galaxy. Our goal is not to give you scalability, but to give you scalability while keeping familiar and simple programming models. There is absolutely no reason not to use Netty with Quasar. In fact, we're doing exactly that in an internal project.
Re:No More Callbacks: 10,000 Actors, 10,000 Threads, 10,000 ... by cnlwsu on Wednesday October 16, 2013 @02:10PM (#6561183)
I've setup 1m connections to a Netty service we host a couple years back, its kinda a fun exercise. I would avoid something like hazelcast if want to do something that palatalized. We used terracotta and the entire concept of a shared memory in a distributed system becomes a major headache.
Re:No More Callbacks: 10,000 Actors, 10,000 Threads, 10,000 ... by ww520 on Wednesday October 16, 2013 @10:07PM (#6563289)
Can you give some insights on why to avoid Hazelcast or friends for distributed system?

I can give my sample usages. I mainly used it for organizing the cluster automatically, like managing membership, server joining or leaving, maintaining the master server address list. With a distributed hash scheme like Soda, any member server can accept work from any client. Scaling out is very simple, just boot up a machine from an image. It would use Hazelcast to join the cluster and become available.

I also used it for distributing jobs, nice to able to say - queue these jobs and the distributed workers pick them up automatically.

I avoid using it for shared memory stuff, using it like Memcached. That's what Memcached, Redis, and friends are for.

Re:No More Callbacks: 10,000 Actors, 10,000 Threads, 10,000 ... by jeremyjh on Wednesday October 16, 2013 @02:16PM (#6561215)
Yes but you're dealing with callbacks then. In the context of the SP, Netty is an example of what they wanted to escape from.
Re:No More Callbacks: 10,000 Actors, 10,000 Threads, 10,000 ... by justinsb on Wednesday October 16, 2013 @01:11PM (#6560799)
I also remember user-space threading in Java (where N threads would be multiplexed onto M kernel threads), although my understanding was that we moved to the 1:1 threading model because it was faster and had fewer pathological edge cases.

It sounds like you're saying that it wasn't faster? Can you explain a bit more about the motivation if so?

Any thoughts on whether we should have user-space threading in the JVM today? Maybe it could be implemented in RoboVM as an experiment (rather than wrestling with the JVM immediately)?

Re:No More Callbacks: 10,000 Actors, 10,000 Threads, 10,000 ... by ChuckMcM on Wednesday October 16, 2013 @02:31PM (#6561287)
So the "original" move to native threads was motivated by the fact that Sun didn't want Java to be SunOS only (there were a number of SunOSism's in it when it was Oak). That the system threading system would improve independently of the language and have fewer edge cases were put forth as good reasons to do that.

Initially it was slower because context switches are slower, and anything that had to context switch into and out of the kernel was thus slower. Later there were other reasons. "User level" or as I prefer "Single Context" [1] threads have the ability to be very fast because they have extra knowledge about what is going on and access to other address spaces (so you don't have to save something if you know how it's used). There has been lots of great work on this since the early 90's when this decision was made so I suspect the issue would be significantly less.

[1] At the time kernel threads were 'single context' and quite fast. Fast enough to be used for interrupts. There is a great paper on the threading system in Solaris which describes them. -- http://dl.acm.org/citation.cfm?id=202217

Re:No More Callbacks: 10,000 Actors, 10,000 Threads, 10,000 ... by pron on Wednesday October 16, 2013 @02:36PM (#6561308)
Naturally, we've experimented a lot measuring context-switch cost. While pretty bad on OS X, on Linux it's quite good in many circumstances (sleep, IO interrupt) but not so good when a thread waits to be woken up by another application thread (as opposed to being woken up by some kernel event). Aside from consuming less memory, Quasar fibers shine exactly in that last scenario: when fibers wait on other fibers (they could be waiting for an actor or channel message, a condition variable, or an in-memory DB transaction). Fibers use Doug Lea's awesome fork/join thread pool for scheduling.

I hope to write about our context-switch results some day.

Re:No More Callbacks: 10,000 Actors, 10,000 Threads, 10,000 ... by tieTYT on Wednesday October 16, 2013 @01:31PM (#6560933)
Isn't the Java mascot named Duke?
Re:No More Callbacks: 10,000 Actors, 10,000 Threads, 10,000 ... by ChuckMcM on Wednesday October 16, 2013 @02:22PM (#6561246)
The guy who drew him (Joe Palrang) called him 'Fang' and most of the rest of the folks in the Java group did as well. When we went public with Java Sun PR didn't like the name we'd given him so they picked Duke. I think Wayne Rosing suggested that name but my memory of that is quite fuzzy.
Re:No More Callbacks: 10,000 Actors, 10,000 Threads, 10,000 ... by Keyframe on Wednesday October 16, 2013 @01:45PM (#6561011)
He looks like a fang though. Maybe that's what they've nicknamed him internally.