google-research / raksha

Apache License 2.0
35 stars 17 forks source link

[Authorization Logic // C++] Performance Improvement in Translation to Datalog #267

Open aferr opened 2 years ago

aferr commented 2 years ago

cc: @markww

Improve performance by eliminating extra copies of predicates when translating from authorization logic to Datalog. This can be done by extending the dlir.h with a predicate modifier class like:

class PredicateModifier {
  /* ... */
  private:
  absl::string_view modifier_;
  Predicate wrapped_predicate_;
};

and by replacing occurances of Predicate in the dlir.h tree with another new class with a private member of type std::variant<Predicate, PredicateModifier.

The implementation of PushOntoPred of dlir.h would then need to be updated to to produce PredicateModifiers instead of just predicates.

bgogul commented 2 years ago

I don't have the complete context of the new code. However, holding on to absl::string_view has lifetime implications.

aferr commented 2 years ago

In case it is helpful, the rest of the context is this thread

aferr commented 2 years ago

ARGH, that link is useless, and there doesn't appear to be a way to get a useful one :( :)

markww commented 2 years ago

Just to address the confusion here: when I was suggesting absl::string_view, I was mostly suggesting it for the parameters that lead up to the creating of Predicates (or soon-to-be PredicateModifiers) so you didn't have to wrap string literals in std::string constructor calls. Once you get to actually creating a long-lived object that refers to a string, I think it is appropriate to make PredicateModifier hold onto its own std::string to eliminate lifetime concerns, as @bgogul suggests.