Problem/Motivation
Per @phenaproxima, we only use symfony/finder for convenience and symfony/config for autowiring:
adam.hoenich: My preference would actually be to remove the dependency on symfony/finder. We currently depend on it for convenience. With a little work I think we could refactor it out
wim.leers: ah!
adam.hoenich: And maybe even symfony/config too, if we can find a way to load in Composer Stager and its autowiring
wim.leers: is that what it’s for?!
adam.hoenich: It is.
wim.leers: lol
wim.leers: okay
adam.hoenich: If you look at PackageManagerServiceProvider, it’s the only way I could expose all those classes to the container. It needed things that exist in symfony/config
We should verify that we need these dependencies. A whole new dependency for Drupal core/AU is not worth it if it just saves a few LoC.
Steps to reproduce
Proposed resolution
- Remove dependency on
symfony/finder - Add
symfony/configas a core dependency per #11: #3326246: Add symfony/config to core's dependencies for package_manager
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #41 | errorss.png | 368.69 KB | yash.rode |
| #35 | Screenshot 2023-02-15 at 5.48.16 PM.png | 243.52 KB | omkar.podey |
Issue fork automatic_updates-3321933
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
wim leersComment #4
wim leersComment #6
wim leerssymfony/finderactually is already required by Drupal core since #3031379: Add a new test type to do real update testing and8.8.0… so nothing to do there! 🥳Comment #7
phenaproximaSorry to be the bearer of bad news, but that is, as far as I know, a dev dependency of core, not a runtime dependency. So I think we have two options:
Comment #8
phenaproximaComment #9
wim leers#7: D'oh, great point — I missed that! 🙈 Thanks! 🙏
Comment #10
tedbowComment #11
wim leers+
+
→ I don't see how we can avoid using
symfony/configif we don't want to make\Drupal\package_manager\PackageManagerServiceProvider::register()a lot more complicated.https://symfony.com/doc/current/components/config.html says:
… which sounds like a reasonable component to include in Drupal core.
Comment #12
wim leerssymfony/finderis used in:\Drupal\package_manager\PathExcluder\GitExcluder\Drupal\package_manager\PathExcluder\NodeModulesExcluder\Drupal\package_manager\Validator\DuplicateInfoFileValidatorI'm tempted to say that that code clarity is worth it.
But Drupal also has a
drupal/core-filesystemcomponent, which has a pretty capable\Drupal\Component\FileSystem\RegexDirectoryIterator. Trying to convert to that…Comment #13
wim leersBeen fighting
\RecursiveFilterIteratorand friends, getting there. Should be able to wrap this up tomorrow.Comment #14
wim leersComment #15
wim leersComment #16
wim leersIf you agree with this direction, we'll need to add #3326246: Add symfony/config to core's dependencies for package_manager to #3319030: Drupal Core Roadmap for Package Manager and Update Manager.
Comment #17
wim leersMerged in the upstream changes from the past ~month.
Explicitly assigning to @tedbow to (finally 😅) get feedback.
I still cannot reproduce the DrupalCI-only failures locally. Here's hoping that was an ephemeral problem on the DrupalCI infrastructure … 🤞
Comment #18
wim leersIt clearly isn't ephemeral. @tedbow: can you reproduce the failures locally?
Comment #19
tedbowI checked some of the test failures and they pass for me locally
@Wim Leers Just to be clear you didn't manually abort any of these test runs, correct? They just timed out?
I see this in the console output for all the ones I have checked so far
Which is strange that we would get a bunch of un-reproducible test fails and a time out.
since
\Drupal\package_manager\Validator\DuplicateInfoFileValidator::findInfoFilesand similar methods scan the entire codebase for particular files could the replacement tosymfony/finderbe that much worse on performance that it causes this timeouts and test failures?Comment #20
tedbowI tried
\Drupal\package_manager\Validator\DuplicateInfoFileValidator::findInfoFileslocally and it seemed not using symfony/finder was actually faster so maybe something with drupalci makes it slower?Comment #22
tedbowok the latest test failure 3321933-performance-test I proves that using
symfony/finderis for some reason much slower on drupalciComment #23
tedbowPushed up a version with data provider to run the test multiple times
My guess is either:
Comment #24
tedbowas a try to exclude #23.2 I pushed up a change ensure that the methods find the same files.
As way determine if #23.1 is correct someone could update \Drupal\Tests\automatic_updates\Unit\PerformanceTest::testPerformance to programmatically create folder with say 1000 files in
setUp()and then use that as the directory to scan. Then we could tell if the just given a known folder with a lot of files if thesymfony/findermethod was just dramatically faster on drupalci for some reason.I am not going to work on this right now if anyone else wants to try this
Comment #25
wim leersThanks, great research, @tedbow! 👍
After discussing with @tedbow, I have some ideas on how to move forward here now — there likely is a lot of additional directories on DrupalCI that we don't have locally, but we don't know where yet 🫣
Comment #26
wim leersNow that #3328742: phpcs stopped working since the switch to testing on Drupal 10.0.x by default is finally done, this is the next most important issue! Will continue this tomorrow.
Comment #27
omkar.podey commentedComment #28
omkar.podey commentedDrupal CI behaves weirdly , does not run tests according to
drupalci.yml, hence the retests.Comment #30
omkar.podey commentedTest times
New PR
kernel - 6:24 mins
functional - 13 mins
build - 14 mins
baseline
kernel - 7.24 mins
functional - 7.49 mins
build - 12 mins
Comment #31
omkar.podey commentedWe can clearly see that functional tests are running slower , so i thought the only thing that functional tests are using that we changed is
package_manager/tests/src/Traits/FixtureUtilityTrait.phpbut even without the changes in it they still seem to run slower.retesting as i forgot to temporarily add it back to composer.json
Comment #32
omkar.podey commentedPerformance test results
The old finder and the RecursiveDirectoryIterator are definitely looking at different files and the RecursiveDirectoryIterator is making more passes on the same files (indicated by the numbers in front of the discovered file names)
Comment #33
tedbowComment #34
omkar.podey commentedFrom the latest test i think i can conclude 2 things
RecursiveDirectoryIteratoris the only one that see's the weird structure.Comment #35
omkar.podey commentedComment #36
omkar.podey commentedComment #37
omkar.podey commentedI did try to create a symlink locally but was unable to recreate the same pattern of paths.
Comment #38
wim leersIt doesn't need to be me who works on this, so if somebody wants to dig into this before I get to it, please do!
Comment #39
yash.rode commentedComment #40
yash.rode commentedWhen I debugged this I get ~7500 from
withOutFinder()and ~250 files fromwithFinder().Comment #41
yash.rode commentedTest failing with on
self::assertSame($txt_files_finder, $txt_file_no_finder);line in\Drupal\Tests\automatic_updates\Unit\PerformanceTest::testPerformance(). The results are identical still the test is failing.Comment #42
yash.rode commentedNeed help with the error
Comment #43
wim leersReproduced the infamous recursive Omkar locally:
→ I'll continue here.
Comment #44
wim leersTurns out that the reason the
3321933-performance-testis actually very simple:withFinder()never calls\Symfony\Component\Finder\Finder::followLinks(), which is why it is ignoring symlinks entirelywithOutFinder()specifies$flags |= \FilesystemIterator::FOLLOW_SYMLINKS;, which causes it to do the opposite⇒ the recursive Omkar mystery is solved: https://git.drupalcode.org/project/automatic_updates/-/merge_requests/64...
Comment #45
wim leersThat puts us at:
→ better, but still not perfect.
Reason for that: we're again not yet matching
Finder's behavior, which has this:… while we have nothing like that at all in our logic in
PerformanceTest.Now tests pass:
So it's faster 100% of the time. Adding
makes that more clear:
I bet that the root cause for the actual MR (https://git.drupalcode.org/project/automatic_updates/-/merge_requests/59...) was similar: none of the code in
package_manageris callingFinder::followLinks()!Comment #47
wim leersNew MR opened … waiting for it to fail before pushing the commit that will remove
\FilesystemIterator::FOLLOW_SYMLINKS🤓Comment #48
wim leersLooks like
\FilesystemIterator::CURRENT_AS_SELFis causingphpstanconfusion? 😳 😬 Trying more…Comment #49
wim leersWell well well … looks like this even works just like that, by just literally porting the MR I had created months ago against
8.x-2.xto3.0.x(and fixing the PHPStan violations which even then were not running anymore apparently) … 😳I bet:
symlink-related things).But! It's still slower! The functional tests no longer time out like in January, but they run excruciatingly slow. So pushed a commit just now to stop following symlinks, just like the validators were doing previously.
Comment #50
wim leersHah!
ec30ba81even finished befored2c2aac2even despite it starting tests roughly an hour later… 😅 In fact, it's currently still going:Comment #54
wim leers⚠️ While #49 matches
HEAD's current behavior, after #3319507: Add symlink support to Composer Stager 2.0, require that version, and simplify UX & tests accordingly lands, we will be accepting most symlinks. Which means validators should also follow them while validating. Captured at #3319507-26: Add symlink support to Composer Stager 2.0, require that version, and simplify UX & tests accordingly.CorePackageManifestTestandFixtureUtilityTraitwill not be affected.Comment #55
wim leersPosted informative comments on the open MR, closed all other MRs. This is now hard-blocked on review, at last! 🥳
Comment #56
phenaproximaThis looks really good. I think it could maybe use a little consolidation and documentation but I have no objections otherwise.
Comment #57
wim leersComment #58
wim leers#3305568: Create a validator that detects duplicate info.yml files in the stage on apply introduced
DuplicateInfoFileValidator. It is what introducedignoreUnreadableDirs()without documenting why. So that leaves some lack of clarity about how we should support this.So I propose to instead just reuse core's
ExtensionDiscovery😊Comment #59
phenaproximaA question, a request to revert something that didn't need to change, and a couple of nits. Then this, in my opinion, is ready and I will be glad to see it land!
Comment #60
wim leersAll feedback addressed! 👍 Some really good catches in there! 👏 Thanks for the thorough review 😊
Comment #61
phenaproximaRe-titling, because the final MR does not document why we need symfony/config. That's okay, though.
Comment #63
phenaproximaGlad to see this alpha blocker bite the dust!
Comment #64
effulgentsia commentedHere's a follow-up for that: #3345039: Remove dependency on symfony/config
Comment #65
wim leers#61: I did document that as part of working on this issue: see #11, and #3326246: Add symfony/config to core's dependencies for package_manager. This is all stated in the issue summary. Nowhere in Drupal core is it documented in code why a certain composer package is being depended upon, so doing that here would've been out of scope.