AcademySoftwareFoundation / AcademySoftwareFoundation/OpenShadingLanguage

[BUG] Bad parallel performance when optimizing a group

Open
#2,005 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
2.3k
Forks
414
Avg merge
3d 1h
Merged PRs (30d)
10

Description

**Describe the bug**

In Windows, when optimizing a shader group in parallel, the performance is almost as the optimization is performed sequentially.

I tracked down the problem, in src\liboslexec\llvm_instance.cpp.

In the block inside if (use_rs_bitcode()) {
the call to ll.validate_global_mappings(names_of_unmapped_globals); triggers a global lock inside llvm.

commenting out the validation solves the problem. A possible solution would be to have an option to turn off validation, so I can turn it on only during debugging.

**OSL version and dependencies**

* OSL branch/version: 1.14.5.1
* OS: Windows
* C++ compiler: MSVC 2022
* LLVM version: 19.1.7
* OIIO version: 3.0.2

Contributor guide

Open the contributing guide

Research direction

Start in src/liboslexec/llvm_instance.cpp at the use_rs_bitcode() block and inspect the ll.validate_global_mappings(names_of_unmapped_globals) call. Trace how shader groups are optimized in parallel on Windows, then verify that validation can be disabled for normal optimization and retained when debugging without the near-sequential performance impact.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.