apache / accumulo-access

Apache Accumulo Access Control Library
https://accumulo.apache.org
Apache License 2.0
4 stars 11 forks source link

Avoids looping when evaluating single set of authorizations #71

Closed keith-turner closed 4 months ago

keith-turner commented 4 months ago

Simplified the code to avoid looping when there is a single set of authorizations. This change was made in an attempt to improve performance and it did very slightly.

Before this change saw the following.

Benchmark                                     Mode  Cnt   Score   Error   Units
AccessExpressionBenchmark.measureEvaluation  thrpt   12  13.609 ± 0.300  ops/us

And after this change saw the following.

Benchmark                                     Mode  Cnt   Score   Error   Units
AccessExpressionBenchmark.measureEvaluation  thrpt   12  13.806 ± 0.254  ops/us

The performance improvement is slight so maybe not worthwhile. However this change simplified the evaluator code a good bit, so that is worthwhile.

keith-turner commented 4 months ago

Was looking at #69 and noticed how that code mimicked the existing code with loops like the following for the Accumulo code. Was thinking the inner loop is usually a singleton list and it would be nice to get rid of the loop when it is a singleton. That is what this PR does, it removes the inner loop when its singleton.

for(var expression : expressions) {
   for(var evaluator : evaluators){
       // evaluate expression using evaluator
   }
}