Skip to content

docs: Speed up layers settings schema validation - #426

Merged
christophe-lunarg merged 1 commit into
mainfrom
layer-settings-schema-fix
Oct 29, 2026
Merged

christophe-lunarg merged 1 commit into
mainfrom
layer-settings-schema-fix

Conversation

@christophe-lunarg

Copy link
Copy Markdown
Contributor

Each setting was validated against a 'oneOf' of the 10 setting type definitions. 'oneOf' evaluates every branch, and most branches define nested 'settings', so nested settings were validated again under each branch, with a cost growing with the nesting depth.

Select the setting definition with 'if'/'then' on the setting 'type' instead, so each setting is validated once against its own definition. The setting definitions are unchanged. The type enums of the branches are disjoint, so the validation result is identical; errors now report the actual issue instead of a 'oneOf' failure across all types.

Moving to JSON Schema 2020-12 was measured too and brings no speedup.

Results are unchanged on the 97 unique layer manifests found locally (all installed SDKs, VulkanTools, Vulkan-Profiles, Loader test corpus): 89 pass and 8 fail with both schemas.

Validation time with jsonschema 4.26, best of 5, SDK 1.4.363.0 macOS layer manifests:

Manifest KB Before After Speedup
VkLayer_khronos_validation 176.4 283.0ms 15.6ms 18.1x
VkLayer_khronos_profiles 69.2 50.2ms 8.7ms 5.8x
VkLayer_gfxreconstruct 28.7 18.2ms 2.7ms 6.8x
VkLayer_api_dump 13.2 8.5ms 1.7ms 5.1x
VkLayer_screenshot 4.3 0.44ms 0.33ms 1.3x
VkLayer_khronos_shader_object 4.3 0.27ms 0.18ms 1.5x
VkLayer_khronos_synchronization2 1.9 0.17ms 0.13ms 1.3x

All 12 macOS and iOS manifests: 702.8ms before, 55.8ms after (12.6x). Running validate_json_schema.py on each of them: 1.42s before, 0.75s after, the remainder being mostly Python startup and jsonschema import.

Each setting was validated against a 'oneOf' of the 10 setting type
definitions. 'oneOf' evaluates every branch, and most branches define
nested 'settings', so nested settings were validated again under each
branch, with a cost growing with the nesting depth.

Select the setting definition with 'if'/'then' on the setting 'type'
instead, so each setting is validated once against its own definition.
The setting definitions are unchanged. The type enums of the branches
are disjoint, so the validation result is identical; errors now report
the actual issue instead of a 'oneOf' failure across all types.

Moving to JSON Schema 2020-12 was measured too and brings no speedup.

Results are unchanged on the 97 unique layer manifests found locally
(all installed SDKs, VulkanTools, Vulkan-Profiles, Loader test corpus):
89 pass and 8 fail with both schemas.

Validation time with jsonschema 4.26, best of 5, SDK 1.4.363.0 macOS
layer manifests:

  Manifest                          KB   Before    After  Speedup
  VkLayer_khronos_validation     176.4  283.0ms   15.6ms    18.1x
  VkLayer_khronos_profiles        69.2   50.2ms    8.7ms     5.8x
  VkLayer_gfxreconstruct          28.7   18.2ms    2.7ms     6.8x
  VkLayer_api_dump                13.2    8.5ms    1.7ms     5.1x
  VkLayer_screenshot               4.3   0.44ms   0.33ms     1.3x
  VkLayer_khronos_shader_object    4.3   0.27ms   0.18ms     1.5x
  VkLayer_khronos_synchronization2 1.9   0.17ms   0.13ms     1.3x

All 12 macOS and iOS manifests: 702.8ms before, 55.8ms after (12.6x).
Running validate_json_schema.py on each of them: 1.42s before, 0.75s
after, the remainder being mostly Python startup and jsonschema import.
@christophe-lunarg christophe-lunarg self-assigned this Oct 29, 2026
@christophe-lunarg
christophe-lunarg merged commit 1e82d41 into main Oct 29, 2026
31 checks passed
@christophe-lunarg
christophe-lunarg deleted the layer-settings-schema-fix branch October 29, 2026 15:34
@spencer-lunarg

Copy link
Copy Markdown
Contributor

would have been faster if you used WebGPU

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants