[mini] Introduce job control to the JIT. Limits by active and duplicate jobs.
This shown up as a problem under parallel roslyn.
We hit frequently the case of multiple threads compiling the same method in parallel
and wasting all but one.
Another issue that happens, but infrequently, is having more threads JITing than there
are cores in the machine. Such thrashing doesn't help.
Test setup. 4/8 macbook pro compiling corlib.
Baseline:
real 0m7.665s
user 0m20.078s
sys 0m2.653s
Methods JITted using mono JIT : 22422
Total time spent JITting (sec) : 18.5365
With this patch:
real 0m6.149s
user 0m18.504s
sys 0m1.487s
Methods JITted using mono JIT : 16619
Total time spent JITting (sec) : 4.9420
New counters
JIT compile waited others : 7681
JIT compile 1+ jobs : 1
JIT compile overload wait : 67
JIT compile spurious wakeups : 14469
This results in a 20% wall clock reduction but only a 8% reduction on user.
We JIT 26% less methods, with very few duplications. Showing this drastically improves the situation.
JIT compilation time metrics are bogus due to .cctors and other sources of interference. So take it with a grain of salt.
Future work:
Based on the new counters, it's clear that the current wakeup design is suboptimal and we could further improve it by cutting on spurious wakeups.