Open AndyAyersMS opened 6 years ago
I'd try instrumenting on module load and see what happens. If that would be more reliable. It might seem very redundant to instrument everything in the module, but it will be roughly proportional to the module size (like the load itself and any kind of relocation/fixups). Also, perhaps next to the cost of doing GC stress it might not be a big difference.
GcStress currently tries to instrument NGEN precompiled methods twice: once during
Module::Initialize
(with a twist for the core library) and a second time duringMethodDesc::PrepareILBasedCode
(with a twist for prejitted IL stubs).R2R precompiled methods are never instrumented, currently.
Seems like we should have only one strategy and it should apply to all cases of prejitted code.
Early instrumentation during module load is nice because it avoids race conditions that can plague on-demand instrumentation. But there is an upfront cost as potentially thousands of methods need to be instrumented but only a few of them will ever be executed.
Late instrumentation is more pay for play but must be done carefully so that no thread can see a partially instrumented method.