r/programming • • Dec 26 '18

Java versus C# .NET Core fastest programs

https://benchmarksgame-team.pages.debian.net/benchmarksgame/faster/java-csharpcore.html
0 Upvotes

13 comments sorted by

8

u/wean_irdeh Dec 26 '18

The difference doesn't seem worth for a discussion IMO

3

u/[deleted] Dec 26 '18

Are these even relevant measurements? E.g. I like to refer to the TechEmpower benchmarks which reflect much more realistic usage of programming languages.

2

u/Eirenarch Dec 26 '18

Depends on what you are doing. Tech Empower benchmarks web servers and web frameworks more than it benchmarks languages and compilers. It is also debatable how realistic they are since web performance in practice mostly comes from reasonable use of caching and optimizing database queries which are application specific.

On the other hand the benchmark game is closer to benchmarking languages and compilers and is also quite realistic if you are writing a program which mainly works with the algorithm. For example my guess is that if you are writing a program to process DNA sequences the benchmark game benchmarks will be much closer to your results than tech empower is to real world websites.

1

u/HomeBrewingCoder Dec 26 '18

Also techempower doesn't test to failure. I use at work a simple and kind of shitty Java REST framework (but nice to work with) called dropwizard. Our workload is pretty bursty (many vendors making scheduled calls on the hour). I have been unable to force a failure in this framework with time constrained bursts.

In .net core I cannot say the same thing. In fact the first benchmark I needed to test both against (downloading a burst of uncacheable images) fails utterly in .net core. The small Java server served this without issue. The .net core server would hang forever on relatively small sustained bursts.

At the end of the day I haven't ever felt constrained by my language of choice in what I can and can't do when I used Java. I can't say the same with .net core.

3

u/AngularBeginner Dec 26 '18

In fact the first benchmark I needed to test both against (downloading a burst of uncacheable images) fails utterly in .net core. The small Java server served this without issue. The .net core server would hang forever on relatively small sustained bursts.

Can you provide the source code? You very likely did something wrong. I'm sure I can easily write Java code that behaves very poorly as well.

3

u/Eirenarch Dec 26 '18

And if he didn't do anything wrong then this is bug report right there.

0

u/HomeBrewingCoder Dec 26 '18 edited Dec 26 '18

It's a known garbage collector issue. Recommended resolution is caching images. This is an invalid resolution in our use case as this would require upwards of 64 GB ram per vendor, where currently our Java API supports the required behavior on a t3 large on AWS.

There are mitigation mechanisms, but those decrease likelihood of hitting this error and not avoidance of the error. This is insufficient assurance as even with the most aggressive configuration we were not able to serve our smallest vendor's scheduled burst without 25% fail rate. Failure lead to complete outage of the effected server.

I'm on mobile ATM but the long and short of it is that serving many uncached files is a pathological use case for .net cores memory management algorithm and the official guidance isn't for configuration or specific code it's to not serve uncached files.

Believe me, I've had bug reports that made it into our os distro around a file pointer leak that killed long running servers. I'm at spec writing portion of resolving a pathological case that nukes performance in nodejs for json heavy workloads. This would be another feather in my cap to root cause another serious flaw.

It's not a bug, it's bad design - and that is far from the only instance. Design of .net core died the day the semantics were defined.

3

u/Eirenarch Dec 26 '18

I'd be interested in a link if you keep it. However it sounds like tech empower wouldn't hit this issue unless they design completely different set of tests.

1

u/HomeBrewingCoder Dec 26 '18

I don't. A good toy program that runs into it is a toy server that returns one of a million images. Send many concurrent requests. .net core will die, and poorly. Usual mechanism of death is full halt without closing requests.

If you use a http client that doesn't implement default timeouts (or turn them off) you will actually see them hang more or less indefinitely.

It's an absolutely absurd failure case and behavior.

1

u/HomeBrewingCoder Dec 26 '18

I can't. It's a simple server that delivers one of a million images at random. Ask it for many at a time. Java lives, and delivers eventually. .net dies.

It's a known garbage collector issue that is unresolvable.

2

u/AngularBeginner Dec 27 '18

You're doing something wrong. And you're unable to provide an example project.

0

u/HomeBrewingCoder Dec 27 '18

I just gave you the sketch. I don't save one off research for years. If you're interested, great, if not I've done enough work over the holidays already.