Jit Is For Prototypes

JIT = JustInTimeCompilation

JIT Compilers are great for prototyping, but a commercial product, especially a high performance computer game, should be compiled using a full-strength compiler and should ship as binary.


Problem:

We require

Therefore:

Develop in a rapid turn around environment. However, as code design stabilizes it should migrate to pre-compiled modules, and the final shipping product should be entirely precompiled using a full-strength compiler. By doing so:

For best results the JIT compiler and full-strength compiler should compile exactly the same language, indeed one compiler with a switch that lets you set JIT mode or pre-compile mode could well be best. This way very little additional work is involved in making the transition from prototyping to production version. But:

As JIT technology improves, the justifications for this approach may be reduced:



The page title is inspired by SpecializationIsForInsects. There is a thematic link too, in that:

See Also: InterpretersAreForTesting



Discussion

[Initially between EddieEdwards and JamesCrook, but now made OpenAuthor]

As I see it the JitIsForPrototypes approach is a temporary phase, and it really comes from the immaturity of JIT technology. If space and speed overheads for JIT compilation were demonstrably below the 1% level, the other advantages of JIT for production code as well as 'just for prototypes' would shine through.

Q: Games programmers in general want speed above all else, and when they want to cut 10% off their time, they will say "why does this stupid *JIT compiler* take 10% of runtime to begin with?"

A1: Done well JIT should take closer to 1%. On code you run a thousand times the JIT overhead is tiny in percentage terms. On code you run once performance is nearly irrelevant - in some systems such code is interpreted as doing so reduces transfer times and frees memory. JIT compilers can potentially be very efficient. Conventional compilers spend MOST of their time in tokenization and file I/O. A JIT compiler does not have to do that. Target speed for a JIT compiler would be around 10,000 lines per second on a P100. [Compare Rick Booth's figure of 50,000 lines assembler per second on a P100 including tokenization].

A2: Think of JIT compilation as a very advanced method for compressing / decompressing exes.

A3: A collision detection demo might convince skeptics of JITs ability to optimize beyond what a normal compile time compiler can do. This source code is table driven and can detect collisions between two objects. It is fast when objects are far apart but gets slower the closer and more complex the decision is. The JIT derives custom code for these decisions. Moreover, only the code for collisions between objects which have actually come close together gets generated, (for the relative displacement directions in which they have approached). This is a 'virtual program'. Were it written out in full it would be impractically large.


This page made me immediately think of the SynthesisOs. (But I see you've already noticed it.) -- JeffGrigg


CategoryOptimization


EditText of this page (last edited July 26, 2008) or FindPage with title or text search