-
Notifications
You must be signed in to change notification settings - Fork 441
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
Performance issue when loading text domains. #2721
Comments
I think we might be able to defer descriptions to be a callback and only execute them when actually called. . .like in introspection queries, for example. 🤔 |
@creative-andrew I don't believe this is the case. Let's take a look: WordPress, no pluginsIf we setup a fresh WordPress install (I'm using localwp to do it) and visit the But we can use this as our baseline of WordPress execution. We can see that the "apply_filters" gets called 8,246 times And then we can dig in and see that "translate" calls it 1,954 times. If we visit the "apply_filters" is called 8,887 times for this REST endpoint, and "translate" is called 4,110 times. If we visit the "apply_filters" is called 17,108 times for this REST endpoint, and "translate" is called 8,218 times. WPGraphQL ActiveIf we activate WPGraphQL (v1.13.8) and visit the If we look at the profiling for this request, we'll see the following: apply_filters called If we go back to WPGraphQL v1.6.5 (shortly after the 1.6 release that targeted the "lazy loading" problem) we would see the following output: apply_filters called So yes, a there's an increase from some of the other endpoints, but definitely not the whole schema worth. If we go back to WPGraphQL v1.5.9, before the v1.6.0 release, we will see a significant change in the profiling, just by visiting the Here we see I definitely think we have something to address here, but I don't think we have a regression to the 1.6 release. I don't see evidence suggesting that "the whole schema seems to be created and queried during each request". This would be true for Introspection Queries, but I don't believe it's the case for every query. Now, when queries are executed, the Types required to fulfill them will be loaded, so that would have an increase as well, but definitely not to the scope of loading the whole schema for each request. So, the more complex queries get, the more types will be loaded, so I would expect an increase in Types being loaded for more complex queries. I think we definitely should look into how we can register Types/Fields so that the descriptions are only executed/translated when needed (i.e. in Introspection Queries), but again, I don't believe there's evidence of a regression to 1.6 where the entire Schema is being loaded. |
(related: caching get_schema() thread on slack ) |
Related https://wp-graphql.slack.com/archives/C3NM1M291/p1684225596339229 Just for clarifying when I mentioned that the schema was called or registered on every request, I meant the schema inflation process. |
From core: https://make.wordpress.org/core/2023/07/24/i18n-performance-analysis/ Seems like adopting lazy-loading is the way to go, while still benefiting from any upstream improvements to the parser. |
Description
Every single GraphQL field has a semantic description, which looks like is getting translated on every single query even though they don't really need to be.
This is creating massive calls to the
__()
andload_textdomain()
functions.Additionally, the whole schema seems to be created and queried during each request, generating a massive object that is impossible to cache.
Steps to reproduce
Blocking
wp-graphl
text domain on demand.If you prevent loading the
$mofile
for thewp-graphql
text domain you would notice the speed bump. As a quick solution, developers can add this to a mu-plugin checking if the request is a WPGraphQL request. This solution should be removed once we have found a better approach.A testing branch has been created by another collaborator with the same issue: #1873 (comment) @idflood
Additional context
No response
WPGraphQL Version
1.13.8
WordPress Version
6.1.1
PHP Version
8.0.27
Please confirm that you have searched existing issues in the repo.
Please confirm that you have disabled ALL plugins except for WPGraphQL.
The text was updated successfully, but these errors were encountered: