🌐 AI搜索 & 代理 主页
Skip to content

Conversation

@nicolas-grekas
Copy link
Member

@nicolas-grekas nicolas-grekas commented Aug 8, 2024

Q A
Branch? 7.2
Bug fix? no
New feature? no
Deprecations? no
Issues -
License MIT

Looking at the resource tracking cache, I figured out we could remove tracking some more resources.

On a webapp skeleton, this goes from 85 to 39 resources to track.

On my Ubuntu, I couldn't measure a difference, but on slow filesystems (Windows, shared mounts), I hope this might improve the DX a bit during dev. Anyone able to confirm?

@xabbuh
Copy link
Member

xabbuh commented Aug 9, 2024

The failures look related to the changes.

@nicolas-grekas nicolas-grekas force-pushed the config-res branch 2 times, most recently from 9fa19e3 to a29fb1e Compare August 12, 2024 10:13
@nicolas-grekas
Copy link
Member Author

The failures look related to the changes.

Yep, fixed

@nicolas-grekas nicolas-grekas force-pushed the config-res branch 3 times, most recently from 4b3dc48 to 07d646d Compare August 12, 2024 12:27
@nicolas-grekas nicolas-grekas merged commit 5df2af1 into symfony:7.2 Aug 13, 2024
@nicolas-grekas nicolas-grekas deleted the config-res branch August 13, 2024 10:08
nicolas-grekas added a commit that referenced this pull request Aug 30, 2024
… on cache clear, impossible to install new project (eltharin)

This PR was merged into the 7.2 branch.

Discussion
----------

[DependencyInjection] Fix bug on windows, memory exhausted on cache clear, impossible to install new project

| Q             | A
| ------------- | ---
| Branch?       | 7.2
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Issues        | Fix
| License       | MIT

Since #57948 on windows, I can't make a cache clear with a fatal error form memory exhausted or install a new symfony app.
Xdebug saw an infinite loop.

Correction with DIRECTORY_SEPARATOR constant instead /

Commits
-------

89b4c87 bug correction
continue;
}

if (!$inVendor = $this->inVendors($dir)) {
Copy link
Member

Choose a reason for hiding this comment

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

This logic looks wrong to me. Configuring a namespace prefixed to match a given directory does not mean that all classes matching that prefix must be defined in that folder.
For instance, all our mailer bridges have a namespace prefix that can also be matched by the prefix of the symfony/mailer package. And nothing prevents the project-level code to also define classes with that namespace (best practices is to keep your project-level code in a different namespace than your vendors, but that's not a requirement, and I know some projects do weird things).

For existing classes, we can optimize the class existence resource if the class is defined in the vendor folder (by checking the actual class definition, not folders in which it is maybe defined). For non-existent classes, we should not optimize the resource (or we should optimize it only based on all possible autoloading locations)

@GromNaN
Copy link
Member

GromNaN commented Sep 3, 2025

I figured out we could remove tracking some more resources.

After reading the code, I don't understand which new classes are excluded.

nicolas-grekas added a commit that referenced this pull request Sep 3, 2025
…peMC)

This PR was merged into the 7.3 branch.

Discussion
----------

[Config] Fix `ReflectionClassResource` hash validation

| Q             | A
| ------------- | ---
| Branch?       | 7.3
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Issues        | -
| License       | MIT

It looks like #57948 broke hash validation.

The problem is that `$excludedVendors` is now used to generate the hash but is not serialized. After unserialization, the property is empty, so the generated hash never matches the dumped one.

Commits
-------

cec2f00 [Config] Fix `ReflectionClassResource` hash validation
@stof
Copy link
Member

stof commented Sep 3, 2025

@GromNaN this is about skipping FileResource, DirectoryResource, FileExistenceResource and ClassExistenceResource for resources that are in the vendor folder (similar to how GlobResource was already skipped), as we have a FileResource checking the vendor/composer/installed.json file, which will be invalidated any time you change the installed packages with composer.

This is all based on the assumption that you don't edit manually files in the vendor folder. But as this is only about automatically invalidating the cache, this assumption is fine. You can clear the cache manually if you do weird things with your vendor folder.

nicolas-grekas added a commit that referenced this pull request Sep 3, 2025
…e (nicolas-grekas)

This PR was merged into the 7.3 branch.

Discussion
----------

[DependencyInjection] Fix optimizing ClassExistenceResource

| Q             | A
| ------------- | ---
| Branch?       | 7.3
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Issues        | -
| License       | MIT

Per `@stof` review at #57948 (review)

Best reviewed [ignoring whitespaces](https://github.com/symfony/symfony/pull/61615/files?w=1).

Commits
-------

b7ca948 [DependencyInjection] Fix optimizing ClassExistenceResource
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