forked from OSchip/llvm-project
[cmake] Speed up check-llvm 5x by delay loading shell32 and ole32
Summary: Previously, check-llvm on my Windows 10 workstation took about 300s to run, and it would lock up my mouse. Now, it takes just under 60s. Previously running the tests only used about 15% of the available CPU time, now it uses up to 60%. Shell32.dll and ole32.dll have direct dependencies on user32.dll and gdi32.dll. These DLLs are mostly used to for Windows GUI functionality, which most LLVM tools don't need. It seems that these DLLs acquire and release some system resources on startup and exit, and that requires acquiring the same highly contended lock discussed in this post: https://randomascii.wordpress.com/2017/07/09/24-core-cpu-and-i-cant-move-my-mouse/ Most LLVM tools still have a transitive dependency on SHGetKnownFolderPathW, which is used to look up the user home directory and local AppData directory. We also use SHFileOperationW to recursively delete a directory, but only LLDB and clang-doc use this today. At some point, we might consider removing these last shell32.dll deps, but for now, I would like to take this free performance. Many thanks to Bruce Dawson for suggesting this fix. He looked at an ETW trace of an LLVM test run, noticed these DLLs, and suggested avoiding them. Reviewers: zturner, pcc, thakis Subscribers: mgorny, llvm-commits, hiraditya Differential Revision: https://reviews.llvm.org/D51952 llvm-svn: 342002
This commit is contained in:
parent
fe0512d575
commit
697d6cb8ee
|
@ -38,6 +38,12 @@ elseif( CMAKE_HOST_UNIX )
|
|||
endif()
|
||||
endif( MSVC OR MINGW )
|
||||
|
||||
# Delay load shell32.dll if possible to speed up process startup.
|
||||
set (delayload_flags)
|
||||
if (MSVC)
|
||||
set (delayload_flags delayimp -delayload:shell32.dll -delayload:ole32.dll)
|
||||
endif()
|
||||
|
||||
add_llvm_library(LLVMSupport
|
||||
AMDGPUMetadata.cpp
|
||||
APFloat.cpp
|
||||
|
@ -164,7 +170,7 @@ add_llvm_library(LLVMSupport
|
|||
${LLVM_MAIN_INCLUDE_DIR}/llvm/ADT
|
||||
${LLVM_MAIN_INCLUDE_DIR}/llvm/Support
|
||||
${Backtrace_INCLUDE_DIRS}
|
||||
LINK_LIBS ${system_libs}
|
||||
LINK_LIBS ${system_libs} ${delayload_flags}
|
||||
)
|
||||
|
||||
set_property(TARGET LLVMSupport PROPERTY LLVM_SYSTEM_LIBS "${system_libs}")
|
||||
|
|
Loading…
Reference in New Issue