Expression size limitations

26 views
Skip to first unread message

Andy Maule

unread,
Feb 28, 2024, 2:14:12 AMFeb 28
to CEL Go Discussion Forum
Hi all,

We've been evaluating cel for some use cases, but the spec says that standard only has to support expression of a very limited size. In the cel-go implementation how large can expressions practically get, are there any hard limits? We're looking into running expressions from user generated content, so they could potentially be large.

Thanks,

Andy

Tristan Swadell

unread,
Feb 28, 2024, 12:10:33 PMFeb 28
to Andy Maule, CEL Go Discussion Forum
Hi Andy,

Personally, I've seen some expressions which are approximately 100-200 lines which are still running in low double digit micros. A lot of that is really heavily dependent on how you structure your expression, whether you're doing object creation, lots of comprehension, etc. 

I would consider that the expression performance will be bound by the size of the input and the size of the expression, and work from those assumptions to set practical limits on user-provided content. Are the expressions from trusted users or from folks who you don't know at all?

-Tristan

--
You received this message because you are subscribed to the Google Groups "CEL Go Discussion Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cel-go-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cel-go-discuss/3434204d-3b99-4d74-87c1-ca5e5789b1e6n%40googlegroups.com.

Andy Maule

unread,
Feb 29, 2024, 11:00:24 AMFeb 29
to CEL Go Discussion Forum
Thanks Tristan. I was actually thinking of expressions that could be much bigger. What we're looking at is user supplied, but mostly trusted, and can be quite large in size. 

If I run a large expression I see there is currently a limit:
"failed to compile the CEL expression: ERROR: <input>:-1:0: expression code point size exceeds limit: size: 6850445, limit 100000"

I'll check the code and see where this limit is coming from.

Tristan Swadell

unread,
Feb 29, 2024, 11:07:08 AMFeb 29
to Andy Maule, CEL Go Discussion Forum
Hi Andy,

The codepoint limit is from the parser. You can adjust it, though I may not have exposed this as an option. I had not anticipated a 6MB expression. You might easily hit this in the aggregate over all CEL expressions, but generally there's some partitioning of the expression space.

If you have more details, I can probably help you come up with an alternative approach that meets your needs and keeps expression sizes reasonable.

-Tristan

Reply all
Reply to author
Forward
0 new messages