Is this related to the JIT compiler
Probably yes, though there are other potential sources of "lag":
- Bootstrapping the JVM and creation of the initial classloader.
- Reading and loading the application's classes, and the library classes that are used.
- Initializing the classes.
- JIT compilation.
- Heap warmup effects; e.g. the overheads of having a heap that is initially too small. (This can result on the GC running more often than normal ... until the heap reaches a size that matches the application's peak working set size.)
- Virtual memory warmup effects; e.g. the OS overheads incurred when the JVM grows the process address space and physical pages are allocated.
... and is there anything one could do to "reset" the state so that you would get the initial "lag" included with all iterations?
There is nothing you can do, apart from starting the JVM over again.
However, there are things that you can do to remove some of these sources of "lag"; e.g. turning of JIT compilation, using a large initial heap size, and running on an otherwise idle machine.
Also, the link that @Joachim contributed above is worth a thorough read.