Open SteveL-MSFT opened 6 years ago
Good idea, I agree it is a known problem of .net assemblies to have a JIT overhead. I am surprised that there is that much potential since the PSSA dlls are relatively small.
At the moment, PSSA only does a dotnet build
and not a dotnet publish
because it can rely on PowerShell to provide all other dependencies (I had a brief discussions with James if this was OK and he said yes). Does it mean we have to publish now in order to be able to crossgen as I imagine it is platform specific or can offer better optimisation? I would certainly welcome the improvement of crossgening assemblies but if we have to publish then it would mean a much bigger installation footprint as a small downside.
Speaking about performance in general: I believe there is also a big potential to increase performance for multi-threading if we improved the current locking mechanisms (heavy locks are used and held way too long, also leading to some bugs due to some code not being thread-safe). At the moment, the CPU does not get maxed out and utilisation is only at around 3 virtual cores on an 8 core system (i.e. basically 1.5 physical cores due to hyper-threading)
The downside of crossgen is that the binaries are platform specific. Note that this isn't a high priority item and I wouldn't work to address this until PSGet supports multiple runtimes
Ok, I was suspecting that. FYI: At the moment PSSA already has to ship separate binaries for v3, 4, v5 and coreclr and at import time the module decides which binaries are appropriate.
Doing some perf tests and there's a large impact to the first time PSSA.dll is loaded due to JIT. However, after the initial JIT, execution time is MUCH faster. But for cases where PSSA is invoked just once, it's a huge cost without savings as the JIT is only in memory until the process goes away.
These times are for using PSSA recursively against all scripts in PowerShell repo:
Tiered is a new opt-in compilation feature of dotnetcore2.1 that balances startup and runtime optimizations.
My conclusion is that we should crossgen (coreclr) and ngen (fullclr) assemblies.