KhronosGroup / KhronosGroup/Vulkan-ValidationLayers
codegen makes switch statements that require massive stack space
- Dominant language
- C++
- Stars
- 1k
- Forks
- 504
- Avg merge
- 11h 35m
- Merged PRs (30d)
- 224
Description
This is for following up after https://github.com/KhronosGroup/Vulkan-ValidationLayers/pull/7684
There's several functions in generated code that require many kb of stack space:
- StatelessValidation::ValidatePnextStructContents() : ~70kb
- StatelessValidation::ValidatePnextFeatureStructContents(): ~70kb
- AddFeature(): ~49kb
Probably there are others. The easiest way to spot these is to view disassembly in MSVC and look for instructions like this before the beginning of the switch statement:
```
00007FF7844DF0C5 mov eax,0C2B8h
00007FF7844DF0CA call __chkstk (07FF783690622h)
00007FF7844DF0CF sub rsp,rax
```
0C2B8h = 49kb
We've found that important applications have trouble with stack sizes > 100kb. We should consider replacing these massive switch statements with enum -> function lookup tables.
Contributor guide
Research direction
Start by inspecting the generated implementations of StatelessValidation::ValidatePnextStructContents(), StatelessValidation::ValidatePnextFeatureStructContents(), and AddFeature(), then use MSVC disassembly to locate the large stack allocations before their switch statements. The work is done when the affected generated paths avoid massive switch-related stack usage and the resulting stack requirements are verified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- performance, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100