Skip to content

Conversation

@ScullWM
Copy link
Contributor

@ScullWM ScullWM commented Oct 29, 2015

Hi,

Recently I've just saw on different performance tools how composer file "autoload_classmap.php" can impact memory usage on each request. Regardless the project size, this file is very important.

So I've look closer to this file content and I've been surprise to see the number of files used for the differents projects librarys self-tests onto a production server.

So I made a very small patch excluding thoses files on "no-dev" mode (best choice for production).

On a "out of the box" Symfony 2.7.6, it concern 1288 lines on a total of 4332 (still 3044 line).
So I've choice to exclude them on no-dev mode.

Here's a blackfire stacktrace on a optimized autoload
https://blackfire.io/profiles/bf86642d-285c-481c-ae78-06447739b795/graph
And here a normal one to compare:
https://blackfire.io/profiles/4892e5be-07d2-480d-9249-95543599f136/graph

I've think that Test class hasn't utility on a server production mode, and reduce composer footprint is always welcome.

@xabbuh
Copy link
Contributor

xabbuh commented Oct 29, 2015

I see your need for this, but I think this is the wrong fix. What if I really wanted to use such a class (maybe the author just used a "weird" namespace)? The proper solution for this imho is to use autoload-dev in our packages for test classes (yeah we don't do that currently in Symfony as it's not really possible with the current directory structure).

@ScullWM
Copy link
Contributor Author

ScullWM commented Oct 29, 2015

@xabbuh thanks for the tips, I never saw this autoload-dev option, it would be great if it was used.

Concerning the use of a "weird" namespace, I've quickly imagine this case.
Seems that there is a "fallback" if a namespace is call and not previously dumped, so there is no blocking situation (just no dump performance gain).
If the case of "weird" namespace is rare this should still represent gain for mostly project.

@ScullWM ScullWM changed the title Exclude tests folder in no-dev mode [Perf gain] Exclude tests folder in no-dev mode Oct 30, 2015
@alcohol
Copy link
Member

alcohol commented Oct 30, 2015

This isn't something Composer should be fixing. It already has the tools in place to solve it properly. It's up to projects/maintainers now to adopt and use those :-)

@Seldaek
Copy link
Member

Seldaek commented Oct 30, 2015

Just merged #1607 which would allow fixing this more gracefully for package layouts like symfony. See https://getcomposer.org/doc/04-schema.md#exclude-files-from-classmaps for usage.

@Seldaek Seldaek closed this Oct 30, 2015
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.

4 participants