-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[2.2] [WIP] [Finder] Adding native finders implementations #4061
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
Conversation
* | ||
* @return bool | ||
*/ | ||
function isValid(); |
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.
What about isSupported
?
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.
You're right... i keep it in mind for a future cleanup.
@jfsimon What's the status of this PR? |
@fabpot 2 features missing for the GNU find adapter: sorting result with |
BTW @jfsimon, in the (quite specific) case where you don't precise filenames or other options but only |
@jfsimon Would be nice to be able to include this PR before 2.1.0 beta2. Would you have time to finish the work soon? |
function searchInDirectory($dir); | ||
|
||
/** | ||
* Tests adapter support for current plateform. |
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.
platform... is it a typo?
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.
yep, fixed
public function end() | ||
{ | ||
if (null === $this->parent) { | ||
var_dump($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.
maybe var_export inside exception instead if you really need it
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.
this is here for debugging, not for production... removed
It seems that I need to perform some benchmarks as find may not be so fast :/ |
Then benchmark scripts won't be part of the repository in the end, so you should create a new repo for that. |
@fabpot @smaftoul Benchmark is ready (more cases to come): https://github.com/jfsimon/symfony-finder-benchmark |
@jfsimon could you make a gist with the result of the benchmark ? I think many people will be lazy to run it themselves when looking at this ticket, and people using windows will probably be unable to run it at all :) |
First results: https://gist.github.com/3107676 |
Sorry, I forgot |
@jfsimon you can edit the commit message whne doing an interactive rebase. and btw, you will need to do a rebase anyway: the PR conflicts with master |
} | ||
|
||
/** | ||
* Returns reegistered adapters ordered by priority without extra informations. |
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.
typo here
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.
two of them ^^
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 just see the double e
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.
information without s
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.
fixed
It seems that I'm an idiot, I used |
They are, but the regex are not faster than glob anymore in these results |
@travisbot you failed, not me! |
Anyone to launch benchmark with php 5.4? |
Bench with php 5.4.5 |
@fabpot |
As the Windows implementation could take a while, I would vote for a separate PR so that the GNU adapter can be merged without waiting the windows one. |
👍 with @stof. There is no benefits to wait the windows adapter. |
@fabpot Do you need something to be done before merging? |
@jfsimon I hadn't had a look at this PR since a long time as it has "WIP" in the title. Can we talk about it tomorrow? |
@fabpot with pleasure :) |
Based on my findings, the actual cause for Finder's poor PHP adapter performance seems to be that it is using Iterators instead of RecursiveIterators. This causes the RecursiveIteratorIterator to perform a full (as in total) recursive filesystem scan without limitation, and Finder filters out unwanted items only afterwards. By replacing the FilterIterators with RecursiveFilterIterator implementations, the total time for a limited filesystem scan can be easily reduced (cut in half, in my cases), especially when applying directory name or depth filters. What I'm trying to say is — I'm not sure whether the abstraction into shell adapters is actually needed. It looks like the actual culprit are the iterator implementations, and fixing those could get the PHP adapter fairly close to the numbers of the shell commands — whereas it is easily possible that the additional abstraction into adapters unnecessarily cripples performance again. Are there any plans to re-implement Finder with Recursive*Iterators? (of course, that would be a major API break) FWIW, here are the results of my investigation. |
@sun: Thanks for the information. That's very interesting. IIUC, the major API break would be for the iterators, not for the public API (the one in the main Finder class), right? If that's the case, I'm +1 for the refactoring. Would you like to help on this refactoring? |
Work in progress...
Bug fix: no
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets: #4031
This PR intends to add native finders implementation based on shell command execution.
Planned support concerns:
find
command -> doneFINDSTR
command