-
-
Notifications
You must be signed in to change notification settings - Fork 163
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
optimalization of the file system enumerator, which now uses the glob function (in Symfony Finder) #402
Conversation
Rastusik
commented
Dec 15, 2018
- this helps with using aspects from vendor folder, which needs to be scanned, but with proper include paths, the scan is not so slow anymore
… function (in Symfony Finder) - this helps with using aspects from vendor folder, which needs to be scanned, but with proper include paths not as slow anymore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the pull request. Solid changes there.
Would love if you address the requested changes.
But don't know how @lisachenko goes with adding another package dependency.
For me its fine tho. Thanks again.
\FilesystemIterator::SKIP_DOTS | \FilesystemIterator::UNIX_PATHS | ||
) | ||
); | ||
$finder = new Finder(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would recommend using Finder
as a dependency for now. Should make up for a more solid test.
Also I just realized, that this operation here is a bit IO heavy.
If you call enumerate
a number of times you will always hit IO to scan again for files.
I get that there could be new files added between two concurrent runs, but I guess this would not happen on a production environment.
Maybe @lisachenko could say more about this ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, the IO heavy operation is there anyway, whether with Finder or using the old way... I didn't want to mess with the original design, this was supposed to be just an optimization... hopefully there won't be a problem with the new dependency, since it isn't dependent of anything else...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@icanhazstring not sure what you meant with the requested changes - just the typo or also something regarding this conversation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ye I know that this was like this before. Just realized it by now.
And after thinking this has nothing to do with this PR - might be subject for another PR - so for me everything is fine 👍
@lisachenko just has to accept/merge it ;)
Co-Authored-By: Rastusik <rasta@lj.sk>
The inspection completed: 2 updated code elements |
@icanhazstring sorry to bother, but is there a reason why this PR isn't merged yet? Do I have to do anything else to make things go faster? Just tell me and I'll do anything what is needed. |
@Rastusik unfortunately I don't have permission to merge. 😕 @lisachenko pls merge if you can :) |
Hello, guys! Sorry for being unavailable, unfortunately I have not so much time now for working on my project, thus PRs accept time is increasing ( |
Regarding this PR, how it helps to apply aspects to vendor folders? Could you please elaborate? This feature was available before this PR. |
@lisachenko yes, the mentioned feature (including aspects from vendor folder) was available before. This PR only optimizes the file scanning process, so the scan is much faster then before (the scan length is proportional to the amount of files in the vendor folder). The scans were slowing my development process, so I made them faster using glob patterns (under the hood in Symfony Finder) |
@Rastusik ok, I understood. Of course, I don't like too much adding new dependency :) But reinventing the wheel is not good option too... Ok, let's proceed with |
This issue brings some pain under Windows platform.
Looks like |
Ouch. Maybe we should setup a travis build for windows as well? And ofc fix this one as well ;) |
Yes, definitely. Previously AppVeyour was used, but it's buggy as hell, half of builds were broken. But now Travis-CI support Windows https://blog.travis-ci.com/2018-10-11-windows-early-release, so it's natural way to enable this. |
Currently php support seems a bit buggy. But possible: |
If someone creates a windows build somewhere (at least appveyor), I can take o look and make a fix |
@Rastusik build on windows works now. You can start :D |
I don't know why it is not reproduced on Windows build right at the moment, but look at https://3v4l.org/DITGg to see that it is real. Stack trace is following:
|
@lisachenko so I was thinking again and it seems that the fix could be quite easy, but I'm not sure whether I won't break anything with it. The problem seems to be the usage of backslashes in the windows paths. AFAIK the solution would be to use slashes everywhere, even on windows machines, but I'm not 100% sure with that. The easy solution should be as follows. There is this method in the AspectKernel: protected function normalizeOptions(array $options): array
{
$options = array_replace($this->getDefaultOptions(), $options);
$options['cacheDir'] = PathResolver::realpath($options['cacheDir']);
if (!$options['cacheDir']) {
throw new \RuntimeException('You need to provide valid cache directory for Go! AOP framework.');
}
$options['excludePaths'][] = $options['cacheDir'];
$options['excludePaths'][] = __DIR__ . '/../';
$options['appDir'] = PathResolver::realpath($options['appDir']);
$options['cacheFileMode'] = (int) $options['cacheFileMode'];
$options['includePaths'] = PathResolver::realpath($options['includePaths']);
$options['excludePaths'] = PathResolver::realpath($options['excludePaths']);
return $options; This method uses PathResolver to sanitize the paths in the options config. In the // resolve path parts (single dot, double dot and double delimiters)
$path = str_replace(['/', '\\'], DIRECTORY_SEPARATOR, $path);
if (strpos($path, '.') !== false) {
$parts = explode(DIRECTORY_SEPARATOR, $path);
$absolutes = [];
foreach ($parts as $part) {
if ('.' === $part) {
continue;
}
if ('..' === $part) {
array_pop($absolutes);
} else {
$absolutes[] = $part;
}
}
$path = implode(DIRECTORY_SEPARATOR, $absolutes);
} I would suggest to not to use the DIRECTORY_SEPARATOR constant anywhere - I would replace the backslashes for slashes. What do you think? |