How did JVM implementations, such as Jython and JRuby, beat their native colleagues?

I watched this video here where Robert Nicholson discusses P8, a PHP implementation on the JVM. At one point, he mentions that they strive to outperform PHP in their performance for some time to come.

He mentions JRuby and Jython, which began slower than their peers but ended up surpassing them. Quercus, another PHP interpreter in the JVM, claims to be 4 times faster than mod_php, and is also worth noting.

Does this mean that the general idea that the JVM is slower than C is incorrect or are there flaws in the original C implementations?

+4
performance jython jvm jruby quercus
source share
3 answers

Does this mean that the general idea that the JVM is slower than C is wrong or are there flaws in the original C implementations?

Little

The JVM has been around for a long time and has made significant progress in efficiency. Garbage collection, jittering, caching and other areas are more advanced than in "reference" implementations, such as PHP.

Anyone looking under the hood of PHP will understand why performance gains are easy to achieve.

I personally doubt that the JVM can outperform CPython, but ... but I can be wrong ... I, that's not how the JVM GC works faster, but IronPython does too. Improving performance may not be warranted in the C call stack, for example, in free Python. Jython Website Status

Jython is about as fast as CPython - sometimes faster, sometimes slower. Since> most JVMs — certainly the fastest — work for a long time, hot code runs faster faster.

What I can describe as a fact, since the JVM will reach C performance levels when generating caches, etc., basically deny higher-level aspects for VM implementation code (most of which is written in C anyway).

In many interpreted languages, such as PHP and Python, there are only bridges for equivalent C calls and immersion in machine code. In the JVM, jitter performs a similar function, reducing bytecode to machine code equivalents. After all, intermediate representations, such as high-level syntax and bytecode, are usually reduced to C-speed or faster CPU operations ... so this is just the same, only more intermediate steps that only affect the delay until full efficiency when downloading new code. There comes a point in RAM where you say: "What's the difference?" and the answer is just the process that gets it there, and the final presentation, which determines the speed of the stack winding, garbage collection algorithms, the use of registers, and the logical representation, such as arithmetic.

+8
source share

This is not too complicated. If you are writing your implementation in C, you must write your own GC, JIT, and more (to be fast and efficient). To do this really well, you need really smart people with a lot of experience and give them a lot of time.

I will go to the limb here and say that the current implementation of PHP (not based not on knowledge of the internal work, but rather on the tests that I saw, and on what I was told by people who know more about PHP) does not correspond to the prior art. Facebook is trying to solve this problem, but they are doing it in an unusual way (due to the special needs and typical use of PHP, see http://www.stanford.edu/class/ee380/Abstracts/100505.html ).

Summary: Therefore, if someone implements PHP in java (or on any fast VM), he does not need to write a super GC or JIT to be a fast "single" compiler (which can be simple).

+1
source share

There are a few tips on what the virtual machine does here . For example, it seems that the Java virtual machine first checks which parts of the bytecode are executed most often, and then compiles the corresponding parts into its own code (which should then run at the same speed as, for example, compiled C code).

By the way, is PHP compiled into bytecode or is it just interpreted using a data structure in memory? By translating PHP first into the bytecode executable by the Java virtual machine, it is automatically profitable from existing (language agnostic) bytecode execution optimizations.

0
source share

All Articles