Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Regular Java is currently faster (up to 3x) than C# on mono: http://shootout.alioth.debian.org/u64q/benchmark.php?test=al... ...but obviously on a phone it's going to be Dalvik not regular JVM

We need to consider memory consumption too. Dalvik obviously uses less memory than regular JVM, and probably less than mono if I were to guess.



Some observations:

In general, HotSpot is a more advanced VM that Mono is. They support dynamic recompilation at a higher optimization level, which we do not.

This is part of the debate in Google vs Oracle. Google could have used HotSpot had they figured out some agreement, but instead ended up with Dalvik which lacks many of the advanced optimizations of HotSpot.

That said, java -server compared against out of the box Mono 2.10.8 is not an apple's to apple's comparison, it is by no means "regular Java". That is Java tuned with some specific parameters. It comes at the expense of interactive time, Mono's default is fast-JIT, and fast startup.

Java -server uses a fixed heap, this means that you must preallocate how much memory the application will use during its entire lifetime. This is good for performance because the GC knows that it only has to scan for example memory between points A and B. 2 comparisons is all you need during GC to scan. Meanwhile, Mono is uses a dynamic heap, which means that it can grow its memory usage based on demand (no need to fine tune the maximum heap every time your app crashes due to a low setting) and can return the released memory to the OS. This complicates GC, because now we cant just compare against 2 values, we need to consider every object in the scope of a series of differently sized heaps.

With Mono 2.11, you can force your app to go fixed heap; The only people that really have a use for this are HPC people and a handful of server people. To be honest, most people dont want to configure the max heap of their server apps by crashing and trial and error.

The second component is that Mono's default is aimed for desktop/mobile configurations, not server loads. If you want to use server loads, run Mono with the --llvm flag: you will have very slow startup times, but you will get code quality that is essentially the same code quality that you get from an optimizing C compiler nowadays.

As for Mono vs Dalvik memory use, in practice people run Mono with Dalvik (Mono for Android), not in standalone mode, so we end up paying for Dalvik's memory footprint. But I agree, it would be nice to find out how much memory it actually uses.

Considering that we get the benefits of a more advanced GC, value types and generics while Java does not, it just seems like we would use less memory for comparable loads.


> java -server compared against out of the box Mono 2.10.8 is not an apple's to apple's comparison, it is by no means "regular Java"

Since at least Java 5 the default on machines with 2 or more processors and 2GB or more memory has been -server. That's what regular out-of-the-box Java is on those machines.

Do many new laptops not have 2 processors and have less than 2GB?


Well, don't read too much into it.

Here is the Java source for binary-trees, which is 6x faster than c#. http://shootout.alioth.debian.org/u64q/program.php?test=bina... C#: http://shootout.alioth.debian.org/u64q/program.php?test=bina...

Notice that the Java code multi-threaded, while the C# version is single-threaded. And the Q6600 being used there has 4 cores.


Notice that there's another Java program which is single-threaded but still uses more than one-core (figure out why) -

http://shootout.alioth.debian.org/u64q/program.php?test=bina...


I'm guessing the JVMs have gone a long way on optimization (or maybe they're using JIT)

Also not sure about how optimized are the C# sources in relation to the Java sources

For example, in the Mandelbrot benchmark there are several differences

- Java uses more arrays

- C# and Java use different break conditions

- Calculations are done differently (with similar results)

Overall they're doing the same things, the C# is more like I remember it, so I'm guessing the Java code has some smart tricks up its sleeve




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: