Skip to content

Improve performances by improving composer autoload #9102

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

Closed
wants to merge 1 commit into from
Closed

Improve performances by improving composer autoload #9102

wants to merge 1 commit into from

Conversation

jacquesbh
Copy link

Improve the autoload by removing a lot of file_exists() calls.

Description

I just added the classmap element in autoload in composer.json.

If the directory doesn't exist composer will complaint about it. So I also added a .gitkeep file.
Which for me is a good way to make it work.
It's worth the improvement.

Fixed Issues

Didn't find a relevant one.

Manual testing scenarios

Use composer dumpautoload -o before the change, load the page (all caches enabled, but works also without).
Then calculate the number of file_exists calls.

Make the change, re-run the dump of the autoload, then call your page again.

Don't forget of course to flush the cache between operations.

Here is the comparison with cache enabled: https://blackfire.io/profiles/compare/7a733717-695d-495f-8bfe-0ffc65154894/graph

The autoload_classmap.php has +3k lines after this. So, in best scenarios it can avoid 3k file_exists.

Contribution checklist

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds on Travis CI are green)

@vrann
Copy link
Contributor

vrann commented Apr 14, 2017

@jacquesbh I noticed that you added "var/generation/Magento/" to the classpath. The latest develop branch uses generated/Magento directory instead. Have you tried that on the latest codebase?

@jacquesbh
Copy link
Author

jacquesbh commented Apr 15, 2017 via email

@adragus-inviqa
Copy link
Contributor

Looks like the path can be dinamycally changed when calling the compilation CLI command (note the --generation option): link. Will/must this PR take that into consideration, too?

@jacquesbh
Copy link
Author

jacquesbh commented Apr 15, 2017 via email

@ishakhsuvarov ishakhsuvarov self-assigned this Apr 21, 2017
@ishakhsuvarov ishakhsuvarov added this to the April 2017 milestone Apr 21, 2017
@ishakhsuvarov
Copy link
Contributor

@jacquesbh Closing per your comment.
Thank you for collaboration.

@mslabko
Copy link
Member

mslabko commented Feb 22, 2018

@jacquesbh , thank you, this is a good improvement. Could you please create PR to https://github.com/magento/devdocs?

@mslabko
Copy link
Member

mslabko commented Feb 23, 2018

Hi @jacquesbh
I've checked di:compile command and there are no extra options. Our devdocs is outdated and all described options related to DiCompileMultiTenantCommand.php, which available only for 2.0.x version.

It would be really great if you will create a new PR to 2.3-develop (and after merging backport it for 2.2-develop) with proposed changes.
And I think it makes sense to add a mapping for "generated/code/", so, not only Magento modules will be processed.

Also, it will be very cool, if you update our devdocs for 2.2.x and 2.3.x versions.

@mslabko
Copy link
Member

mslabko commented Feb 26, 2018

@jacquesbh what do you think about this? Will you have time to prepare this PR for 2.3-develop branch.
If you don't have time now, would you don't mind if we implement such changes by ourself?

@jacquesbh
Copy link
Author

Hi @mslabko :)

I put that in my todo list. I will do it. This week probably.

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

Successfully merging this pull request may close these issues.

5 participants