-
Notifications
You must be signed in to change notification settings - Fork 384
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
Exclude unused validator spec classes from amp-toolbox-php #7324
Comments
@westonruter This patch removes above mentioned Spec files from class map. diff --git a/composer.json b/composer.json
index f7fa32a78..433891905 100644
--- a/composer.json
+++ b/composer.json
@@ -53,6 +53,10 @@
],
"files": [
"includes/bootstrap.php"
+ ],
+ "exclude-from-classmap": [
+ "/vendor/ampproject/amp-toolbox/src/Validator/Spec/",
+ "/vendor/ampproject/amp-toolbox/src/Validator/Spec.php"
]
},
"autoload-dev": { To remove these files from our build, we can add EDIT:
Just tried excluding Spec files from the build and it results in a fatal error but removing these files from the class map works fine. |
The fatal error is due to some code in the plugin using a spec class? |
Not sure yet 🤔 . I am just curious why it's creating an instance of |
Those Validator\Spec files look like they're used during html optimization, and not just test specs (if that's what you were thinking), so you won't be able to remove them and shouldn't exclude them from the classmap. It still worked when you only removed from the classmap due to how you do the composer build currently without The performance issues originally noted were more likely due to the issue I brought up, having to do more with this fallback class lookup composer does when built without |
Got it. I see
Specifically these usages:
So if it ends up being that we should still exclude unused classes, perhaps we can just do so for |
to be honest, I would highly recommend not messing with excluding these files to avoid unexpected breakage in my opinion, the performance boost to be gained here is going to be adding |
OK, agreed. I'm removing this issue from the milestone and deprioritizing. |
@westonruter Do we still need this as something similar has been fixed in #7337. |
No, we can close this. |
Bug Description
The optimized autoloader generates a class map with many many files. The majority of these files (936 out of 1,375 or 68%) come from the validator spec files in amp-toolbox-php located in
vendor/ampproject/amp-toolbox/src/Validator/Spec/
. I received a report that theClassLoader
execution time was slow perhaps due to the large size of the class map. We can improve the runtime performance as well as decrease the number of files in the plugin by excluding these files from the build. The validator spec files are not being used by the plugin.Expected Behaviour
Unused validator spec classes should be omitted from the plugin.
Screenshots
No response
PHP Version
No response
Plugin Version
2.3.0
AMP plugin template mode
Standard, Transitional, Reader
WordPress Version
No response
Site Health
No response
Gutenberg Version
No response
OS(s) Affected
No response
Browser(s) Affected
No response
Device(s) Affected
No response
Acceptance Criteria
No response
Implementation Brief
No response
QA Testing Instructions
No response
Demo
No response
Changelog Entry
No response
The text was updated successfully, but these errors were encountered: