regolibrary icon indicating copy to clipboard operation
regolibrary copied to clipboard

perf: improve workload-with-administrative-roles rule

Open isimluk opened this issue 2 months ago • 3 comments

This seems to be the slowest rule on my set-up, so I have taken a look on how to improve its performance.

It seems that it has complexity O(n) = n^5 as it iterates over all the data 5 times.

Limiting the inner loops by object kind yields 23.3% improvement on my set-up.

I would be interested to hear what the maintainers think. It feels worth it, code is not considerably worse in any way and 23.3% sounds great and the benefits will grow with a cluster size.

Metodology

Nothing scientific, just:

	start := time.Now()
	responses, err = opaProcessor.regoEval(ctx, inputObj, compiled, *data)
	elapsed := time.Since(start)
	fmt.Printf("Execution took %s\n", elapsed)

Readings before this patch (avg: 677.1890104ms)

  • 681.387391ms
  • 652.945844ms
  • 694.478191ms
  • 646.288995ms
  • 710.844631ms

Readings after this patch (avg: 519.11271779999ms)

  • 496.79941ms
  • 521.634789ms
  • 507.044831ms
  • 536.090881ms
  • 533.993678ms

isimluk avatar Oct 15 '25 15:10 isimluk