Repository navigation
docs: Speed up layers settings schema validation - #426
Merged
Merged
Conversation
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.
Contributor
|
would have been faster if you used WebGPU |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.