Giter Site home page Giter Site logo

Comments (3)

patrick-east avatar patrick-east commented on July 26, 2024

A quick look at where the OPA eval happens (I think? Correct me if I'm wrong on this): https://github.com/forseti-security/config-validator/blob/258b9eb9e8e6d6e91da8edbcab771d19ece3fad8/pkg/gcv/cf/cf.go#L214-L222 it appears that the query is passed in as a string for each evaluation. If the actual eval is fast it wouldn't be super surprising to see that a large chunk of time is spent parsing the query on each of the benchmark loop iterations. I see the topdown.eval entries only taking up a few % on that screenshot so it seems likely that this is the case, especially if the iteration count was large for the benchmark.

More recently in OPA we have added a set of new API's on the rego package that prepares the rego.Rego object as a "prepared query" and can then be re-used for evaluations that eliminate the need to do the query prep (and a number of other things, depending on the options passed in). You can then use it with different inputs for evaluations and save a bunch of time, especially on repeated queries where only input is changing (which it looks like in this case here). Check out https://pkg.go.dev/github.com/open-policy-agent/[email protected]/rego?tab=doc#example-Rego.PrepareForEval

Again, just from a quick look. I might have totally missed some other spot that is doing additional parsing.

from frameworks.

patrick-east avatar patrick-east commented on July 26, 2024

@maxsmythe, as discussed, to parse the query ahead of time you'd use https://godoc.org/github.com/open-policy-agent/opa/ast#ParseBody and then use this option to pass in the parsed query https://godoc.org/github.com/open-policy-agent/opa/rego#ParsedQuery

from frameworks.

willbeason avatar willbeason commented on July 26, 2024

This has been resolved with #202 and #206 . We only parse Template rego once, and we don't recompile already existing Templates.

from frameworks.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.