-
Notifications
You must be signed in to change notification settings - Fork 24
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
Zero-allocation* redesign #76
Comments
While not zero-allocation, have you considered integrating with the protobuf ecosystem? There is prost-reflect which provides a |
This only works if you're not passing temporaries into EDIT 1: Also, if So the default implementation should be: /// Called when other [`Value`] is added to this type.
#[inline]
fn add(&self, second: Value) -> ResolveResult {
Err(ExecutionError::UnsupportedBinaryOperatorExternal(
"add", std::any::type_name::<Self>(),
))
}
/// Called when this type is added to other [`Value`].
///
/// Override if addition is non-commutative.
#[inline]
fn add_to(&self, first: Value) -> ResolveResult {
Self::add(self, first)
} |
Tried doing this at some point, just letting you know you'll need to introduce an additional lifetime to a lot of functions in I personally don't understand what magic does without spending a day/two examining the code and explanation from the forum, but I'm not invested enough (i.e. too busy) to do so atm. This is however one of those changes that are better done earlier than later because as more features are tackled on it will be more and more difficult to implement it without breaking/rewriting everything. |
This issue is meant to be a scratchpad for ideas and feedback on improving how types and values are handled in the interpreter. There have been several different feature requests recently that could be solved by the a fundamental shift in how CEL values are managed.
Value
when only some fields in those types are actually referenced.serde_json::Value
.Today any value referenced in a CEL expression is owned by either the
Program
or theContext
. TheProgram
owns values that were created directly in the CEL expression, for example in the expression("foo" == "bar") == false
, there are three values owned by theProgram
, "foo", "bar", andfalse
. Values that are owned by theContext
are values that are dynamically provided at execution time to aProgram
as variables, likefoo == bar
, bothfoo
andbar
are values owned by the Context.Context
so that it does not own any data, meaning that you do not need to clone your types to use them in CEL. Instead I'd like theContext
to have references to that data.Questions:
Arc
/Rc
's anymore or could we get away with just this since we would assume the caller owned all the data. RIght now, anArc
is required for values owned byProgram
because aProgram
can be executed one or more times simultaneously.Value
enum, we have aValue
trait that exposes every behavior supported in a CEL expression, i.e.:The text was updated successfully, but these errors were encountered: