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

Speed up #426

Open
3 of 5 tasks
lulco opened this issue Aug 3, 2023 · 8 comments
Open
3 of 5 tasks

Speed up #426

lulco opened this issue Aug 3, 2023 · 8 comments

Comments

@lulco
Copy link
Contributor

lulco commented Aug 3, 2023

@MartinMystikJonas
Copy link
Collaborator

It would be ideal to have same dir for following runs for same project to make use of phpstan results cache. But we need to figure out how to prevent overwriting identical templates (so phostan would not thinknit changed) and how to clean up old templates.

Maybe first compile to some tmp dir and then compare this tmp dir with analysed dir?

@lulco
Copy link
Contributor Author

lulco commented Aug 3, 2023

Complete? Great :)

I'm ready to sacrifice our internal compiled template cache mechanism for the sake of speed up. I'm cleaning the phpstan latte dir before almost each run anyway

@lulco lulco reopened this Aug 3, 2023
@lulco
Copy link
Contributor Author

lulco commented Aug 3, 2023

Question is: “what is slowest part of this extension?”
My candidates:

  • non-paralell analysis (phpstan a analyse in one thread)
  • compiling templates
  • Adjusting compiled templates (node visitors)

@MartinMystikJonas
Copy link
Collaborator

Sorry I put unlocked phone to my pocket 😀

My main candidate is latte context collection for template resolvers. But it is also hardest thing to speed up significantly.

@lulco
Copy link
Contributor Author

lulco commented Aug 3, 2023

I did some simple measurements:
Getting context is slow but not slowest part. Two slowest parts are: "compiling + adjusting templates" and "analysing files".

Sometimes analysing files is the slowest, sometimes adjusting templates is the slowest. I'm not sure if it depends on size of template or something else.

We can look at node visitors, but there is not much things to approve if we want to have testable compiled templates, but we can try to run phpstan via "exec"-like command. We will see

@MartinMystikJonas
Copy link
Collaborator

Idea for adjusting templates: Maybe visitors can specify some fast checks (like template/comoiled template contains given string/regex) and run only if it is true.

For example it does not make sense to run forms related visitors for templates without any form/input tags.

@lulco
Copy link
Contributor Author

lulco commented Aug 4, 2023

Idea for adjusting templates: Maybe visitors can specify some fast checks (like template/comoiled template contains given string/regex) and run only if it is true.

For example it does not make sense to run forms related visitors for templates without any form/input tags.

I like the idea for fast checks, just don't like the implementation with regexes, but maybe it is best thing we can do :)

@lulco
Copy link
Contributor Author

lulco commented Aug 6, 2023

I've achieved 12% speed up on my test app with running phpstan on compiled templates via shell_exec. I have to admit it is lower then my expectations :D Tomorrow I'll push it and you can try it too.

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

No branches or pull requests

2 participants