-
Notifications
You must be signed in to change notification settings - Fork 378
Disable Clang optimizations for Session::get*LibraryCode() functions
#9069
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Disable Clang optimizations for Session::get*LibraryCode() functions
#9069
Conversation
Clang was taking around 10 minutes to compile `slang-embedded-core-module-source.cpp` with optimizations. Disabling optimizations for these functions reduced the compilation time to about 12 seconds on my machine (Intel Core Ultra 7 165H), and had no noticeable impact on run-time performance. Run-time performance with optimizations: ``` $ hyperfine --shell=none './build/generators/Release/bin/slang-bootstrap -archive-type riff-lz4 -save-core-module-bin-source slang-core-module-generated.h -save-glsl-module-bin-source slang-glsl-module-generated.h' Benchmark 1: ./build/generators/Release/bin/slang-bootstrap -archive-type riff-lz4 -save-core-module-bin-source slang-core-module-generated.h -save-glsl-module-bin-source slang-glsl-module-generated.h Time (mean ± σ): 2.545 s ± 0.035 s [User: 2.333 s, System: 0.210 s] Range (min … max): 2.496 s … 2.620 s 10 runs ``` Run-time performance without optimizations: ``` $ hyperfine --shell=none './build/generators/Release/bin/slang-bootstrap -archive-type riff-lz4 -save-core-module-bin-source slang-core-module-generated.h -save-glsl-module-bin-source slang-glsl-module-generated.h' Benchmark 1: ./build/generators/Release/bin/slang-bootstrap -archive-type riff-lz4 -save-core-module-bin-source slang-core-module-generated.h -save-glsl-module-bin-source slang-glsl-module-generated.h Time (mean ± σ): 2.564 s ± 0.039 s [User: 2.350 s, System: 0.213 s] Range (min … max): 2.512 s … 2.614 s 10 runs ``` Disabling optimizations also makes `slang-embedded-core-module-source.cpp.o` slightly smaller: - 7.84 MiB with optimizations, - 7.37 MiB without optimizations. Fixes shader-slang#9054.
|
I think we still want to enable the optimization for the release package and anybody building Slang from source code. |
|
These functions are only called in the following cases:
As I've shown, disabling optimizations for these functions has no noticeable impact on Clang takes 11-15x as long as GCC to compile this file, and >90% of the compilation time is spent on one single LLVM optimization pass. There is something wrong with LLVM here. See llvm/llvm-project#132554. Why make this more complex just so we can only optionally work around a bug in LLVM, when the workaround shows no downsides? |
|
I see the point. |
jkwak-work
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
Let's go with this simpler approach rather than adding a new CMake option.
jkiviluoto-nv
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM but stating the runtime impact in comment makes sense.
jkiviluoto-nv
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Clang was taking around 10 minutes to compile
slang-embedded-core-module-source.cppwith optimizations. Disablingoptimizations for these functions reduced the compilation time to about
12 seconds on my machine (Intel Core Ultra 7 165H), and had no
noticeable impact on run-time performance.
Run-time performance with optimizations:
Run-time performance without optimizations:
Disabling optimizations also makes
slang-embedded-core-module-source.cpp.oslightly smaller:Fixes #9054.