News for hackers. Stuff that matters.
Re:Why Aren’t More Users More Happy with Our VMs? Part 1 by hyperman1 on Thursday September 06, 2018 @05:03AM (#17924868)
There is another very practical benefit: You can use all features available on your PC.

E.g. when you compile an application C-style, you set the target architecture to the lowest CPU you want to support. If this is , say, SSE, then no SSE2 instructions will be used by the program and the sometimes huge performance gains from them are lost.

A VM like hotspot can generate code for this specific machine. If you have SSE2, it will generate SSE2 instructions. If you dont, it wont.

Recently, I see more applications choosing code paths based on CPUID, but this only works for CPUs existing at compile time. If you app was compiled in 2016, in wont use CPU features from 2018. If your java app from 2016 runs on a JRE from 2018, it will use them.

Re:Why Aren’t More Users More Happy with Our VMs? Part 1 by varjag on Thursday September 06, 2018 @06:30AM (#17925192)
I would really like to see a Java program beating a C program in this use case. Say, outperforming it (or even matching to same order of magnitude) on DCT/IDCT even by using SSE2 vs SSE/MMX. Can only say am immensely sceptical.

Another thing is these kind of gains with instruction level efficiencies are exceedingly rare and your typical VM program never runs any code where SIMD extensions would make a difference.

Re:Why Aren’t More Users More Happy with Our VMs? Part 1 by hyperman1 on Thursday September 06, 2018 @09:13AM (#17925973)
This article is not what you ask, but it is an example of a VM beating native:

https://nullprogram.com/blog/2018/05/27/

Java uses the same technique.

Basically, a JIT allows you to skip the overhead of the GOT.

Devirtualization is another case.

I have personally seen Java beating an existing C++ program for the reason I describe, but I cant publish the results here. You have to program carefully or you loose all speed benefits because of pointer chasing. But it is possible.

Re:Why Aren’t More Users More Happy with Our VMs? Part 1 by wolfgke on Thursday September 06, 2018 @11:34AM (#17927001)
> Basically, a JIT allows you to skip the overhead of the GOT.

This is a problem that is GNU/Linux-specific. Windows DLLs are not PIC (position-independent code), so they do not suffer from this problem and don't need a GOT.

See

> https://www.symantec.com/connect/articles/dynamic-linking-li...

for details.

The method that Windows uses is much faster in the average case, but slower in the "bad" case. So GNU/Linux vs Windows have different performance tradeoffs.

Re:Why Aren’t More Users More Happy with Our VMs? Part 1 by hyperman1 on Thursday September 06, 2018 @02:16PM (#17928197)
Yes and no: there is another indirection mechanism at work on windows: All results for imports in the import table are at the beginning of the DLL's data segment. So a call to another DLL first has to fetch the data from there, then do an indirect call. In x86 assembler:

  some_import_address    dd some_import ; will be filled in by dll import
      [... lots of unrelated code and  data...]
      call [some_import_address]
a JIT can read the address from code and do directly:

      call some_import
that's one less memory load.

The benefit is that the dynamic linking does not modify the code segment, so there are less private, modified pages mmapped, thus more sharing and less memory usage.

Re:Why Aren’t More Users More Happy with Our VMs? Part 1 by hyperman1 on Thursday September 06, 2018 @10:31AM (#17926555)
I'll add another one: Inlining across libraries. AFAIK, Even if you statically precompile bytecode on the target system a la dotnet this is not possible as the individual library and executable files are barriers the compiler can't cross.
Re:Why Aren’t More Users More Happy with Our VMs? Part 1 by cm2187 on Thursday September 06, 2018 @05:59AM (#17925064)
But don't static compilers generate checks for the availability of these features and ship both versions? I guess it is rather to take advantage of new features that were not available when the code was compiled.
Re:Why Aren’t More Users More Happy with Our VMs? Part 1 by de_watcher on Thursday September 06, 2018 @08:09AM (#17925626)
In other words "an obfuscated Gentoo".