Closed john-h-kastner-aws closed 6 months ago
I suggest we store only the first 5 (or some other N) attribute names in the available_attrs
field of the error, maybe with a usize indicating how many total attributes there were. This is possibly a breaking change, so we could make it for 4.0 (along with the other error restructuring in #745).
Resolved by #887
Describe the improvement you'd like to request
Attempting to access an non-existing attribute on a large record causes unexpectedly high latency for authorization requests.
In the following benchmarks, I construct a context record containing 100,000 attributes and then evaluate two policies, one that accesses an existing attribute, and another that access an attribute that does not exist, resulting in an evaluation error. The error case has much worse performance, taking over a millisecond while the non-error case is measured in nanoseconds.
This behavior is due to error case rebuilding the context record as a
Vec
of its keys on this line:https://github.com/cedar-policy/cedar/blob/57d3463937aafd907ea22602bf85dd63e8764d14/cedar-policy-core/src/evaluator.rs#L774
Replacing this line with
vec![]
and re-running the benchmarks shows much better times, but we would like to keep the nicer error message if possible.Benchmark used:
Describe alternatives you've considered
No response
Additional context
No response
Is this something that you'd be interested in working on?