Questions tagged [jit]

Just-In-Time compilation (JIT) is a technique used to improve the performance of interpreted code by translating it to machine code.

Introduction

From Wikipedia:

In computing, just-in-time compilation (JIT), also known as dynamic translation, is a method to improve the runtime performance of computer programs based on bytecode.

JIT compilers represent a hybrid approach, with translation occurring continuously, as with interpreters, but with caching of translated code to minimize performance degradation. They also offer handling of late-bound data types and the ability to enforce security guarantees.

In a bytecode-compiled system, source code is translated to an intermediate representation known as bytecode. The JIT compiler reads the bytecode and compiles it dynamically into machine language so the program can run faster.

Tag usage

Use the tag for questions about JIT compilers. Be sure to include other relevant tags as well. For example, if your JIT question is Java-specific, include the tag.

Further reading

1936 questions
910
votes
10 answers

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; i < 1000000000; i++) { n += 2 * (i * i); …
Stefan
  • 5,052
  • 3
  • 7
  • 12
797
votes
12 answers

Why shouldn't I use PyPy over CPython if PyPy is 6.3 times faster?

I've been hearing a lot about the PyPy project. They claim it is 6.3 times faster than the CPython interpreter on their site. Whenever we talk about dynamic languages like Python, speed is one of the top issues. To solve this, they say PyPy is 6.3…
chhantyal
  • 11,874
  • 7
  • 51
  • 77
635
votes
18 answers

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?
Michiel Borkent
  • 34,228
  • 15
  • 86
  • 149
422
votes
2 answers

Does Java JIT cheat when running JDK code?

I was benchmarking some code, and I could not get it to run as fast as with java.math.BigInteger, even when using the exact same algorithm. So I copied java.math.BigInteger source into my own package and tried this: //import…
Koen Hendrikx
  • 2,243
  • 2
  • 9
  • 7
411
votes
3 answers

.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 tried .NET 3.5 SP1. When running outside Visual…
Philip Welch
  • 4,488
  • 2
  • 20
  • 17
119
votes
5 answers

Why doesn't the JVM cache JIT compiled code?

The canonical JVM implementation from Sun applies some pretty sophisticated optimization to bytecode to obtain near-native execution speeds after the code has been run a few times. The question is, why isn't this compiled code cached to disk for…
Chinmay Kanchi
  • 62,729
  • 22
  • 87
  • 114
100
votes
9 answers

Do any JVM's JIT compilers generate code that uses vectorized floating point instructions?

Let's say the bottleneck of my Java program really is some tight loops to compute a bunch of vector dot products. Yes I've profiled, yes it's the bottleneck, yes it's significant, yes that's just how the algorithm is, yes I've run Proguard to…
Sean Owen
  • 66,182
  • 23
  • 141
  • 173
97
votes
7 answers

How to see JIT-compiled code in JVM?

Is there some way to see the native code produces by the JIT in a JVM?
alsor.net
  • 1,142
  • 1
  • 8
  • 9
95
votes
5 answers

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 native code? Is the .NET runtime (as a Virtual…
Steve
  • 11,763
  • 15
  • 70
  • 103
95
votes
7 answers

Does the Python 3 interpreter have a JIT feature?

I found that when I ask something more to Python, python doesn't use my machine resource at 100% and it's not really fast, it's fast if compared to many other interpreted languages, but when compared to compiled languages i think that the difference…
guz
  • 1,361
  • 1
  • 10
  • 13
90
votes
4 answers

What is the loop inversion technique?

I was going through a document which talks about just-in-time compiler (JIT) optimization techniques for Java. One of them was "loop inversion". And the document says: You replace a regular while loop with a do-while loop. And the do-while loop…
Trying
  • 14,004
  • 9
  • 70
  • 110
89
votes
6 answers

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 of microbenchmarking and how do you avoid…
polygenelubricants
  • 376,812
  • 128
  • 561
  • 623
85
votes
8 answers

Why are operators so much slower than method calls? (structs are slower only on older JITs)

Intro: I write high-performance code in C#. Yes, I know C++ would give me better optimization, but I still choose to use C#. I do not wish to debate that choice. Rather, I'd like to hear from those who, like me, are trying to write…
Brian Kennedy
  • 3,499
  • 3
  • 21
  • 27
84
votes
4 answers

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 into a byte array how do you jump into it to begin…
J D
  • 48,105
  • 13
  • 171
  • 274
83
votes
3 answers

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 compilation system supports 5 execution levels, basically…
Markus Weninger
  • 11,931
  • 7
  • 64
  • 137
1
2 3
99 100