You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
main.rego:10 is the json.match_schema call where the CycloneDX schema is being used. main.rego:12 uses a much smaller schema. That's 288,827 vs 63 microseconds.
Version: 0.68.0
Build Commit: db53d77c482676fadd53bc67a10cf75b3d0ce00b
Build Timestamp: 2024-08-29T15:23:19Z
Build Hostname: 3aae2b82a15f
Go Version: go1.22.5
Platform: linux/amd64
WebAssembly: available
Steps To Reproduce
See description.
Expected behavior
Validation of object should not take longer than 1ms.
The text was updated successfully, but these errors were encountered:
Looking into this briefly, and almost all of that time is spent in loading the JSON schema, not actually validating.
This loading isn't cached either, so each call is going to repeat loading the schema. Using a cached schema makes things... faster, to say the least. Notice the use of gojsonschema.NewSchema(sl) below, where the returned schema is reused:
Short description
The
json.match_schema
function takes much longer when the JSON schema is significantly large.I created a simple reproducer here: https://github.com/lcarva/opa-json-schema-perf
(Schema too large for rego playground)
The reproducer validates a small object against the CycloneDX SBOM JSON Schema (about 5k lines long).
main.rego:10
is thejson.match_schema
call where the CycloneDX schema is being used.main.rego:12
uses a much smaller schema. That's 288,827 vs 63 microseconds.Steps To Reproduce
See description.
Expected behavior
Validation of object should not take longer than 1ms.
The text was updated successfully, but these errors were encountered: