5 ms·
Erlang was designed from the ground up to do what it does, so it's... not easy to replicate that in other systems.
by davidw 11y ago
Erlang was designed from the ground up to do what it does, so it's... not easy to replicate that in other systems.
- tormeh 11y agoThis. The VM and everything about Erlang in general is designed for this particular task. Just sit down and learn you some Erlang - it's a bit weird and alien, but it's not so hard and you either do it or regret not doing it. You could, I suppose, hack something together using multiple JVMs per machine (avoid global GC) and Akka and implement some custom live diagnostics, but if you're really doing a telecommunications project there's no real shortcut. Plain Akka will cut it in many cases but it's not a thoroughbred like Erlang. Give up, Erlang just can't be beaten at its home turf by a framework.
- MichaelGG 11y agoWhat shortcut are you talking about? I spread SIP/RTP handling systems over many machines, load balanced with a SIP proxy. I would love to know how Erlang is going to make it magically scale even better. Highest record was only a billion calls in a day or two, so maybe I'm not at enough scale to be hurt by non-Erlang. (Stack was all C, plus F# for routing and billing.)
- pron 11y ago... unless those other systems are more general. Erlang itself is written in C. The JVM (or, rather, any JVM) is more low-level and therefore more general than an Erlang VM, and includes much of the work already, so replicating Erlang on the JVM is much easier than replicating it in C. There is nothing Erlang VMs provide that the JVM doesn't, except for some guarantees that are simply different on the JVM, and I think most applications would prefer the JVM's advantages anyway.
- MCRed 11y agoOTP is written in erlang. The JVM is not "more low-level" and not "more general". In fact it is impossible to do on the JVM in any JVM language what the erlang VM gives you. You literally cannot replicate erlang on the JVM. You can fake it, but you will not have the guarantees and reliability that the erlang VM gives you. To get erlang/OTP you would have to replicate it from the beginning in C, and there's no point in that, when you can just use erlang.
- pron 11y agoI guess we'll just have to disagree on all of those points.
- RogerAlsing 11y ago>and there's no point in that, when you can just use erlang That is a strange comment, ofc the Erlang VM is not the single best VM that will ever be created. Some day, someone will create a better one.
- CHY872 11y agoI think the point was more that Erlang was produced at considerable expense, so the cost of recreating Erlang for your own project is probably less than the cost of simply producing your project in Erlang.
- arthurcolle 11y ago> I think the point was more that Erlang was produced at considerable expense, so the cost of recreating Erlang for your own project is probably more than the cost of simply producing your project in Erlang. Fixed! Read your comment, understood it, but I think you probably meant the opposite
- felixgallo 11y agoHow hard did you find implementation of reduction counting preemption and tail call optimization?
- pron 11y agoReduction/time-slice preemption is quite easy. Trivial, actually. We had it in early versions of Quasar but later removed it as it had no advantage as you can choose either user-space or kernel scheduling for each Quasar actor/"strand", and threads that rely time-slice based preemption do a lot better when scheduled by the kernel (and you can't have too many of them anyway, no matter how they're scheduled). Tail call optimization is more painful. On the JVM, it is done at the language level[1] (Erjang does it), and will eventually be added to the JVM itself[2]. In any case, because Erlang the language needs it, it can have it on the JVM. But the "Erlang model" of processes etc. doesn't require it. [1]: http://cesquivias.github.io/blog/2015/01/15/writing-a-language-in-truffle-part-4-adding-features-the-truffle-way/#tail-call-optimization-in-truffle http://cesquivias.github.io/blog/2015/01/15/writing-a-langua... [2]: It is unfortunate that the JVM doesn't yet have TCO, but the compiler generates such fast code that implementing it at the language level still yields better performance than Erlang VMs.
- felixgallo 11y agoTCO isn't about fast performance, it's about stack depth. I like Quasar, but I suspect you removed reduction scheduling because function-call-site reductions, as erlang does natively, is not great when implemented in-language, as it blows up a number of optimizations and muddies the register picture. That said, I think MCRed is doing a slight disservice even he's got good intentions; erlang is amazing for what it does, quasar is pretty nifty and doubtless has many superior use cases; even go has a lot of utility in the concurrency space. Let a billion processes bloom.
- pron 11y ago> TCO isn't about fast performance, it's about stack depth. Sure, but again, it's certainly doable (and has been done). > I suspect you removed reduction scheduling because function-call-site reductions, as erlang does natively, is not great when implemented in-language, as it blows up a number of optimizations and muddies the register picture. We removed it because it's unhelpful, and let me explain why. Any preemption that's based on time-slices/reduction -- basically, preemption at any point other than the thread blocking on something -- means that the thread still wants more CPU, but you can't allow it to have it because there are others that need it. This is fine when you have roughly the same number of such CPU-hungry threads as CPU cores, or even a bit higher -- not when you have 100,000 of those or 1M. So the number of CPU hungry threads must be very low, or your system is grossly under-provisioned. Now, Erlang has to do it because all Erlang processes are scheduled in user mode, but even in Erlang this doesn't help if you have more than a few such processes. OTOH, on the JVM, where you can pick if you want user-mode or kernel scheduling, you can simply choose the kernel to schedule those few CPU-hungry threads. The kernel does it much better than anything in userspace can. If you don't have CPU-hungry threads, but well-behaving threads that occasionally become CPU-hungry, it still doesn't help because the work stealing scheduler can very easily deal with such occasional behavior. In short, time-slice/reduction based preemption in the user-mode scheduler simply doesn't help you in any way. Erlang does it because it has no other scheduler and it must support (a few) processes that behave that way.