5 ms·
So with about the same CPU time, JRuby will use up to 100x memory in worst case? Anyway Ruby 2.0 is suppose to solve the Ruby is Slow problem. although i have
by ksec 14y ago
So with about the same CPU time, JRuby will use up to 100x memory in worst case?
Anyway Ruby 2.0 is suppose to solve the Ruby is Slow problem. although i have yet to see any evidence that will the case. Sigh.
- benmmurphy 14y agothese benchmarks also include the time it takes the vm to start up and may not include full JIT performance. locally in jruby pidigits.rb 2000 takes 4.132s, running it twice it takes 4.965s. jruby is quite annoying for running small little scripts because of the startup time but it an be quite nice for full applications.
- bascule 14y agoYes, each Ruby method needs to get executed 50 times to JIT to JVM bytecode, and from there it takes an additional 10,000 calls for HotSpot to JIT that to machine code. Any hotspots therefore need to be hit at least 10,050 times in order to be fully warmed up.
- mbell 14y agoJust start the JVM with -XX:CompileThreshold=<some_number> It only defaults to 10,000 when the JVM is running in server mode, its 1,500 when in client. Which mode a default install runs in is a bit wonky so I always explicitly set it (with -server as an argument to the JVM).
- igouy 14y ago>> jruby pidigits.rb 2000 takes 4.132s << Why did you measure a workload 1/5th of the workload shown on the benchmarks game webpages? Each program page shows measurements for 3 workloads, in the case of pi-digits 2,000 6,000 and 10,000. http://shootout.alioth.debian.org/u32/program.php?test=pidigits&lang=jruby&id=3 http://shootout.alioth.debian.org/u32/program.php?test=pidig...
- spitfire 14y agoPossibly not. Those benchmarks (mandelbrot and n-body, pi-digits) are very low memory footprint benchmarks. So it might be a difference of going from 20K to 30meg constant memory usage. Whereas the other benchmarks seem to have single digit multiples of memory usage. SO seemingly real world apps will use more memory, but not 100x in practice.
- bascule 14y agoAlso note that for Fixnum dependent benchmarks, JRuby has to allocate memory due to boxed integers, whereas on the de facto interpreter it's able to use tagged pointers which allow Fixnums to be treated as simple numeric values. This may be going away in JDK9 as they claim they're eliminating primitive types in favor of an everything-is-an-object model.
- bascule 14y ago> So with about the same CPU time, JRuby will use up to 100x memory in worst case? The JVM often trades increased memory usage for increased performance. That said "100x memory" is total hyperbole, even in the context of a microbenchmark. If you want the JVM to use less RAM, you can turn down the maximum heap size. Otherwise the heap will grow until it reaches close to full before the GC does a stop-the-world style collection of the old generation. > Anyway Ruby 2.0 is suppose to solve the Ruby is Slow problem Absolutely not. There are presently no plans to add a JIT compiler to the de facto Ruby interpreter. The JVM on the other hand has the most advanced JIT compiler in the world. InvokeDynamic on Java 7 allows JRuby to do method inlining, and on Java 8 it will be able to take advantage of the full suite of HotSpot optimizations, including escape analysis and lock elision when compiling Ruby code into machine code. No other Ruby VM will have that level of optimization.
- igouy 14y ago>> If you want the JVM to use less RAM, you can turn down the maximum heap size. << That's how the programs used to be run with JRuby 1.6.7 and with those same limits the n-body program failed to complete within 1 hour using JRuby 1.7 -- so the brittle RAM limits were abandoned.
- mbell 14y ago> Otherwise the heap will grow until it reaches close to full before the GC does a stop-the-world style collection of the old generation. Most real applications will be using ConcMarkSweepGC(or G1) and ParNewGC. With these collectors the JVM won't just burn through all the memory and halt the world unless you throw a workload at it which the GC can't handle with its normal GC cycles. The GC makes small sweeps regularly but the duration of those sweeps is limited to ensure relatively consistent response time. If you were creating and throwing away so many objects which were promoted to the tenured generation that these small, time limited, GC sweeps couldn't keep up, then you would see the heap grow to its maximum and a 'stop the world' GC would take place. In practice that doesn't happen in the vast majority of workloads.
- bascule 14y ago