Skip to content
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

perf: cost of indexing greatly reduced #7370

Merged
merged 1 commit into from
Feb 19, 2025

Conversation

anderseknert
Copy link
Member

And many smaller performance improvements. The indexer recycling results is one of the most impactful performance improvements as of yet, and alone saves more than 2 million allocations in the Regal lint benchmark. The indexer is also more efficient, as values are no longer stored on the struct. Thanks @tsandall for that code!

Also included a bunch of small improvements from my perf branches.

Before

1209043041 ns/op	3255157224 B/op	64026192 allocs/op

After

1197131792 ns/op	3194124864 B/op	61876276 allocs/op

var schemaDefinitions = map[SchemaFile]interface{}{}
var schemaDefinitions = map[SchemaFile]any{}

var loadOnce = sync.OnceValue(func() error {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This just moves initialization from init() to when it's actually needed. This isn't so much about performance, but just that there's no need to init authoziation policy in opa eval, check, etc

@anderseknert anderseknert force-pushed the perf3 branch 5 times, most recently from d7b2e71 to 418eebf Compare February 19, 2025 08:18
internal/compiler/utils.go Show resolved Hide resolved
v1/ast/index.go Show resolved Hide resolved
Copy link
Contributor

@srenatus srenatus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

And many smaller performance improvements. The indexer recycling results
is one of the most impactful performance improvements as of yet, and alone
saves more than 2 million allocations in the Regal lint benchmark. The indexer
is also more efficient, as `values` are no longer stored on the struct. Thanks
@tsandall for that code!

Also included a bunch of small improvements from my perf branches.

**Before**
```
1209043041 ns/op	3255157224 B/op	64026192 allocs/op
```

**After**
```
1197131792 ns/op	3194124864 B/op	61876276 allocs/op
```

Signed-off-by: Anders Eknert <[email protected]>
@anderseknert anderseknert enabled auto-merge (squash) February 19, 2025 10:09
@anderseknert anderseknert merged commit 61d3b7b into open-policy-agent:main Feb 19, 2025
27 checks passed
@anderseknert anderseknert deleted the perf3 branch February 19, 2025 10:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants