[.net] JIT Compiler

Started by
6 comments, last by Holy Fuzz 18 years, 10 months ago
Is there is any way for my program to tell the .Net JIT to finish compiling the entire app? I know that the JIT compiles a function when the function is first called, but this can cause a slightly noticable delay on old computers when suddenly a lot of new code is executed (certain actions that do not load any resources but still produce a small delay when they are first performed). What I'd like to do is get all of the compiling done on the initial lode, so that these slight delays do not happen. Any way to do this? Thanks. - Fuzz
Advertisement
I believe that install time code generation is what you need. The relevant utility is Native Image Generator (ngen). There is lots of information in this article.
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.
Note that using NGen will not speed up your app, in most case it will slow it down. JIT makes a lot of optimizations, by using Ngen you loose most of them.
Thanks for the info.

It is my understanding after reading the articles Promit linked that NGen is run on the client computer (say during installation) and invokes the JIT, which performs all optimizations for that computer's architecture. Is this understanding correct?

The problem with NGen is that it's a little inconvenient. Either the user would have to run it on my program or the installer would (which isn't a big deal, but I'd have to figure out how to do it).

So there isn't any API or anything that I can call which tells the JIT to finish compiling?

Thanks!
There are tons of information why you shouldn't do what you're asking for, and why you shouldn't use NGen. Solve your problems in another way. What exact code paths are causing the problem? Make sure to call that code during startup instead to avoid that problems.
On low-end machines, there is a small (< second) delay when the first order is given to a unit, which executes code such as pathfinding, AI, logic, etc... After that, no delay at all. Calling this code during startup sounds like a hack, not to mention impossible or at least extremely impracticle.
It's much less of a hack than using something like NGen. You could easily do some of these calls, by making the first unit you create move to the block he is currently standing in, or some similar 'dummy' move. You should be able to call this 'hack' right after your loading, just before your game loop begins.
A hack, I say. A hack!

NGen isn't much better though. It requires being run under an administrator account, so isn't very useful.

This topic is closed to new replies.

Advertisement