Skip to content

[Config] Improve GlobResource performance #50087

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

Merged
merged 1 commit into from
Apr 21, 2023

Conversation

staabm
Copy link
Contributor

@staabm staabm commented Apr 21, 2023

Q A
Branch? 6.3
Bug fix? no
New feature? no
Deprecations? no
Tickets Fix #...
License MIT
Doc PR symfony/symfony-docs#...

Re-order conditions in GlobResource to prevent unnecessary file IO, which improves performance of the following test-script.

put this script into the symfony/symfony project root and run it

<?php

error_reporting(E_ALL);

require __DIR__.'/vendor/autoload.php';

$glob = new \Symfony\Component\Config\Resource\GlobResource(__DIR__.'/src/', '/**/*.php', true);
foreach($glob as $file) {
    echo $file->getRealPath()."\n";
}

I did a few measures and it consistently reports a 15-18% improvement

grafik

https://blackfire.io/profiles/compare/647af42c-c4e5-495e-8f8d-1b77f61631dd/graph

@symfony symfony deleted a comment from carsonbot Apr 21, 2023
@staabm
Copy link
Contributor Author

staabm commented Apr 21, 2023

I am not sure whether perf improvements are considered a bug or not. I am open for guidance relating the target branch.

Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

6.3 is perfect

@nicolas-grekas
Copy link
Member

Good catch, thanks @staabm.

@nicolas-grekas nicolas-grekas merged commit 24b1b02 into symfony:6.3 Apr 21, 2023
@staabm staabm deleted the less-glob-io branch April 21, 2023 08:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants