2,017 questions
912
votes
10
answers
255k
views
Why is 2 * (i * i) faster than 2 * i * i in Java?
The following Java program takes on average between 0.50 secs and 0.55 secs to run:
public static void main(String[] args) {
long startTime = System.nanoTime();
int n = 0;
for (int i = 0; ...
652
votes
18
answers
310k
views
What does a just-in-time (JIT) compiler do?
What does a JIT compiler specifically do as opposed to a non-JIT compiler? Can someone give a succinct and easy to understand description?
413
votes
3
answers
9k
views
.NET 3.5 JIT not working when running the application
The following code gives different output when running the release inside Visual Studio, and running the release outside Visual Studio. I'm using Visual Studio 2008 and targeting .NET 3.5. I've also ...
103
votes
5
answers
53k
views
C# JIT compiling and .NET
I've become a bit confused about the details of how the JIT compiler works. I know that C# compiles down to IL. The first time it is run it is JIT'd. Does this involve it getting translated into ...
97
votes
7
answers
26k
views
How to see JIT-compiled code in JVM?
Is there some way to see the native code produces by the JIT in a JVM?
92
votes
6
answers
34k
views
What is microbenchmarking?
I've heard this term used, but I'm not entirely sure what it means, so:
What DOES it mean and what DOESN'T it mean?
What are some examples of what IS and ISN'T microbenchmarking?
What are the dangers ...
89
votes
3
answers
54k
views
What exactly does -XX:-TieredCompilation do?
Using java -XX:+PrintFlagsFinal I found the TieredCompilation flag, and I read about it a bit online.
Yet, I still don't know exactly what happens when setting it to false.
I know that the ...
86
votes
9
answers
38k
views
What are the advantages of just-in-time compilation versus ahead-of-time compilation?
I've been thinking about it lately, and it seems to me that most advantages given to JIT compilation should more or less be attributed to the intermediate format instead, and that jitting in itself is ...
84
votes
4
answers
7k
views
Is it possible to write a JIT compiler (to native code) entirely in a managed .NET language
I'm toying with the idea of writing a JIT compiler and am just wondering if it is even theoretically possible to write the whole thing in managed code. In particular, once you've generated assembler ...
65
votes
1
answer
26k
views
Why is LuaJIT so good?
EDIT: unfortunately LuaJIT was taken out of the comparison in the link below.
This comparison of programming languages shows that LuaJIT has an over tenfold improvement over the normal Lua ...
64
votes
1
answer
30k
views
What are Torch Scripts in PyTorch?
I've just found that PyTorch docs expose something that is called Torch Scripts. However, I do not know:
When they should be used?
How they should be used?
What are their benefits?
63
votes
8
answers
35k
views
Errors installing Composer on macOS (JIT compilation failed)
When I run composer --version in the macOS terminal, I get the following errors.
PHP Warning: preg_match(): JIT compilation failed: no more memory in
phar:///usr/local/bin/composer.phar/vendor/...
61
votes
11
answers
97k
views
Why Python is so slow for a simple for loop?
We are making some kNN and SVD implementations in Python. Others picked Java. Our execution times are very different. I used cProfile to see where I make mistakes but everything is quite fine ...
58
votes
8
answers
38k
views
What are the differences between a Just-in-Time-Compiler and an Interpreter?
What are the differences between a Just-in-Time-Compiler and an Interpreter, and are there differences between the .NET and the Java JIT compiler?
56
votes
10
answers
27k
views
Why is Java faster when using a JIT vs. compiling to machine code?
I have heard that Java must use a JIT to be fast. This makes perfect sense when comparing to interpretation, but why can't someone make an ahead-of-time compiler that generates fast Java code? I know ...
55
votes
7
answers
37k
views
CLR vs JIT
What is the difference between the JIT compiler and CLR? If you compile your code to il and CLR runs that code then what is the JIT doing? How has JIT compilation changed with the addition of generics ...
50
votes
5
answers
9k
views
Is there a runtime benefit to using const local variables?
Outside of the ensuring that they cannot be changed (to the tune of a compiler error), does the JIT make any optimisations for const locals?
Eg.
public static int Main(string[] args)
{
const int ...
49
votes
1
answer
2k
views
JIT not optimizing loop that involves Integer.MAX_VALUE
While writing an answer to another question, I noticed a strange border case for JIT optimization.
The following program is not a "Microbenchmark" and not intended to reliably measure an execution ...
46
votes
11
answers
10k
views
JIT compiler vs offline compilers
Are there scenarios where JIT compiler is faster than other compilers like C++?
Do you think in the future JIT compiler will just see minor optimizations, features but follow a similar performance, ...
46
votes
2
answers
19k
views
Why is it hard to beat AOT compiler with a JIT compiler (in terms of app. performance)?
I was thinking that JIT compilers will eventually beat AOT compilers in terms of the performance of the compiled code, due to the inherent advantage of JIT (can use information available only at ...
45
votes
7
answers
3k
views
Does the .NET CLR Really Optimize for the Current Processor
When I read about the performance of JITted languages like C# or Java, authors usually say that they should/could theoretically outperform many native-compiled applications. The theory being that ...
44
votes
5
answers
3k
views
Why does adding local variables make .NET code slower
Why does commenting out the first two lines of this for loop and uncommenting the third result in a 42% speedup?
int count = 0;
for (uint i = 0; i < 1000000000; ++i) {
var isMultipleOf16 = i % ...
41
votes
8
answers
13k
views
How to generate and run native code dynamically?
I'd like to write a very small proof-of-concept JIT compiler for a toy language processor I've written (purely academic), but I'm having some trouble in the middle-altitudes of design. Conceptually, ...
39
votes
5
answers
2k
views
Can only 'perl6' parse Perl 6?
There's that (relatively) well known Perl axiom, "Only perl can parse Perl." I'm wondering, will that remain true for Perl 6?
Expanding the discussion... I thought of this question given the ...
38
votes
2
answers
24k
views
When does ahead-of-time (AOT) compilation happen?
I'm using C#.NET for a web application. I've read that JIT compilation happens at run-time, which means(correct me if I'm wrong) that the compilation will happen when the request hits IIS.
Another ...