-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
panic in virtual document cache #1197
Labels
Comments
tsandall
added a commit
to tsandall/opa
that referenced
this issue
Jun 24, 2019
Previously the virtual cache was implemented using a map[ast.Value]... which works for scalar key terms but not composites (because they're not comparable.) This change updates the virtual cache to use a util.HashMap that supports all term kinds. This prevents the virtual cache lookup/insert from panicing when a key like data.x.y[[1]] is received. In addition to fixing the virtual cache, this change updates the Term.Equal() function to include an early-exit for types that do not allocate in their Equal() functions. The early-exit was added because swapping out the map[ast.Value]... for util.HashMap introduced allocations into the virtual cache lookup/insert operations which doubled the benchmark latency. See below for benchmark results before/after this commit. ``` BEFORE ====== goos: linux goarch: amd64 pkg: github.com/open-policy-agent/opa/topdown BenchmarkVirtualCache-8 5000000 284 ns/op 0 B/op 0 allocs/op PASS ok github.com/open-policy-agent/opa/topdown 1.731s Success: Benchmarks passed. AFTER ===== goos: linux goarch: amd64 pkg: github.com/open-policy-agent/opa/topdown BenchmarkVirtualCache-8 5000000 322 ns/op 0 B/op 0 allocs/op PASS ok github.com/open-policy-agent/opa/topdown 1.969s Success: Benchmarks passed. ``` This change will also let us memoize virtual sets using the same cache (see open-policy-agent#822). Fixes open-policy-agent#1197 Signed-off-by: Torin Sandall <torinsandall@gmail.com>
patrick-east
pushed a commit
that referenced
this issue
Jun 24, 2019
Previously the virtual cache was implemented using a map[ast.Value]... which works for scalar key terms but not composites (because they're not comparable.) This change updates the virtual cache to use a util.HashMap that supports all term kinds. This prevents the virtual cache lookup/insert from panicing when a key like data.x.y[[1]] is received. In addition to fixing the virtual cache, this change updates the Term.Equal() function to include an early-exit for types that do not allocate in their Equal() functions. The early-exit was added because swapping out the map[ast.Value]... for util.HashMap introduced allocations into the virtual cache lookup/insert operations which doubled the benchmark latency. See below for benchmark results before/after this commit. ``` BEFORE ====== goos: linux goarch: amd64 pkg: github.com/open-policy-agent/opa/topdown BenchmarkVirtualCache-8 5000000 284 ns/op 0 B/op 0 allocs/op PASS ok github.com/open-policy-agent/opa/topdown 1.731s Success: Benchmarks passed. AFTER ===== goos: linux goarch: amd64 pkg: github.com/open-policy-agent/opa/topdown BenchmarkVirtualCache-8 5000000 322 ns/op 0 B/op 0 allocs/op PASS ok github.com/open-policy-agent/opa/topdown 1.969s Success: Benchmarks passed. ``` This change will also let us memoize virtual sets using the same cache (see #822). Fixes #1197 Signed-off-by: Torin Sandall <torinsandall@gmail.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Actual Behavior
The virtual document cache is implemented on top of Go maps. If the ref contains an array operand, the insertion panics:
Query:
Panic:
If the ref operand is a set/object, the insertion doesn't panic, but the result will be incorrect.
Additional info
The text was updated successfully, but these errors were encountered: