4 ms·
The other day some guys proudly re-implemented jemalloc in pure Java - https://blog.twitter.com/2013/netty-4-at-twitter-reduced-gc-overhead https://blog.twitter
by dschiptsov 13y ago
The other day some guys proudly re-implemented jemalloc in pure Java - https://blog.twitter.com/2013/netty-4-at-twitter-reduced-gc-overhead https://blog.twitter.com/2013/netty-4-at-twitter-reduced-gc-... now these guys re-implemented a half of Erlang.)
Isn't it better (and bitter) to face the reality and just use Erlang or Go or at least to ask oneself why should everything be stuffed into JVM in 2013?)
- pron 13y agoGo has nothing to do with it. The JVM is a superset of Go, and Go's strengths lie mostly in a short startup time. Erlang is a different matter. We love Erlang. But the JVM ecosystem is not only two or three orders of magnitude bigger, but the JVM serves other requirements as well like excellent performance (performance is not Erlang's strongest suit, and more than a few Erlang projects require C code to meet performance requirements). Some projects will be best served by Erlang, but many will benefit from Erlang's capabilities on the JVM. In short – Erlang is awesome, the JVM is awesome, extremely popular and very successful. Why not combine their strengths? We already have a full Erlang implementation for the JVM, and we think that Pulsar (Quasar's Clojure API) really brings together the best of both Erlang and Clojure. There are many technical advantages to using the JVM, too. Because it has really good low-level concurrency constructs, you can implement state-of-the-art concurrent data structures in Java. This is downright impossible in Erlang, as in all pure functional languages. This is as it should be, because these languages work at a higher level. The problem is that BEAM, Erlang's VM, operates at the same level, too, so if you want to write a concurrent DS for Erlang you'll need to do that in C. It's a lot harder than it may seem, because many of these data structures require a good GC, and the BEAM the GC can't help because it only manages process-private heaps.
- dschiptsov 13y agoI am really appreciate your drive and effort, thank you for the reply. In my opinion, however, as I could gather from the writings of mr. Armstrong, (one of) the fundamental problem with JVM is that it lacks a process isolation, and when it crashes, everything crashes completely. He explicitly pointed out this in his thesis - JVM cannot provide fault-tolerance due to being a mere user-level multi-thread process. As a person who had experience of running huge Java crapware like Business Objects I could tell that yes, it crashes and it crashes often, and when it crashes there are situations in which there is no way to preserve data integrity and plain re-installation is required. I am also not quite sure about any superior concurrency constructs which aren't based on OS primitives, but I am not Java guy. Go is a way of doing things without a VM.)
- pron 13y ago> In my opinion, however, as I could gather from the writings of mr. Armstrong, (one of) the fundamental problem with JVM is that it lacks a process isolation, and when it crashes, everything crashes completely. He explicitly pointed out this in his thesis - JVM cannot provide fault-tolerance due to being a mere user-level multi-thread process. This is true in general, but not entirely accurate. When a Java thread crashes it doesn't bring down the whole JVM any more than when an Erlang process does. Just the one thread dies. With Quasar you get the same isolation for fibers. It is true, however, that one thread in Java could negatively impact the performance of another by triggering a GC, while in Erlang each process has its own private heap. The Erlang approach (or the BEAM approach, rather, as its a feature of the VM - not the language) provides this isolation because Erlang was designed for systems where fault-tolerance is the number one concern. But it has its cost, too. The lack of a global heap makes it impossible to implement useful shared data structures, so Erlang provides some simple shared data-structures (like ETS) implemented in C, but those aren't garbage collected. Also, the JVM has a big performance advantage over BEAM. That's why quite a few Erlang projects need to code some performance critical functions in C. But once you do that, you lose Erlang's isolation guarantees: a failed C function could bring down the entire application, and one that's stuck in an infinite loop will affect the performance of other processes. > I am also not quite sure about any superior concurrency constructs which aren't based on OS primitives, but I am not Java guy. You can start by looking here: http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/package-summary.html http://docs.oracle.com/javase/7/docs/api/java/util/concurren... None of these classes uses kernel mutexes or other synchronization mechanisms.
- dschiptsov 13y ago> When a Java thread crashes it doesn't bring down the whole JVM any more than when an Erlang process does. Just the one thread dies. I think this is inaccurate also.) Technically there is no memory protection from one pthread to another, so "crashed" pthread could damage shared data or the common stack. It is, however, not JVM's problem but of the pthreads as a concept, and Armstrong argued that only share-nothing architecture (process-based) could be fault-tolerant, and pthreads are just "broken by design".