From cd8594dc2ed408a925548a6b8fd95a7f2500a724 Mon Sep 17 00:00:00 2001 From: Mike Danes Date: Sun, 19 Aug 2018 13:29:49 +0300 Subject: [PATCH] Speed-up JIT dump Add a config option that allows routing JIT's stdout output to a specified file. jitStartup disables stdio buffering on its stdout created stream and that makes large dumps (such as the ones generated by jit-diff) 2-4x slower. Simply enabling buffering is somewhat problematic, it would require occasional flushing to avoid losing output in the case of a crash and can also result in mingled output if crossgen decides to print something via its own stdout stream. file fix Commit migrated from https://github.com/dotnet/coreclr/commit/193e3134e3726b933111b46617be9bee05084ee2 --- src/coreclr/src/jit/ee_il_dll.cpp | 15 +++++++++++---- src/coreclr/src/jit/jitconfigvalues.h | 1 + 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/coreclr/src/jit/ee_il_dll.cpp b/src/coreclr/src/jit/ee_il_dll.cpp index 88612bc..5153363 100644 --- a/src/coreclr/src/jit/ee_il_dll.cpp +++ b/src/coreclr/src/jit/ee_il_dll.cpp @@ -80,9 +80,16 @@ extern "C" void __stdcall jitStartup(ICorJitHost* jitHost) assert(!JitConfig.isInitialized()); JitConfig.initialize(jitHost); -#if defined(_HOST_UNIX_) - jitstdout = procstdout(); -#else // !_HOST_UNIX_ +#ifdef DEBUG + const wchar_t* jitStdOutFile = JitConfig.JitStdOutFile(); + if (jitStdOutFile != nullptr) + { + jitstdout = _wfopen(jitStdOutFile, W("a")); + assert(jitstdout != nullptr); + } +#endif // DEBUG + +#if !defined(_HOST_UNIX_) if (jitstdout == nullptr) { int stdoutFd = _fileno(procstdout()); @@ -106,6 +113,7 @@ extern "C" void __stdcall jitStartup(ICorJitHost* jitHost) } } } +#endif // !_HOST_UNIX_ // If jitstdout is still null, fallback to whatever procstdout() was // initially set to. @@ -113,7 +121,6 @@ extern "C" void __stdcall jitStartup(ICorJitHost* jitHost) { jitstdout = procstdout(); } -#endif // !_HOST_UNIX_ #ifdef FEATURE_TRACELOGGING JitTelemetry::NotifyDllProcessAttach(); diff --git a/src/coreclr/src/jit/jitconfigvalues.h b/src/coreclr/src/jit/jitconfigvalues.h index 26c5ccc..49b8c7a 100644 --- a/src/coreclr/src/jit/jitconfigvalues.h +++ b/src/coreclr/src/jit/jitconfigvalues.h @@ -113,6 +113,7 @@ CONFIG_INTEGER(JitSplitFunctionSize, W("JitSplitFunctionSize"), 0) // On ARM, us CONFIG_INTEGER(JitSsaStress, W("JitSsaStress"), 0) // Perturb order of processing of blocks in SSA; 0 = no stress; 1 = // use method hash; * = supplied value as random hash CONFIG_INTEGER(JitStackChecks, W("JitStackChecks"), 0) +CONFIG_STRING(JitStdOutFile, W("JitStdOutFile")) // If set, sends JIT's stdout output to this file. CONFIG_INTEGER(JitStress, W("JitStress"), 0) // Internal Jit stress mode: 0 = no stress, 2 = all stress, other = vary // stress based on a hash of the method and this value CONFIG_INTEGER(JitStressBBProf, W("JitStressBBProf"), 0) // Internal Jit stress mode -- 2.7.4