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

Allow static analysis of performance #299

Open
salman-ca opened this issue Dec 11, 2018 · 10 comments
Open

Allow static analysis of performance #299

salman-ca opened this issue Dec 11, 2018 · 10 comments
Labels
enhancement Improve the expected

Comments

@salman-ca
Copy link

Just a few general questions on liquid-rust.

  1. would you say this implementation provides the same level of safety as the ruby version? i.e. since an end user can create their templates, they won't be able to do anything dangerous.

  2. Is there a way to introspect the liquid document. I believe in the ruby version you can see how many if statements, loops etc. the template has (this is probably to analyze the general complexity of the template - or limit the # of certain tags).

Great work!

@epage
Copy link
Member

epage commented Dec 11, 2018

  1. I'd say this implementation is safer. The ruby version blurs the line between liquid and ruby and they have to go through extra hoops to ensure it is safe. The Rust version does not have any escape hatches like that.

  2. As of right now, there is not a way to introspect the document. Currently, the document gets turned into Box<dyn SomeTrait> where the implementations of the trait aren't exposed such that you can't even dynamic cast them. I'd be interested to know what the use case would be for us to consider opening this up which also help us know what would be the best way to open it up.

@salman-ca
Copy link
Author

Regarding #2, the use case is as follows. If you allow the end user to create their own templates, they might write very inefficient templates such as abuse of looping statements etc.
If you can introspect the types and # of statements, you could generate some kind of a usage score on the template (in addition to rendering the template - but introspection could prevent you from evening rendering if it is flagged as such).

That is the use case I am thinking about.

@epage
Copy link
Member

epage commented Dec 11, 2018

So a static analysis profiler, interesting. I'll have to give this some thought on the best way to handle it.

On a related note, we also need to take care of #300.

@epage epage changed the title General questions on the lib Allow static analysis of performance Dec 11, 2018
@epage epage added the enhancement Improve the expected label Dec 11, 2018
@salman-ca

This comment was marked as off-topic.

@epage

This comment was marked as off-topic.

@salman-ca

This comment was marked as off-topic.

@chipsenkbeil

This comment was marked as off-topic.

@epage

This comment was marked as off-topic.

@RyanAmos

This comment was marked as off-topic.

@epage

This comment was marked as off-topic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improve the expected
Projects
None yet
Development

No branches or pull requests

4 participants