Commit 91c0bae
authored
Enabling OPA AST optimizations in Skipper to store AST values in in-memory store (#3514)
**Context:**
With open-policy-agent/opa#7125 Open Policy
Agent introduced an option to read AST values from in-memory storage
instead of interfaces/slices.
When enabled it is expected to improve latency as this removes the time
spent converting raw data values to AST during policy evaluation. The
memory footprint of the store will increase, as processed AST values
would take more space in memory than the corresponding raw data values,
but overall memory usage of OPA might remain more stable over time, as
pre-converted data is shared across evaluations and isn't recomputed for
each evaluation.
With this PR, the option
`enable-open-policy-agent-data-preprocessing-optimization` is supported
as a Skipper configuration at OPA registry level. In other words, when
enabled it will be enabled for all the OPA systems running within the
same Skipper ingress.
### Benchmark test results show huge improvments
A 1000 run of the benchmark comparison.
For the simple policy,
<img width="805" alt="image" src="https://github.com/user-attachments/assets/b4a71b03-ed10-440f-bcd5-05a3e9d3dbaf" />
<google-sheets-html-origin><!--td {border: 1px solid #cccccc;}br {mso-data-placement:same-cell;}-->
| ns/op _default | ns/op _optimized | B/op _default | B/op _optimized | allocs/op _default | allocs/op _optimized
-- | -- | -- | -- | -- | -- | --
Median | 24727.5 | 25016 | 18945 | 18961 | 308 | 309
Average | 26727.107 | 27058.068 | 18945.996 | 18961.234 | 308 | 309
P99 | 37737.5 | 39558.05 | 18951 | 18967 | 308 | 309
Max | 44914 | 49197 | 18953 | 18968 | 308 | 309
Min | 23375 | 23899 | 18945 | 18961 | 308 | 309
Deviation | 3703.249928 | 3840.160723 | 1.550609038 | 0.9110840104 | 0 | 0
For the slightly complex policy,
<img width="778" alt="image" src="https://github.com/user-attachments/assets/c5cd93d2-38cc-47ef-b6b4-f31cad91c461" />
**Complex Policy**
<google-sheets-html-origin><!--td {border: 1px solid #cccccc;}br {mso-data-placement:same-cell;}-->
| ns/op _default | ns/op _optimized | B/op _default | B/op _optimized | allocs/op _default | allocs/op _optimized
-- | -- | -- | -- | -- | -- | --
Median | 1021329 | 28488.5 | 832732 | 20386 | 13990 | 336
Average | 1083208.684 | 29921.284 | 832734.342 | 20386.162 | 13990.147 | 336
P99 | 1612204.06 | 36141.25 | 832751 | 20388 | 13991 | 336
Max | 2908902 | 53455 | 832797 | 20394 | 13991 | 336
Min | 985625 | 26690 | 832726 | 20385 | 13990 | 336
Deviation | 140331.5701 | 3317.752934 | 7.238607147 | 1.144143813 | 0.3542831022 | 0
Signed-off-by: Pushpalanka Jayawardhana <pushpalanka.jayawardhana@zalando.de>1 parent 0d0142d commit 91c0bae
9 files changed
Lines changed: 4716 additions & 70 deletions
File tree
- config
- filters/openpolicyagent
- opaauthorizerequest
- testResources/data-pre-procesing-visible-impact
- data
- policy
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
297 | 297 | | |
298 | 298 | | |
299 | 299 | | |
300 | | - | |
301 | | - | |
302 | | - | |
303 | | - | |
304 | | - | |
305 | | - | |
306 | | - | |
307 | | - | |
308 | | - | |
309 | | - | |
310 | | - | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
311 | 312 | | |
312 | 313 | | |
313 | 314 | | |
| |||
536 | 537 | | |
537 | 538 | | |
538 | 539 | | |
| 540 | + | |
539 | 541 | | |
540 | 542 | | |
541 | 543 | | |
| |||
993 | 995 | | |
994 | 996 | | |
995 | 997 | | |
996 | | - | |
997 | | - | |
998 | | - | |
999 | | - | |
1000 | | - | |
1001 | | - | |
1002 | | - | |
1003 | | - | |
1004 | | - | |
1005 | | - | |
1006 | | - | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
1007 | 1010 | | |
1008 | 1011 | | |
1009 | 1012 | | |
| |||
Lines changed: 67 additions & 35 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
343 | 343 | | |
344 | 344 | | |
345 | 345 | | |
| 346 | + | |
| 347 | + | |
346 | 348 | | |
347 | 349 | | |
348 | 350 | | |
| |||
357 | 359 | | |
358 | 360 | | |
359 | 361 | | |
360 | | - | |
361 | | - | |
362 | | - | |
363 | | - | |
364 | | - | |
365 | | - | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
366 | 365 | | |
367 | 366 | | |
368 | | - | |
369 | | - | |
370 | | - | |
371 | | - | |
372 | | - | |
373 | | - | |
374 | | - | |
375 | | - | |
376 | | - | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
377 | 380 | | |
378 | 381 | | |
379 | | - | |
380 | | - | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
381 | 388 | | |
382 | | - | |
383 | | - | |
| 389 | + | |
| 390 | + | |
384 | 391 | | |
385 | | - | |
386 | | - | |
387 | | - | |
388 | | - | |
389 | | - | |
390 | | - | |
391 | | - | |
392 | | - | |
393 | | - | |
394 | | - | |
395 | | - | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
396 | 398 | | |
397 | | - | |
398 | | - | |
399 | | - | |
400 | | - | |
401 | | - | |
402 | 399 | | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
403 | 428 | | |
404 | 429 | | |
405 | 430 | | |
| |||
506 | 531 | | |
507 | 532 | | |
508 | 533 | | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
509 | 541 | | |
510 | 542 | | |
511 | 543 | | |
| |||
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
0 commit comments