5 ms·
The JVM jit _has_ to do a lot more for performance. Lack of value types means greater allocation by default - so it needs escape analysis to avoid it. Type er
by benaadams 9y ago
The JVM jit _has_ to do a lot more for performance.
Lack of value types means greater allocation by default - so it needs escape analysis to avoid it.
Type erasure for generic types means speculative optimisation and deoptimisation steps for types.
etc
Doesn't mean the .NET Jit can't improve in these areas (e.g. now its doing devirtualization for .NET Core 2.1, and escape analysis would be great) - but it does start in a better place.
- bunderbunder 9y agoI think that the "lack of value types" is probably an overrated difference these days. Empirically, I've found that value types generally only offer a tangible perf benefit when they're the size of a pointer or smaller. There aren't a whole lot of spots where that comes into play. Primitives, sure, but Java also has those. Beyond that, maybe you'd see some difference in code that does a lot of date calculations, maybe. I've done some slightly obscene and shameful optimizations around packing data into 64-bit structures in the past, but those are pretty special cases.
- comex 9y agoHow about vectors or coordinates? This post from a few years ago comes to mind: http://www.minecraftforum.net/forums/mapping-and-modding-java-edition/minecraft-mods/1272953-optifine-hd-c7-fps-boost-dynamic-lights-shaders?page=2100#c43757 http://www.minecraftforum.net/forums/mapping-and-modding-jav... (Allegedly, a Minecraft update added significant strain on the garbage collector by switching the codebase from using separate variables/parameters for x, y, and z coordinates to using a single “BlockPos” object.)
- bunderbunder 9y agoIf you're just using local values, or storing them in an array, then, yeah, value types might help. That's a likely scenario for something like storing arrays of vectors. The spot where you take a hit is when you've got a scattering of individual objects that are being passed into and out of functions. There, the extra data copying has a tendency to outweigh the other benefits. And that's a more likely scenario for most kind of the kinds of business apps that .NET and Java are typically used for.
- pjmlp 9y agoNo they are a real issue, and that is why Oracle is pouring millions into improving the JVM in this area. Oracle is not a company that gives money away for free. Fintech is one of the areas that is slowly moving from C++ into Java and doesn't do it faster because they cannot move all the kind of code they have into Java, hence Oracle efforts. Or why we are starting to see languages like Pony and Chapel pop up.
- matthewwarren 9y ago> I think that the "lack of value types" is probably an overrated difference these days. Well, seems that the JVM designers disagree, there's been a lot of work put into fixing this, see 'Project Valhalla' for instance https://www.infoq.com/news/2016/11/valhalla-Implementation-proposal https://www.infoq.com/news/2016/11/valhalla-Implementation-p... http://www.jesperdj.com/2015/10/04/project-valhalla-value-types/ http://www.jesperdj.com/2015/10/04/project-valhalla-value-ty...